[ITK-users] itkSmoothingQuadEdgeMeshFilter Help!!

Arnaud Gelas arnaudgelas at gmail.com
Thu Aug 7 09:31:03 EDT 2014


Shouldn't it be D://temp.vtk ? Isn't it missing one '/' ?

Can you send this vtk file?

On Aug 7, 2014, at 3:23 PM, Mallikarjun K <mallikarjun49 at gmail.com> wrote:

> Hi Arnaud,
> 
> Kindly have a look in the below code ,the problem  is that even after QEMeshFilter output is saved as .stl file ,the program is still running for long time.I have observed in my tests that MeshFileReader seems to be the culprit. Any suggestions ?
> 
> /////
> #include<iostream>
> #include<string>
> 
> #include <vtkPolyDataWriter.h>
> #include <vtkPolyDataReader.h>
> #include <itkMeshFileWriter.h>
> #include <itkMeshFileReader.h>
> #include <itkMeshIOFactory.h>
> #include <itkMeshIOBase.h>
> #include <vtkTriangleFilter.h>
> #include <vtkCleanPolyData.h>
> #include "itkMesh.h"
> #include "itkQuadEdgeMesh.h"
> #include "itkQuadEdgeMeshTraits.h"
> #include "itkSmoothingQuadEdgeMeshFilter.h"
> #include "vtkSTLWriter.h"
> #include <vtkSmartPointer.h>
> 
> int main()
> {
> 	std::string Inputfilename="D:/temp.vtk";   //number of points of this mesh file is around 78K
> 
> 	typedef itk::QuadEdgeMeshTraits<double, 3,double, double, double,double > qetraits;	
> 	typedef itk::QuadEdgeMesh< vtkFloatingPointType, 3,qetraits > MeshType;
> 	
> 	itk::OnesMatrixCoefficients< MeshType > coeff0;
> 	typedef itk::SmoothingQuadEdgeMeshFilter< MeshType, MeshType >SmoothingQuadEdgeMeshFilter;
>     
> 	vtkSmartPointer<vtkPolyDataWriter> polyDatawriter=vtkSmartPointer<vtkPolyDataWriter>::New();
> 	vtkSmartPointer<vtkPolyDataReader> polyDatareader=vtkSmartPointer<vtkPolyDataReader>::New();
>    
>     SmoothingQuadEdgeMeshFilter::Pointer QEMeshSmoother = SmoothingQuadEdgeMeshFilter::New();
> 	
>    /* polyDatareader->SetFileName(Inputfilename.c_str() );
> 	polyDatareader->ReleaseDataFlagOn();
> 	polyDatareader->Update();*/
> 
> 	/*vtkSmartPointer<vtkTriangleFilter> triangleFilter =
>     vtkSmartPointer<vtkTriangleFilter>::New();
>     triangleFilter->SetInput(polyDatareader->GetOutput());
>     triangleFilter->Update();*/
>   
> 	//
> 	/* vtkSmartPointer<vtkCleanPolyData> clean = vtkSmartPointer<vtkCleanPolyData>::New();
> 	#if (VTK_MAJOR_VERSION < 6)
> 	 clean->SetInput(triangleFilter->GetOutput() );
> 	#else
>        clean->SetInputData(triangleFilter->GetOutput() );
> 	#endif
> 	
>     clean->ConvertPolysToLinesOff();
>     clean->ConvertLinesToPointsOff();
>     clean->Update();
> 
> 	std::string Inputfilename2="D:/cleaned.vtk";*/
> 
> 	////
> 	/*polyDatawriter->SetInput(clean->GetOutput());	
> 	polyDatawriter->SetFileName(Inputfilename2.c_str());
> 	polyDatawriter->ReleaseDataFlagOn();
> 	polyDatawriter->Write(); */ 
>   
> 	typedef itk::MeshFileReader<MeshType> MeshReaderType;
> 	MeshReaderType::Pointer Meshreader = MeshReaderType::New();
>        Meshreader->SetFileName(Inputfilename.c_str( ));
> 	Meshreader->Update();
> 
> 	/*MeshType::Pointer mesh =  Meshreader->GetOutput();
>          mesh->DisconnectPipeline();*/
> 	
> 
> 	QEMeshSmoother->SetInput(Meshreader->GetOutput()/*mesh*/ );
> 	QEMeshSmoother->SetNumberOfIterations(1 );
> 	QEMeshSmoother->SetRelaxationFactor( 0.5 );
> 	QEMeshSmoother->SetDelaunayConforming(true);
> 	QEMeshSmoother->SetCoefficientsMethod( &coeff0 );
> 
> 	QEMeshSmoother->ReleaseDataFlagOn();
> 
> 	QEMeshSmoother->Update();	
>     
> 	std::string Outputfilename="D:/tempOut.vtk";
> 
> 	typedef itk::MeshFileWriter<MeshType> MeshWriterType;
> 	MeshWriterType::Pointer Meshwriter = MeshWriterType::New();
>        Meshwriter->SetFileName(Outputfilename.c_str( ));
> 	Meshwriter->SetInput(QEMeshSmoother->GetOutput());
>        Meshwriter->Update();	
> 
> 	polyDatareader->SetFileName(Outputfilename.c_str() );
> 	polyDatareader->ReleaseDataFlagOn();
> 	polyDatareader->Update();
> 
> 	vtkSmartPointer<vtkSTLWriter> stlWriter=vtkSmartPointer<vtkSTLWriter>::New();
> 	
> 	stlWriter->SetInput( polyDatareader->GetOutput());
> 	stlWriter->SetFileName("D:/QEoutput.stl");
> 	stlWriter->SetFileTypeToASCII();
> 	stlWriter->Write();
> 	
> 	//Here it stops and taking long time 
> 
> 	return 0;
> 
> 	
> }
> ////
> 
> 
> 
> On Thu, Aug 7, 2014 at 3:39 PM, Mallikarjun K <mallikarjun49 at gmail.com> wrote:
> Hi Arnaud,
> 
> Thanks for your reply and valuable suggestions.
> 
> Number of points in my input mesh are 78928.In my pipeline I am already cleaning the polydata using vtkCleanPolyData filter.I will check the speed improvement and results with delaunay conforming turned OFF.
> 
> Thank you
> 
> 
> On Thu, Aug 7, 2014 at 2:22 PM, Arnaud Gelas <arnaudgelas at gmail.com> wrote:
> Hi Malik,
> 
> First of all, I would recommend using MeshFileReader instead of VTKPolyDataReader (I guess VTKPolyDataReader will be deprecated in near future?).
> 
> Regarding now the smoothing procedure in itself. This class definitively misses some documentation and I will be adding some in the next few days (mainly extracted from the corresponding insight journal).
> 
> At the end of each iteration, when the delaunay conforming flag is turned ON, the conformation is performed. So depending on the mesh configuration, mesh size and number of iterations, it can take ages…
> How large is your input mesh (number of points)?
> 
> You can also check results, by running first a smoothing without delaunay conforming, then apply a delaunay conforming on the output. Results won't be as nice, but you should get significant speed improvement.
> Another possibility is to first do a clean poly data in vtk, with a small threshold to remove small edges in the input meshes (which results in lots of edge flipping after smoothing).
> 
> HTH
> Arnaud
> 
> 
> On Aug 6, 2014, at 10:42 AM, Mallikarjun K <mallikarjun49 at gmail.com> wrote:
> 
>> Hi All,
>> 
>> Can anyone suggest me if anything wrong I am doing in this below pipeline ,Where I used itkVtkPolydataReader to convert vtk Surface polydata to Itk QuadedgeMesh. Execution loop is being hung up for sometime(4 to 5 mins in release mode) at itkVtkPolydataReader .
>> 
>> 
>> ////
>> 
>> typedef itk::QuadEdgeMeshTraits<double, 3,double, double, double,double > qetraits;
>> 	
>> typedef itk::QuadEdgeMesh< vtkFloatingPointType, 3,qetraits > MeshType;
>> 
>> itk::OnesMatrixCoefficients< MeshType > coeff0;
>> 
>> typedef itk::VTKPolyDataReader< MeshType >VTKPolyDataReaderType;
>> //typedef itk::VTKPolyDataWriter< MeshType >VTKPolyDataWriterType;
>> 
>> //VTKPolyDataWriterType::Pointer ItkToVtkWriter=VTKPolyDataWriterType::New();
>> VTKPolyDataReaderType::Pointer VtkToItkReader=VTKPolyDataReaderType::New();
>> 
>> VtkToItkReader->SetFileName("abc.vtk");
>> VtkToItkReader->Update();	
>> 
>> typedef itk::SmoothingQuadEdgeMeshFilter< MeshType, MeshType >
>> SmoothingQuadEdgeMeshFilter;
>> 
>>  SmoothingQuadEdgeMeshFilter::Pointer QEMeshSmoother =   SmoothingQuadEdgeMeshFilter::New();
>> 	
>> 
>> QEMeshSmoother->SetInput(VtkToItkReader->GetOutPut());
>> QEMeshSmoother->SetNumberOfIterations(5 );
>> QEMeshSmoother->SetRelaxationFactor( 0.5 );
>> QEMeshSmoother->SetDelaunayConforming(true );
>> QEMeshSmoother->SetCoefficientsMethod( &coeff0 );	
>> 	
>> QEMeshSmoother->Update();
>> 
>> ////
>> 
>> 
>> On Fri, Aug 1, 2014 at 4:36 PM, Mallikarjun K <mallikarjun49 at gmail.com> wrote:
>> Thanks Bill for your answer.
>> 
>> The reason I am using this pipeline is that SmoothingQEMeshFilter has an additional parameter for smoothing which is delaunay conforming which helps to optimize aspect ratio of triangles while smoothing and thus produces better output.Is there anything similar filter in the vtk pipeline.I used vtkWindowedSincPolydatafilter which is not giving the output as good as QEMeshSmoothing filter.
>> 
>> Thanks for your help 
>> 
>> 
>> On Thu, Jul 31, 2014 at 5:14 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> If you have it in vtk, I suggest using the vtk pipeline to smooth the data.
>> 
>> On Thu, Jul 31, 2014 at 1:35 AM, Mallikarjun K <mallikarjun49 at gmail.com> wrote:
>> > Hi Bill,
>> > Thanks for the replay.
>> >
>> > Yes,I built both ITK and my app with Release ,I forgot to mention it in the
>> > previous post.Actually the data set is the output of
>> > vtkDiscreteMarchingCubes algorithm(around 5MB) and need to smooth .I saved
>> > this marching cube's output as .vtk file and read it using
>> > itkVTKPolyDataReader and then I am giving this reader's output to
>> > itkSmoothingQuadEdgeMeshFilter's input.
>> >
>> > I checked the execution time of each step in the pipeline ,after
>> > SmothingQEMeshFilter has got it's input ,it is taking time to process the
>> > data.
>> >
>> > Thank you
>> >
>> >
>> >
>> > On Wed, Jul 30, 2014 at 9:29 PM, Bill Lorensen <bill.lorensen at gmail.com>
>> > wrote:
>> >>
>> >> First, make sure you are building ITK and your app with Release. A
>> >> Debug build can be 10-50 times slower.
>> >>
>> >>
>> >> On Wed, Jul 30, 2014 at 10:18 AM, Mallikarjun K <mallikarjun49 at gmail.com>
>> >> wrote:
>> >> > Hi All,
>> >> > I am using itkSmoothingQuadEdgeMeshFilter for Surface Mesh
>> >> > smoothing.This
>> >> > filter is giving good results what I expected but taking more execution
>> >> > time.can any one suggest me to reduce the execution time( multi
>> >> > threading
>> >> > or any parameters to add/remove )?
>> >> >
>> >> > Below is the code snippet
>> >> > ///////
>> >> > typedef itk::QuadEdgeMeshTraits<double, 3,double, double, double,double
>> >> > >
>> >> > qetraits;
>> >> > typedef itk::QuadEdgeMesh< vtkFloatingPointType, 3,qetraits > MeshType;
>> >> >
>> >> > //typedef itk::QuadEdgeMesh< vtkFloatingPointType, 3 > MeshType;
>> >> >
>> >> > itk::OnesMatrixCoefficients< MeshType > coeff0;
>> >> >
>> >> > typedef itk::SmoothingQuadEdgeMeshFilter< MeshType, MeshType >
>> >> > SmoothingQuadEdgeMeshFilter;
>> >> >
>> >> >     SmoothingQuadEdgeMeshFilter::Pointer QEMeshSmoother =
>> >> > SmoothingQuadEdgeMeshFilter::New();
>> >> >
>> >> > QEMeshSmoother->SetInput("abc.vtk");
>> >> > QEMeshSmoother->SetNumberOfIterations(5 );
>> >> > QEMeshSmoother->SetRelaxationFactor( 0.5 );
>> >> > QEMeshSmoother->SetDelaunayConforming(true );
>> >> > QEMeshSmoother->SetCoefficientsMethod( &coeff0 );
>> >> > QEMeshSmoother->Update();
>> >> > ////
>> >> >
>> >> > --
>> >> > Regards:
>> >> > Mallik
>> >> >
>> >> >
>> >> > _____________________________________
>> >> > Powered by www.kitware.com
>> >> >
>> >> > Visit other Kitware open-source projects at
>> >> > http://www.kitware.com/opensource/opensource.html
>> >> >
>> >> > Kitware offers ITK Training Courses, for more information visit:
>> >> > http://www.kitware.com/products/protraining.php
>> >> >
>> >> > Please keep messages on-topic and check the ITK FAQ at:
>> >> > http://www.itk.org/Wiki/ITK_FAQ
>> >> >
>> >> > Follow this link to subscribe/unsubscribe:
>> >> > http://public.kitware.com/mailman/listinfo/insight-users
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Unpaid intern in BillsBasement at noware dot com
>> >
>> >
>> >
>> >
>> > --
>> > Regards:
>> > Mallik
>> >
>> 
>> 
>> 
>> --
>> Unpaid intern in BillsBasement at noware dot com
>> 
>> 
>> 
>> -- 
>> Regards:
>> Mallik
>> 
>> 
>> 
>> 
>> -- 
>> Regards:
>> Mallik
>> 
>> _____________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>> 
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users
> 
> 
> 
> 
> -- 
> Regards:
> Mallik
> 
> 
> 
> 
> -- 
> Regards:
> Mallik
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20140807/2c34f56a/attachment.html>


More information about the Insight-users mailing list