[Insight-users] [Segfault] itk::NormalQuadEdgeMeshFilter and itk::WarpMeshFilter

Alexandre GOUAILLARD agouaillard at gmail.com
Thu Dec 6 12:33:19 EST 2012


Thanks oscar.

Would you have a complete example (a main) in a file that I could compile,
run and debug here?

regards,

alex.



On Fri, Dec 7, 2012 at 12:21 AM, Oscar Esteban <oesteban at die.upm.es> wrote:

> Dear Alexandre,
>
> Thank you so much.
>
> I didn't realize about the existence of the itkQuadEdgeMeshToQuadEdgeMeshFilter,
> so now I'm trying to use it. Currently, the segfault has moved to a
> different place (the faces iterator).
>
> After the itkQuadEdgeMeshToQuadEdgeMeshFilter (I defined a typedef so it
> will be ContourCopyType), the QEMesh has uninitialized the members
> m_NumberOfFaces and m_NumberOfEdges.
>
> This is my code:
>
> // Read an vtk mesh with VTKPolyDataReader. This is the "prior" I use
> inside this method:
>
> template< typename TReferenceImageType, typename TCoordRepType >
>> void
>> LevelSetsBase<TReferenceImageType, TCoordRepType>
>> ::SetShapePrior( typename LevelSetsBase<TReferenceImageType,
>> TCoordRepType>::ContourDeformationType* prior ) {
>> this->m_ShapePrior = prior;
>>         this->m_CurrentContourPosition = ContourDeformationType::New();
>> this->m_ContourCopier = ContourCopyType::New();
>> m_ContourCopier->SetInput( this->m_ShapePrior );
>>  this->m_ContourCopier->Update();
>> this->m_CurrentContourPosition = m_ContourCopier->GetOutput();
>> }
>
>
> When I compare m_ShapePrior and m_CurrentContourPosition after the
> GetOutput(), I see that m_CurrentContourPosition does not have the
> variables mentioned before.
>
> After that, the normals filter comes in, and I get the segfault.
>
> Before, I was manually copying the meshes like this:
>
>  typename ContourDeformationType::PointsContainerConstIterator u_it =
>> prior->GetPoints()->Begin();
>>     typename ContourDeformationType::PointsContainerConstIterator u_end =
>> prior->GetPoints()->End();
>>  VectorType zero = itk::NumericTraits<VectorType>::Zero;
>> PointType p, newP;
>> while( u_it != u_end ) {
>>  p = u_it.Value();
>> newP.SetPoint( p );
>> newP.SetEdge( p.GetEdge() );
>>  this->m_CurrentContourPosition->SetPointData(
>> this->m_CurrentContourPosition->AddPoint( newP ), zero);
>>  ++u_it;
>> }
>> typename ContourDeformationType::CellsContainerConstIterator c_it  =
>> prior->GetCells()->Begin();
>>  typename ContourDeformationType::CellsContainerConstIterator c_end =
>> prior->GetCells()->End();
>> size_t i = 0;
>>  while( c_it!=c_end ) {
>> typename ContourDeformationType::CellType::CellAutoPointer cellCopy;
>>  c_it.Value()->MakeCopy( cellCopy );
>> this->m_CurrentContourPosition->SetCell( i++ ,cellCopy );
>>  ++c_it;
>> }
>
>
> Thanks in advance
>
> Cheers,
> Oscar Esteban
>
> *______________________________________*
> *Oscar Esteban*
> PhD Student / Researcher
>
> Biomedical Image Technologies (BIT), UPM
> ETSI Telecomunicación Lab. C203, Av. Complutense s/n - E-28040 Madrid
> (Spain)
> +34 915 495 700 ext.4234
>
> Signal Processing Laboratory (LTS5), EPFL-STI-IEL-LTS5
> ELD 224 (Bâtiment ELD), Station 11, CH-1015 Lausanne, Switzerland
>
>
>
> On 5 December 2012 21:53, Alexandre GOUAILLARD <agouaillard at gmail.com>wrote:
>
>> dear oscar,
>>
>> could you share a simple code that reproduce the problem?
>>
>> There is no unsafe copying of QEMesh, itkQuadEdgeMeshToQuadEdgeMeshFilter
>> always hard copy (actually reconstructs the structure) the entire mesh.
>> This is because the QuadEdges have no container and other technical
>> details. This is one reason why the copying part is relatively slow today.
>> Points are safe to shallow copy, cell could be made safe to shallow copy,
>> but edge cells need to be added over again. This is what the filter does
>> when copying.
>>
>> regards,
>>
>> alex.
>>
>>
>>
>>
>>
>> On Thu, Dec 6, 2012 at 9:32 AM, Oscar Esteban <oesteban at die.upm.es>wrote:
>>
>>> Hi all,
>>>
>>> I'm trying to compute the Normals of a QuadEdgeMesh after warping it
>>> with itk::WarpMeshFilter and a displacement field.
>>>
>>> I save to vtk files the result and the points seem to be correctly
>>> displaced, but when computing the normals, I get a segmentation fault in
>>> line 302 of itkQuadEdge.h.
>>>
>>> I think that the output Mesh after the WarpMeshFilter lacks of some
>>> properties needed by the normals filter.
>>>
>>> In order to solve this, I could copy this properties from the input mesh
>>> to the output. This are my questions:
>>> - What is missing after the WarpMeshFilter?
>>> - How to safely clone (deep-copy) a QuadEdgeMesh? (I have this problem
>>> in some other parts of my code).
>>>
>>> Thank you so much in advance.
>>>
>>> Best,
>>> Oscar Esteban
>>>
>>> *______________________________________*
>>> *Oscar Esteban*
>>> PhD Student / Researcher
>>>
>>> Biomedical Image Technologies (BIT), UPM
>>> ETSI Telecomunicación Lab. C203, Av. Complutense s/n - E-28040 Madrid
>>> (Spain)
>>> +34 915 495 700 ext.4234
>>>
>>> Signal Processing Laboratory (LTS5), EPFL-STI-IEL-LTS5
>>> ELD 224 (Bâtiment ELD), Station 11, CH-1015 Lausanne, Switzerland
>>>
>>>
>>> _____________________________________
>>> 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://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121207/cf2da6d2/attachment.htm>


More information about the Insight-users mailing list