Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] use Surface mesher to re-mesh self-intersecting

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] use Surface mesher to re-mesh self-intersecting


Chronological Thread 
  • From: Qianqian Fang <>
  • To:
  • Subject: Re: [cgal-discuss] use Surface mesher to re-mesh self-intersecting
  • Date: Mon, 23 Feb 2009 17:32:25 -0500

Laurent Saboret wrote:
Mariette Yvinec wrote:

The Surface mesher will be able to handle such a situation in a
a near future.
What is missing actually is the Polyhedral_surface_traits that can handle
surface defined as a triangle soup. Such a traits is going to be provided
in the next public release.

In the current release, you can find such a traits hidden in the polyhedron
demo, as Pierre said. However you will have to hack a bit the code, ti bypass the construction of the Polyhedron_3 which does not work with a self intersecting triangular surface.


Hi Qianqian Fang,

I attached to this post the AABB_polyhedral_oracle class mentioned by Mariette above, that can remesh a triangles soup. Triangles must be convertible to type CGAL::Triangle_3.

Best regards,

hi Laurent and Mariette

thank you very much for helping me on this. I modified the example from
demo/PolyhedronMainWindow_remeshing.cpp and replaced with Laurent's
AABB_tree units. Unfortunately, g++ raised a bunch of error messages
when compiling the program. I believe the key issue is to define a
Triangle_3 object and feed to AABB_tree template, and I probably did it
in wrong.

I am wondering if either of you can take a quick look at the unit I attached,
and tell me if it is what you expected, particularly the definition of classes.
I really appreciate your time and patience for helping me to solve this
problem.

Qianqian
#include "AABB_polyhedral_oracle.h"
#include "AABB_tree.h"

#include <fstream>

#include <CGAL/Triangle_3.h>

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/Complex_2_in_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Surface_mesh_default_criteria_3.h>

#include <CGAL/IO/Complex_2_in_triangulation_3_file_writer.h>
#include <CGAL/IO/Complex_2_in_triangulation_3_polyhedron_builder.h>


typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Triangle_3 Surface;

int main(int argc, char**argv){

    Surface surface;

// I hope to read in a triangular surface, say in OFF format, to surface

    std::ifstream is(argv[1]) ; is >> surface ;

//    if(!surface) return;

    // remesh

    typedef CGAL::Surface_mesh_default_triangulation_3 Tr;
    typedef CGAL::Complex_2_in_triangulation_3<Tr> C2t3;
    typedef Tr::Geom_traits GT;

    Tr tr; // 3D-Delaunay triangulation
    C2t3 c2t3(tr); // 2D-complex in 3D-Delaunay triangulation

    // initialize the parameters

    double diag = 100;  // better from something computed from surface

    bool ok;
    double angle = 25.; // [1~30]
    double sizing = diag*0.05; // [diag*1e-5,diag]
    double approx = diag*0.005; // [diag*1e-6,diag]

    // meshing parameters
    CGAL::Surface_mesh_default_criteria_3<Tr> facets_criteria(angle,sizing,approx);

    // AABB tree
    std::cout << "Build AABB tree...";
    typedef CGAL::Simple_cartesian<double> Simple_cartesian_kernel; 
    typedef CGAL::AABB_tree<Simple_cartesian_kernel,Surface> Tree;
    Tree tree;
    tree.build_faces(surface);

    // input surface
    typedef CGAL::AABB_polyhedral_oracle<Surface,GT,Simple_cartesian_kernel> Input_surface;
    Input_surface input(&tree);

    // initial point set
    std::cout << "Insert initial point set...";
    unsigned int nb_initial_points = 10;
    Surface::Point_iterator it;
    typedef CGAL::Cartesian_converter<Kernel,GT> Converter;
    Converter convert;
    unsigned int i = 0;
    for(it = surface.points_begin();
        it != surface.points_end(), i < nb_initial_points;
	it++, i++)
      tr.insert(convert(*it));

    // remesh
    std::cout << "Remesh...";
    CGAL::make_surface_mesh(c2t3, input, facets_criteria, CGAL::Manifold_with_boundary_tag());
    std::cout << "done (" << tr.number_of_vertices() << " vertices)" << std::endl;

    if(tr.number_of_vertices() > 0)
    {
      // add remesh as new polyhedron
      Polyhedron *pRemesh = new Polyhedron;
      CGAL::Complex_2_in_triangulation_3_polyhedron_builder<C2t3, Surface> builder(c2t3);
      pRemesh->delegate(builder);
//      std::ofstream os( argc > 2 ? argv[2] : "out.off" ) ; os << *pRemesh ;

    }
}

Attachment: Remesher.tar.gz
Description: GNU Zip compressed data




Archive powered by MHonArc 2.6.16.

Top of Page