Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Meshing 3D segmented domain with 1D sharp feature

Subject: CGAL users discussion list

List archive

[cgal-discuss] Meshing 3D segmented domain with 1D sharp feature


Chronological Thread 
  • From: <>
  • To:
  • Subject: [cgal-discuss] Meshing 3D segmented domain with 1D sharp feature
  • Date: Mon, 25 Jul 2011 12:46:16 +0200 (CEST)

Hello everybody, I am really new to CGAL and now I try to learn 3D mesh
generation of the segmented 3D images.
In the manual (Chapter 49: 3D Mesh Generation) I have found the following
sentence :
" The current implementation provides classes to represent domains bounded by
isosurfaces of implicit functions, polyhedral domains and domains defined
through 3D labeled images. Currently, 1-dimensional features may be defined as
segments and polyline segments. "

Please, does it mean that a 1D-feature (line) can be preserved also using
meshing of segmented 3D image?
I've tried it without success.

I run succesfully two examples shown in the manual: "mesh_3D_image.cpp" and
"mesh_two_implicit_spheres_with_balls.cpp", in the latter it is demonstrated
how an edge (polyline) can be preserved. Then I've tried to modify the file
"mesh_3D_image.cpp" to implement 1D sharp feature when using the segmented
image. .
For that I use input image: "domain.inr", which describes a simple cube of
sizes 128x128x128 (one material only).
(The header of domain.inr is:
#INRIMAGE-4#{
XDIM=128
YDIM=128
ZDIM=128
VDIM=1
TYPE=unsigned fixed
PIXSIZE=8 bits
CPU=pc
VX=1
VY=1
VZ=1
....
##}
)
Then I attempted to add 1D feature (such that one edge of the cube should be
preserved, i.e. sharp) to the "mesh_3D_image.cpp". It was done consulting the
code in
"mesh_two_implicit_spheres_with_balls.cpp".
The final code is compiled without errors, mesh of the cube is generated, but
the 1D feature IS NOT preserved.

My complete code is:
****************

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>

#include <CGAL/Labeled_image_mesh_domain_3.h>
#include <CGAL/Mesh_domain_with_polyline_features_3.h> // added
#include <CGAL/make_mesh_3.h>
#include <CGAL/Image_3.h>

// Domain
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point; // added
typedef CGAL::Mesh_domain_with_polyline_features_3<
CGAL::Labeled_image_mesh_domain_3<CGAL::Image_3,K> > Mesh_domain;
//modified

// Polyline //added
typedef std::vector<Point> Polyline;
typedef std::list<Polyline> Polylines;

// Triangulation
typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<
Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_segment_index> C3t3;
//modified

// Criteria
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;

// To avoid verbose function and named parameters call
using namespace CGAL::parameters;

int main()
{
// Loads image
CGAL::Image_3 image;
image.read("data/domain.inr");

// Domain
Mesh_domain domain(image);

// Mesh criteria
Mesh_criteria criteria(facet_angle=30, facet_size=6, facet_distance=4,
cell_radius_edge=3, cell_size=4);

// Create edge that we want to preserve
Polylines polylines (1);
Polyline& polyline = polylines.front();

Point p=Point(0, 0, 0);
polyline.push_back(p);
Point p1=Point(127, 0, 0);
polyline.push_back(p1);

// Insert edge in domain
domain.add_features(polylines.begin(), polylines.end());

// Meshing
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);

// Output
std::ofstream medit_file("out.mesh");
c3t3.output_to_medit(medit_file);

return 0;
}

*************************

Please, can you see what I am missing, or some hints or suggestions?
Thank you, Ivan.



Archive powered by MHonArc 2.6.16.

Top of Page