<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Rodolfo,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">faces are one type of cells for a mesh. For examples how to access them, you can take a look at:</div><div class="gmail_default"><font face="verdana, sans-serif"><a href="https://itk.org/Doxygen/html/Examples_2DataRepresentation_2Mesh_2MeshCellsIteration_8cxx-example.html" target="_blank">https://itk.org/Doxygen/html/<wbr>Examples_2DataRepresentation_<wbr>2Mesh_2MeshCellsIteration_<wbr>8cxx-example.html</a></font><br></div><div class="gmail_default"><a href="https://itk.org/ITKExamples/src/Core/QuadEdgeMesh/CutMesh/Documentation.html" target="_blank">https://itk.org/ITKExamples/<wbr>src/Core/QuadEdgeMesh/CutMesh/<wbr>Documentation.html</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">Regards,</div><div class="gmail_default">Dženan</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 13, 2016 at 5:54 AM, Oliveira, Rodolfo <span dir="ltr"><<a href="mailto:r.oliveira16@imperial.ac.uk" target="_blank">r.oliveira16@imperial.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi Matt,</p>
<p><br>
</p>
<p>It did helped a lot! </p>
<p><br>
</p>
<p>I modified the example to display what's been written to file in terms of what I need but I'm struggling to access the edges of a particular face. For now all I can do is to iterate over the points and cell's ids. There are some examples to write data to
cells but I either don't find it that useful for my case or completely understood it. </p>
<p><br>
</p>
<p>Please find my code below:</p>
<p><br>
</p>
<p><br>
</p>
<p></p>
<div>
<div>#include "itkQuadEdgeMesh.h"</div>
<div>#include "itkMeshFileWriter.h"</div>
<div>#include "itkMeshFileReader.h"</div>
<div><br>
</div>
<div>int main(int argc, char* argv[])</div>
<div>{</div>
<div> if (argc != 2)</div>
<div> {</div>
<div> std::cerr << "Usage: " << std::endl;</div>
<div> std::cerr << argv[0];</div>
<div> std::cerr << " <OutputFileName>";</div>
<div> std::cerr << std::endl;</div>
<div> return EXIT_FAILURE;</div>
<div> }</div>
<div><br>
</div>
<div> const char * outputFileName = argv[1];</div>
<div><br>
</div>
<div> //</div>
<div> // Definitions</div>
<div> //</div>
<div> const unsigned int Dimension = 3;</div>
<div><br>
</div>
<div> typedef double CoordType;</div>
<div> typedef itk::QuadEdgeMesh< CoordType, Dimension > MeshType;</div>
<div><br>
</div>
<div> MeshType::Pointer mesh = MeshType::New();</div>
<div><br>
</div>
<div> typedef MeshType::PointsContainer PointsContainer;</div>
<div> typedef MeshType::PointsContainerPoint<wbr>er PointsContainerPointer;</div>
<div><br>
</div>
<div> //</div>
<div> // Create points</div>
<div> //</div>
<div> PointsContainerPointer points = PointsContainer::New();</div>
<div> points->Reserve(9);</div>
<div><br>
</div>
<div> typedef MeshType::PointType PointType;</div>
<div> PointType p;</div>
<div> p[2] = 0.;</div>
<div><br>
</div>
<div> typedef MeshType::PointIdentifier PointIdentifier;</div>
<div> PointIdentifier k = 0;</div>
<div><br>
</div>
<div> for (int i = 0; i < 3; i++)</div>
<div> {</div>
<div> p[0] = static_cast< CoordType >(i);</div>
<div><br>
</div>
<div> for (int j = 0; j < 3; j++)</div>
<div> {</div>
<div> p[1] = static_cast< CoordType >(j);</div>
<div> points->SetElement(k, p);</div>
<div> k++;</div>
<div> }</div>
<div> }</div>
<div><br>
</div>
<div> mesh->SetPoints(points);</div>
<div><br>
</div>
<div> //</div>
<div> // Create faces</div>
<div> //</div>
<div> k = 0;</div>
<div><br>
</div>
<div> for (int i = 0; i < 2; i++)</div>
<div> {</div>
<div> for (int j = 0; j < 2; j++)</div>
<div> {</div>
<div> mesh->AddFaceTriangle(k, k + 1, k + 4);</div>
<div> mesh->AddFaceTriangle(k, k + 4, k + 3);</div>
<div> k++;</div>
<div> }</div>
<div> k++;</div>
<div> }</div>
<div> </div>
<div> //</div>
<div> // Write mesh to file</div>
<div> //</div>
<div> typedef itk::MeshFileWriter< MeshType > WriterType;</div>
<div> WriterType::Pointer writer = WriterType::New();</div>
<div> writer->SetFileName(outputFile<wbr>Name);</div>
<div> writer->SetInput(mesh);</div>
<div> try</div>
<div> {</div>
<div> writer->Update();</div>
<div> }</div>
<div> catch (itk::ExceptionObject & error)</div>
<div> {</div>
<div> std::cerr << "Error: " << error << std::endl;</div>
<div> return EXIT_FAILURE;</div>
<div> }</div>
<div><br>
</div>
<div> //</div>
<div> // Read mesh to file</div>
<div> //</div>
<div> typedef itk::MeshFileReader< MeshType > ReaderType;</div>
<div> ReaderType::Pointer reader = ReaderType::New();</div>
<div> reader->SetFileName(outputFile<wbr>Name);</div>
<div> try</div>
<div> {</div>
<div> reader->Update();</div>
<div> }</div>
<div> catch (itk::ExceptionObject & error)</div>
<div> {</div>
<div> std::cerr << "Error: " << error << std::endl;</div>
<div> return EXIT_FAILURE;</div>
<div> }</div>
<div><br>
</div>
<div> mesh = reader->GetOutput();</div>
<div><br>
</div>
<div> //</div>
<div> // Print data</div>
<div> //</div>
<div> typedef MeshType::PointsContainer::Con<wbr>stIterator PointIterator;</div>
<div> PointIterator pointIterator = mesh->GetPoints()->Begin();</div>
<div> PointIterator pointEnd = mesh->GetPoints()->End();</div>
<div><br>
</div>
<div> MeshType::PointIdentifier pid;</div>
<div> </div>
<div> while (pointIterator != pointEnd)</div>
<div> {</div>
<div> p = pointIterator.Value();</div>
<div> pid = pointIterator.Index();</div>
<div> </div>
<div> std::cout << pid << ": "</div>
<div> << p[0] << " "</div>
<div> << p[1] << " "</div>
<div> << p[2] << std::endl;</div>
<div><br>
</div>
<div> ++pointIterator;</div>
<div> }</div>
<div> </div>
<div> //</div>
<div> // Print edges</div>
<div> //</div>
<div> typedef MeshType::CellsContainer::Cons<wbr>tIterator CellIterator;</div>
<div> CellIterator cellIterator = mesh->GetCells()->Begin();</div>
<div> CellIterator cellEnd = mesh->GetCells()->End();</div>
<div> </div>
<div> MeshType::CellType *c;</div>
<div> MeshType::CellIdentifier cid;</div>
<div><br>
</div>
<div> while (cellIterator != cellEnd)</div>
<div> {</div>
<div> c = cellIterator.Value();</div>
<div> cid = cellIterator.Index();</div>
<div><br>
</div>
<div> std::cout << cid << ": "</div>
<div> // The face's edge list?</div>
<div> << std::endl;</div>
<div><br>
</div>
<div> ++cellIterator;</div>
<div> }</div>
<div> </div>
<div> return EXIT_SUCCESS;</div>
<div>}</div>
</div>
<p></p>
<div></div>
<div><br>
</div>
<p></p>
<p><br>
</p>
<p>Thanks again!</p>
<p><br>
</p>
<p>Rodolfo</p>
</div>
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matt McCormick <<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>><br>
<b>Sent:</b> 07 September 2016 21:30:18<br>
<b>To:</b> Oliveira, Rodolfo<br>
<b>Cc:</b> <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<b>Subject:</b> Re: [ITK] Get the list of Points, Edges and Cells of a Mesh</font>
<div> </div>
</div>
</div><div><div>
<font size="2"><span style="font-size:10pt">
<div>Hi Rodolfo,<br>
<br>
Here is an example of how to manually create a mesh:<br>
<br>
<a href="https://itk.org/ITKExamples/src/Core/QuadEdgeMesh/CreateTriangularQuadEdgeMesh/Documentation.html" target="_blank">
https://itk.org/ITKExamples/sr<wbr>c/Core/QuadEdgeMesh/CreateTria<wbr>ngularQuadEdgeMesh/Documentati<wbr>on.html</a><br>
<br>
HTH,<br>
Matt<br>
<br>
On Wed, Sep 7, 2016 at 12:36 PM, Oliveira, Rodolfo<br>
<<a href="mailto:r.oliveira16@imperial.ac.uk" target="_blank">r.oliveira16@imperial.ac.uk</a>> wrote:<br>
> Hi,<br>
><br>
><br>
> I need to get the list of points, edges and cells of an itk mesh to file. I<br>
> have to write the points, the edges as a reference of two points' indexes<br>
> and the faces as three edges' indexes.<br>
><br>
><br>
> So far I only managed to get the points from a mesh, using a point iterator<br>
> and writing its value and indexes. I still haven't figure it out how to get<br>
> the linking indexes of the edges and faces.<br>
><br>
><br>
> For illustration purposes, say I have a mesh containing a single triangle,<br>
> defined this:<br>
><br>
><br>
> 0,1 - 2 - 1,1<br>
><br>
> | /<br>
><br>
> | /<br>
><br>
> | 1 /<br>
><br>
> 1 3<br>
><br>
> | /<br>
><br>
> | /<br>
><br>
> | /<br>
><br>
> 0,0<br>
><br>
><br>
> The structure would be like this:<br>
><br>
> Points:<br>
> 1: 0,0<br>
> 2: 0,1<br>
> 3: 1,1<br>
><br>
> Edges:<br>
> 1: 1 2 (Point 1 to Point 2)<br>
> 2: 2 3<br>
> 3: 3 1<br>
><br>
> Faces:<br>
> 1: 1 2 3 (Edge 1, to Edge 2 and Edge 3)<br>
><br>
> This is a rather simplistic example, but there is no difference for the case<br>
> of more than one triangle. But they might share some of the same indexes<br>
> when neighbours.<br>
><br>
> Any help would be much appreciated!<br>
><br>
><br>
> Thanks,<br>
><br>
><br>
> Rodolfo<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Community mailing list<br>
> <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
> <a href="http://public.kitware.com/mailman/listinfo/community" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/community</a><br>
><br>
</div>
</span></font>
</div></div></div>
<br>______________________________<wbr>_________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/community</a><br>
<br></blockquote></div><br></div></div>