Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Re: Convert C3t3 to Polyhedron

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Re: Convert C3t3 to Polyhedron


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Re: Convert C3t3 to Polyhedron
  • Date: Sun, 25 Mar 2012 15:40:35 +0200

Try with the attached file.

Sebastien.


On 03/24/2012 11:38 AM, Zohar wrote:
1.
http://cgal-discuss.949826.n4.nabble.com/Contibution-for-CGAL-Complex-3-in-triangulation-3-polyhedron-builder-h-td2307832.html

2.
A. It converts tets from CGAL to tets for vtk, I'm not sure how it could
help me.
B. But there is the
MeshComplex_3InTriangulation_3::Facets_in_complex_iterator(), which gives
the surface facets. I can't see a link (?) to what the facet consists of,
but I assume there's a begin_vertices(), or I can look in the source for
that.
C. I could hold in an std::map the vertex handles to some arbitrary ids, so
I could connect between common vertices of the facets.
D. I can use c3t3.surface_patch_index(Facet f), to retrieve the connected
component the facet belongs to - if that's what I think it is, and here
things get a bit murky. I'm not fully sure about the definitions, or what's
going on here, and that's why I implied that a depiction might help. There
are two related links in the manual:

http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Mesh_3/Chapter_main.html
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Mesh_3_ref/Concept_MeshComplex_3InTriangulation_3.html

On the second link, second paragraph:

"To distinguish the faces of the embedded 3D complex from the faces of the
triangulation, we call the faces of the embedded complex respectively
subdomains, for 3D faces and surface patches, for 2D faces, while the
triangulations faces are called respectively cells, facets, edges and
vertices."

I'm not sure if it's bad punctuation, but there's a problem in this sentence
and it doesn't make sense to me.

Please help me understand the c3t3 structure. It's a 3 simplicial complex,
which is embedded as a triangulation. The simplicial complex is partitioned
to a few spaces (sub-domains?), each space is composed of tets, and its
boundary surface is composed of facets. Referring to the first link, figure
50.1, I assume that each colored set of tets is an independent space.
Are there facets only on the surface, since a tet is also made of 4 facets?
Why do we need to distinguish between the simplicial complex and its
embedding - the triangulation?
When I extract a polyhedron, I want only facets that touch 'air', and not
the ones between the spaces, how do I know if a facet touches air?
When I reconstruct a c3t3 from a poly, how many spaces will I have?

3.
I thought it was buggy officially. Anyway here is one of the standard
models, try to remesh it with poly_3 demo:

http://svn.code.sf.net/p/mymayaplugins/code-0/trunk/tmp/camel.off

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Convert-C3t3-to-Polyhedron-tp4467182p4501152.html
Sent from the cgal-discuss mailing list archive at Nabble.com.


// Copyright (c) 2008-2009  GeometryFactory (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: svn+ssh:///svn/cgal/branches/next/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h $
// $Id: Complex_3_in_triangulation_3_to_vtk.h 67117 2012-01-13 18:14:48Z lrineau $
//
//
// Author(s)     : Laurent Rineau

#ifndef BOUNDARY_OF_SUDDOMAIN_OF_COMPLEX_3_IN_TRIANGULATION_3_TO_OFF_H
#define BOUNDARY_OF_SUDDOMAIN_OF_COMPLEX_3_IN_TRIANGULATION_3_TO_OFF_H

#include <map>
#include <sstream>

#include <CGAL/array.h>

namespace CGAL {

namespace internal{
template <class Vertex_handle>
std::size_t get_vertex_index(Vertex_handle v,std::map<Vertex_handle, std::size_t>& V,std::size_t& inum,std::stringstream& vertex_buffer){
  std::pair<typename std::map<Vertex_handle, std::size_t>::iterator,bool> res=
    V.insert(std::make_pair(v,inum));
  if (res.second){
    ++inum;
    vertex_buffer <<   res.first->first->point().point() <<"\n"; //point is weighted!
  }
  return res.first->second;
}
}//namespace internal

template <typename C3T3>
std::ostream&
output_boundary_of_c3t3_to_off(const C3T3& c3t3, 
                               typename C3T3::Subdomain_index sd_index,
                               std::ostream& output)
{
  typedef typename C3T3::Triangulation Triangulation;
  typedef typename Triangulation::Vertex_handle Vertex_handle;

  const Triangulation& tr = c3t3.triangulation();

  std::map<Vertex_handle, std::size_t> V;
  
  std::size_t inum = 0; 
  std::size_t nfacets = 0;
  cpp0x::array<std::size_t,3> indices={{0,0,0}};
  std::stringstream facet_buffer,vertex_buffer;
  for(typename C3T3::Facets_in_complex_iterator 
        fit = c3t3.facets_in_complex_begin(),
        end = c3t3.facets_in_complex_end();
      fit != end; ++fit) 
  {
    typename C3T3::Subdomain_index cell_sd=c3t3.subdomain_index(fit->first);
    typename C3T3::Subdomain_index opp_sd=c3t3.subdomain_index(fit->first->neighbor(fit->second));
    
    if (cell_sd!=sd_index && opp_sd!=sd_index) continue;

    ++nfacets;
    int j=-1;
    
    
    for (int i = 0; i < 4; ++i)
      if (i != fit->second)
          indices[++j]=internal::get_vertex_index((*fit).first->vertex(i), V, inum,vertex_buffer);
    if ( (cell_sd==sd_index) == (fit->second%2 == 1) ) std::swap(indices[0],indices[1]);
    facet_buffer << "3" << " " << indices[0] <<" " << indices[1] <<" " << indices[2] << "\n";
  }
  
  output << "OFF " << inum << " " << nfacets << " 0\n";
  output << vertex_buffer.str();
  output << facet_buffer.str();
  
  
  return output;
}

} // end namespace CGAL

#endif // BOUNDARY_OF_SUDDOMAIN_OF_COMPLEX_3_IN_TRIANGULATION_3_TO_OFF_H



Archive powered by MHonArc 2.6.16.

Top of Page