[vtkusers] best way to save vtkpolydata for ANSYS

InfoSeekerr ali.mahmoud.habib at gmail.com
Fri Dec 25 16:42:58 EST 2009


Dear David,
this is the complete code 
/// Start reading DICOM data-> 
            vtkDICOMImageReader v16 = vtkDICOMImageReader();
            v16->SetDirectoryName(@"D:\work\Master
Degree\DataSet\case2\DICOM\PA1\ST1\SE2");
            v16->SetDataOrigin(2, 2, 1);
            v16->Update();


            /////////////////////Pre processing
/////////////////////////////////////////////////
            // STEP 1:
            vtkImageShrink3D VIS = vtkImageShrink3D::NEW();
            VIS->SetInputConnection(v16->GetOutputPort());
            VIS->SetShrinkFactors(2, 2, 1);
            VIS->Update();
            // STEP 2:
            vtkImageThreshold VIT = vtkImageThreshold::NEW();
            VIT->SetInputConnection(VIS->GetOutputPort());
            VIT->ThresholdByLower(200);
            VIT->ThresholdByUpper(2000);
            VIT->Update();


            vtkContourFilter skinExtractor = vtkContourFilter::NEW();
            skinExtractor->GetOutput()->ReleaseDataFlagOff();
            skinExtractor->SetInputConnection(VIT->GetOutputPort());
            skinExtractor->SetValue(0, 500);
            skinExtractor->ComputeGradientsOn();
            skinExtractor->Update();
            //step3


            vtkTriangleFilter triangle = vtkTriangleFilter::NEW();
            triangle->SetInput(skinExtractor->GetOutput());
            triangle->PassVertsOff();
            triangle->PassLinesOff();

            vtkQuadricDecimation decimation = vtkQuadricDecimation::NEW();
            decimation->SetInput(triangle->GetOutput());

            vtkCleanPolyData clean = vtkCleanPolyData();
            clean->SetInput(triangle->GetOutput());


            vtkTriangleFilter triangle2 = vtkTriangleFilter::NEW();
            triangle2->SetInput(clean->GetOutput());
            triangle2->PassVertsOff();
            triangle2->PassLinesOff();

            vtkSTLWriter writer = vtkSTLWriter::NEW();
            writer->SetInput(triangle2->GetOutput());
            writer->SetFileName("test");
  writer->Write();

in managed vtk , there's no smart pointer 



David Doria-2 wrote:
> 
> On Fri, Dec 25, 2009 at 11:57 AM, Ali Habib <ali.mahmoud.habib at gmail.com>
> wrote:
>> Dear All.
>>
>> how to save vtkpolydata to be suitable for using in ANSYS
>>
>> I used vtkstlwriter as following:
>>
>>             vtkSTLWriter writer = vtkSTLWriter::NEW();
>>             writer->SetInput(triangle2.GetOutput());
>>             writer->SetFileName("test");
>>
>> but when load test file using vtk give the following warning :
>>
>> ENDFACET  is not a recognized  BEGIN command ,abbreviation, or macro this
>> command will be ignored
>>
>> Best regards
>>
> 
> A couple of things:
> 
> 1) you should use smart pointers:
> vtkSmartPointer<vtkSTLWriter> writer =
> vtkSmartPointer<vtkSTLWriter>::New();
> instead of
> vtkSTLWriter writer = vtkSTLWriter::NEW();  // I'm not sure NEW()
> works here? Shouldn't it be New()?
> 
> 2) what type is triangle2?
> 
> 3) I'm assuming you called writer->Write() ?
> 
> I'd suggest making the smallest possible example of using vtkSTLWriter
> (we need an example of this anyway :) ) and seeing if you get the same
> behavior. Do something very controlled like add a few points and
> vertices or a triangle or something and see what happens.
> 
> Thanks,
> 
> David
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 

-- 
View this message in context: http://old.nabble.com/best-way-to-save-vtkpolydata-for-ANSYS-tp26922317p26923921.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list