Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] get vertices, tetrahedrons and neighbours from C3T3 Object

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] get vertices, tetrahedrons and neighbours from C3T3 Object


Chronological Thread 
  • From: Dongming Yan <>
  • To:
  • Subject: Re: [cgal-discuss] get vertices, tetrahedrons and neighbours from C3T3 Object
  • Date: Fri, 27 Aug 2010 12:52:32 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=T23Cop9TqTN9gXx8yXTg8vOexxAPkPhxhzZFyuVWvZ2fYtziiIpVzSsz6MYlwsMjPb w3MNdxDMxmeMyaYUIBn8VISAsnJeEs+3F3b+vBdGAWLTpf9110W8Js2fVT1sSgnOEO4m SOD4zBPTRxw1Hf51Wdci1aK0dEJTv1wy/V/mE=

Hi, Alex,
 
Following is a piece of code I convert c3t3 to a graph structure. Hope it will help with your problem
 
best
 
Dongming
 
 class C3t3ToCGraph : public CGraphMutator {
 public:
  C3t3ToCGraph(C3t3& c3t3, CGraph* target=nil) : c3t3_(c3t3), CGraphMutator(target) {
   cgal_to_graphite() ;
  }
 protected:
  void cgal_to_graphite() {
   target()->clear() ;
   if(target()->size_of_meta_cells() == 0) {
    CGraphBuilder builder ;
    builder.set_target(target()) ;
    builder.begin_volume() ;
    builder.build_meta_tetrahedron() ;
    builder.end_volume() ;
   }
        
   // Create vertices
   std::map<Tr::Vertex_handle, CGraph::Vertex*> vertices ;
   Tr& tr = c3t3_.triangulation() ;
   for(Tr::Vertex_iterator vit=tr.vertices_begin(); vit!=tr.vertices_end(); ++vit) {
    vertices[vit] = new_vertex(Point3d(vit->point().x(), vit->point().y(), vit->point().z())) ;
   }
   // Create cells
   std::map<Tr::Cell_handle, CGraph::Cell*> cells ;
   CGraph::MetaCell* meta_tet = target()->meta_cell(0) ;
   for(C3t3::Cell_iterator cit=c3t3_.cells_begin(); cit!=c3t3_.cells_end(); ++cit) {
    CGraph::Cell* c = new_cell(meta_tet) ;
    for(int j=0; j<4; ++j) {
     set_cell_vertex(c, j, vertices[cit->vertex(j)]) ;
    }
    cells[cit] = c ;
   }
   for(C3t3::Cell_iterator cit=c3t3_.cells_begin(); cit!=c3t3_.cells_end(); ++cit) {
    for(int j=0; j<4; ++j) {
     Tr::Cell_handle cj = cit->neighbor(j) ; // j-th neighbor of cells[i]
     if(c3t3_.is_in_complex(cj)) {
      set_cell_adjacent(
       cells[cit],
       j,
       cells[cj]
      ) ;
     }
    }
   } 
  }
 protected:
  C3t3& c3t3_ ;
 } ;

On Fri, Aug 27, 2010 at 12:03 PM, Sebastien Loriot (GeometryFactory) <sloriot.ml@gmail.com> wrote:
IBTAlex wrote:
Dear mailing list users,
i am still trying to get into the cgal details.
To use CGAL here at university I am writing a program that does Mesh
Generation From a Segmented 3D Image and then should save the mesh in the
format we use here.
To do this I need to access the "data" of the mesh, speaking of vertices,
tetrahedrons, neighbours (of the tetrahedrons) and material keys.

I supposed to find the information in the class C3T3 (<CGAL/Mesh_complex_3_in_triangulation_3.h>) but could not find any
getfunction that would help me (except from .number_of_vertices()) - or
maybe I am just blind..?

In the end I need to read all vertice-coordinates into a hash table and then
build another htable with tetrahedrons (existing of 4 point indices and 4
neighbours).

Could anybody help me and tell me where to find any functions that can give
me the information i need?

I appreciate any help

Alex

From here:

http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Mesh_3_ref/Concept_MeshComplex_3InTriangulation_3.html#Cross_link_anchor_1476

you will see that C3T3 has a member function triangulation that gives you the regular triangulation used internally and also functions
is_in_complex to indicates if a simplex of the triangulation is in
the complex.

Doc of regular triangulation is here:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Triangulation_3_ref/Class_Regular_triangulation_3.html#Cross_link_anchor_1313
and here for the base class:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Triangulation_3_ref/Class_Triangulation_3.html#Cross_link_anchor_1310
where you can find:
finite_vertices_begin(),finite_vertices_end(),finite_edges_begin() ...

Description of the representation for the triangulation simplices is
given here:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/TriangulationDS_3_ref/Concept_TriangulationDataStructure_3.html#Cross_link_anchor_1333

S.


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss





Archive powered by MHonArc 2.6.16.

Top of Page