<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>Hi Dan,</DIV>
<DIV>Thank you for your help. the code is working I've just added pointer incrementation statment in both loops.</DIV>
<DIV>Regards</DIV>
<DIV>Marion<BR><BR>--- En date de : <B>Lun 8.6.09, Dan Mueller <I><dan.muel@gmail.com></I></B> a écrit :<BR></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid"><BR>De: Dan Mueller <dan.muel@gmail.com><BR>Objet: Re: [Insight-users] how to copy a mesh? newbie<BR>À: marion.rizet@yahoo.fr<BR>Cc: insight-users@itk.org<BR>Date: Lundi 8 Juin 2009, 19h51<BR><BR>
<DIV class=plainMail>Hi Marion,<BR><BR> Welcome to ITK!<BR><BR>One way to copy your mesh is to iterate and copy the points/cells<BR><BR>#include "itkCellInterface.h"<BR>#include "itkDefaultStaticMeshTraits.h"<BR>#include "itkMesh.h"<BR><BR>int main( int argc, char *argv[] )<BR>{<BR> typedef itk::Mesh < float,3,itk::DefaultStaticMeshTraits<<BR>float,3,3,float > > MeshType;<BR> MeshType::Pointer mesh = MeshType::New(); // You need to<BR>initialise the mesh to copy<BR> MeshType::Pointer copy = MeshType::New(); // This is the copied mesh<BR> MeshType::PointsContainerPointer points = mesh->GetPoints( );<BR> MeshType::PointsContainerConstIterator it = points->Begin();<BR> MeshType::PointsContainerConstIterator itEnd = points->End();<BR> unsigned int i = 0;<BR> while ( it != itEnd )<BR> {<BR>
MeshType::PointType point = it.Value();<BR> copy->SetPoint( i++, point );<BR> }<BR><BR> i = 0;<BR> MeshType::CellsContainerPointer cells = mesh->GetCells( );<BR> MeshType::CellsContainerConstIterator itCells = cells->Begin();<BR> MeshType::CellsContainerConstIterator itCellsEnd = cells->End();<BR> while ( itCells != itCellsEnd )<BR> {<BR> MeshType::CellType::CellAutoPointer cellCopy;<BR> itCells.Value()->MakeCopy( cellCopy );<BR> copy->SetCell( i++, cellCopy );<BR> }<BR>}<BR><BR>Disclaimer: I haven't fully tested the above code, but it should get<BR>you started.<BR><BR>Hope this helps.<BR><BR>Cheers, Dan<BR><BR><BR>2009/6/8 <<A href="http://fr.mc246.mail.yahoo.com/mc/compose?to=marion.rizet@yahoo.fr"
ymailto="mailto:marion.rizet@yahoo.fr">marion.rizet@yahoo.fr</A>>:<BR>> Hi all,<BR>><BR>> I would like to create a new mesh from an existing mesh(which is an input to<BR>> my code). The new mesh that I want to create should has the same data except<BR>> the values (the points value) which are different. How can I do that? Is<BR>> there way or method to copy a mesh (points , cells,..) ?. please could you<BR>> give me help, I’m a bit lost with itk as I’m new.<BR>><BR>><BR>><BR>> Thank you<BR>><BR>> Marion<BR>><BR>> _____________________________________<BR>> Powered by www.kitware.com<BR>><BR>> Visit other Kitware open-source projects at<BR>> <A href="http://www.kitware.com/opensource/opensource.html" target=_blank>http://www.kitware.com/opensource/opensource.html</A><BR>><BR>> Please keep messages on-topic and check the ITK FAQ at:<BR>> <A href="http://www.itk.org/Wiki/ITK_FAQ"
target=_blank>http://www.itk.org/Wiki/ITK_FAQ</A><BR>><BR>> Follow this link to subscribe/unsubscribe:<BR>> <A href="http://www.itk.org/mailman/listinfo/insight-users" target=_blank>http://www.itk.org/mailman/listinfo/insight-users</A><BR>><BR>><BR></DIV></BLOCKQUOTE></td></tr></table><br>