<div>Hi ITK users, </div><div>I am having trouble with QuadricDecimationQuadEdgeMeshFilter</div><div>class. Here is the code snippet I used. The program compiles </div><div>but crashes while running </div><div><br></div>
<div> typedef itk::QuadEdgeMesh< double, 3 > InputQuadMeshType;</div><div> typedef itk::Vector< double, 3 > QuadVectorType;</div><div> </div><div> //Binary image to mesh</div>
<div> typedef itk::BinaryMask3DMeshSource< OIT, InputQuadMeshType > MeshSourceType;</div><div> MeshSourceType::Pointer meshSource = MeshSourceType::New();</div><div> meshSource->SetObjectValue( 255 );</div><div>
meshSource->SetInput( thresholdFilter->GetOutput() );</div><div> meshSource->Update();</div><div> InputQuadMeshType::Pointer mesh = meshSource->GetOutput( );</div><div> std::cout << "Initially #faces: " << mesh->GetNumberOfFaces() << std::endl;</div>
<div> </div><div> //Mesh decimate</div><div> typedef itk::NumberOfFacesCriterion< InputQuadMeshType > CriterionType;</div><div> typedef itk::QuadricDecimationQuadEdgeMeshFilter</div><div> <InputQuadMeshType, InputQuadMeshType, CriterionType > DecimationType;</div>
<div><br></div><div> long N=1000;</div><div> CriterionType::Pointer criterion = CriterionType::New();</div><div> criterion->SetTopologicalChange( true );</div><div> criterion->SetNumberOfElements( N );</div><div>
<br></div><div> DecimationType::Pointer decimate = DecimationType::New();</div><div> decimate->SetInput( mesh );</div><div> decimate->SetCriterion( criterion );</div><div> decimate->Update();</div><div> InputQuadMeshType::Pointer decimatedMesh = decimate->GetOutput();</div>
<div> std::cout << "Decimation # of faces: " << decimatedMesh->GetNumberOfFaces() << std::endl;</div><div><br></div><div>when I do N = mesh->GetNumberOfFaces(); </div><div>the code just works fine. </div>
<div><br></div><div>Here is the output</div><div><br></div><div><div>Initially #faces: 360790</div></div><div><div>*** glibc detected *** ./CBSRelease: double free or corruption (out): 0x00007fc0e4000020 ***</div><div>======= Backtrace: =========</div>
<div>/lib/x86_64-linux-gnu/libc.so.6(+0x78a96)[0x7fc14b72fa96]</div><div>/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7fc14b733d7c]</div><div>./CBSRelease(_ZN10vnl_matrixIfE7destroyEv+0x33)[0x86ad83]</div><div>./CBSRelease(_ZN3itk42QuadEdgeMeshDecimationQuadricElementHelperINS_17QuadEdgeMeshPointIfLj3ENS_19GeometricalQuadEdgeImmbbLb1EEEEEED1Ev+0x1c)[0x6e83c8]</div>
<div>./CBSRelease(_ZNSt4pairIKmN3itk42QuadEdgeMeshDecimationQuadricElementHelperINS1_17QuadEdgeMeshPointIfLj3ENS1_19GeometricalQuadEdgeImmbbLb1EEEEEEEED1Ev+0x1c)[0x6e4ae4]</div><div>./CBSRelease(_ZN9__gnu_cxx13new_allocatorISt4pairIKmN3itk42QuadEdgeMeshDecimationQuadricElementHelperINS3_17QuadEdgeMeshPointIfLj3ENS3_19GeometricalQuadEdgeImmbbLb1EEEEEEEEE7destroyEPSA_+0x1c)[0x6e4b02]</div>
<div>./CBSRelease(_ZNSt8_Rb_treeImSt4pairIKmN3itk42QuadEdgeMeshDecimationQuadricElementHelperINS2_17QuadEdgeMeshPointIfLj3ENS2_19GeometricalQuadEdgeImmbbLb1EEEEEEEESt10_Select1stIS9_ESt4lessImESaIS9_EE15_M_destroy_nodeEPSt13_Rb_tree_nodeIS9_E+0x46)[0x6e11dc]</div>
<div>./CBSRelease(_ZNSt8_Rb_treeImSt4pairIKmN3itk42QuadEdgeMeshDecimationQuadricElementHelperINS2_17QuadEdgeMeshPointIfLj3ENS2_19GeometricalQuadEdgeImmbbLb1EEEEEEEESt10_Select1stIS9_ESt4lessImESaIS9_EE12_M_erase_auxESt23_Rb_tree_const_iteratorIS9_E+0x3e)[0x768840]</div>
<div>./CBSRelease(_ZNSt8_Rb_treeImSt4pairIKmN3itk42QuadEdgeMeshDecimationQuadricElementHelperINS2_17QuadEdgeMeshPointIfLj3ENS2_19GeometricalQuadEdgeImmbbLb1EEEEEEEESt10_Select1stIS9_ESt4lessImESaIS9_EE5eraseESt17_Rb_tree_iteratorIS9_E+0x36)[0x74d20e]</div>
<div>./CBSRelease(_ZNSt3mapImN3itk42QuadEdgeMeshDecimationQuadricElementHelperINS0_17QuadEdgeMeshPointIfLj3ENS0_19GeometricalQuadEdgeImmbbLb1EEEEEEESt4lessImESaISt4pairIKmS6_EEE5eraseESt17_Rb_tree_iteratorISB_E+0x23)[0x73140f]</div>
<div>./CBSRelease(_ZN3itk35QuadricDecimationQuadEdgeMeshFilterINS_12QuadEdgeMeshIdLj3ENS_18QuadEdgeMeshTraitsIdLj3EbbffEEEES4_NS_22NumberOfFacesCriterionIS4_mdNS_30MinPriorityQueueElementWrapperIPNS_19GeometricalQuadEdgeImmbbLb1EEESt4pairIbdEmEEEEE11DeletePointERKmSG_+0x99)[0x6f9ee9]</div>
<div>./CBSRelease(_ZN3itk32EdgeDecimationQuadEdgeMeshFilterINS_12QuadEdgeMeshIdLj3ENS_18QuadEdgeMeshTraitsIdLj3EbbffEEEES4_NS_22NumberOfFacesCriterionIS4_mdNS_30MinPriorityQueueElementWrapperIPNS_19GeometricalQuadEdgeImmbbLb1EEESt4pairIbdEmEEEEE37ProcessWithoutAnyTopologicalGuaranteeEv+0x42c)[0x6f9792]</div>
<div>./CBSRelease(_ZN3itk32EdgeDecimationQuadEdgeMeshFilterINS_12QuadEdgeMeshIdLj3ENS_18QuadEdgeMeshTraitsIdLj3EbbffEEEES4_NS_22NumberOfFacesCriterionIS4_mdNS_30MinPriorityQueueElementWrapperIPNS_19GeometricalQuadEdgeImmbbLb1EEESt4pairIbdEmEEEEE31ProcessWithTopologicalGuaranteeEv+0x3b)[0x6f9ad7]</div>
<div>./CBSRelease(_ZN3itk28DecimationQuadEdgeMeshFilterINS_12QuadEdgeMeshIdLj3ENS_18QuadEdgeMeshTraitsIdLj3EbbffEEEES4_NS_22NumberOfFacesCriterionIS4_mdNS_30MinPriorityQueueElementWrapperIPNS_19GeometricalQuadEdgeImmbbLb1EEESt4pairIbdEmEEEEE12GenerateDataEv+0x98)[0x6f87be]</div>
<div>./CBSRelease(_ZN3itk13ProcessObject16UpdateOutputDataEPNS_10DataObjectE+0xc5)[0x8b6eb5]</div><div>./CBSRelease(_ZN3itk13ProcessObject6UpdateEv+0x116)[0x8b4116]</div><div>./CBSRelease(main+0xf8a)[0x6be89e]</div><div>/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7fc14b6d830d]</div>
<div>./CBSRelease[0x6bd861]</div></div><div><br></div><div><br></div><div>Cagatay</div><div><br></div>