Subject: CGAL users discussion list
List archive
- From: venki1130 <>
- To:
- Subject: [cgal-discuss] CGAL Surface mesh generation
- Date: Mon, 2 Mar 2015 12:04:35 -0800 (PST)
Hello all,
Could you please check my code to generate a 3d surface mesh. The following
code giving me errors..
////////////////////////start
// C++ headers
#include <iostream>
#include <algorithm>
#include <limits>
#include <math.h>
// CGAL headers
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/Surface_mesh_default_criteria_3.h>
#include <CGAL/Complex_2_in_triangulation_3.h>
#include <CGAL/IO/Complex_2_in_triangulation_3_file_writer.h>
#include <fstream>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Gray_level_image_3.h>
#include <CGAL/Implicit_surface_3.h>
// default triangulation for Surface_mesher
typedef CGAL::Surface_mesh_default_triangulation_3 Tr;
// Triangulation
// c2t3
typedef CGAL::Complex_2_in_triangulation_3
C2t3;
// Labelled image
typedef Tr::Geom_traits GT;
typedef CGAL::Gray_level_image_3<GT::FT, GT::Point_3> Gray_level_image;
typedef CGAL::Implicit_surface_3<GT, Gray_level_image> Surface_3;
// Usage: image2mesh_cgal inputstack.inr criteria.txt
// criterial.txt is a text file containing setting for mesh sizes and
refirement options.
int main(int argc, char *argv[])
{
Tr tr; // 3D-Delaunay triangulation
// Loads imag
std::string cfn, inrfn, outfn;
double facet_angle=25, facet_size=2, facet_distance=1.5,
cell_radius_edge=2, general_cell_size=2;
double special_size = 0.9; // Cell size to be used in subdomains of
image
with 'special_subdomain_label'
int special_subdomain_label = 0; // If this is set to zero, no
subdomain
resizing will be performed
int volume_dimension = 3;
bool defulatcriteria = false;
if (argc == 1) {
std::cout << " Enter the image stack file name (.inr): ";
std::cin >> inrfn;
defulatcriteria = true;
std::cout << " (Using default settings for meshing
parameters!)\n";
}
else if (argc==2) {
inrfn = argv[1];
defulatcriteria = true;
}
else if (argc >= 3) {
inrfn = argv[1];
cfn = argv[2];
}
if (!defulatcriteria) {
std::ifstream cfs(cfn.c_str());
if (!cfs) {
std::cerr << " Can not read mesh criteria file!\n";
exit(-1);
}
cfs >> facet_angle;
cfs >> facet_size;
cfs >> facet_distance;
cfs >> cell_radius_edge;
cfs >> general_cell_size;
cfs >> special_subdomain_label;
cfs >> special_size;
/*std::cout << facet_angle << std::endl <<
facet_size << std::endl <<
facet_distance << std::endl <<
cell_radius_edge << std::endl <<
general_cell_size << std::endl <<
special_subdomain_label << std::endl
<<
special_size << std::endl;*/
}
if (argc >= 4)
outfn = argv[3];
else
outfn = "_tmp_image2mesh_cgal.mesh";
Gray_level_image (read(inrfn.c_str()));
// Carefully choosen bounding sphere: the center must be inside the
// surface defined by 'image' and the radius must be high enough so
that
// the sphere actually bounds the whole image.
GT::Point_3 bounding_sphere_center(122., 102., 117.);
GT::FT bounding_sphere_squared_radius = 200.*200.*2.;
// instantiate the bounding sphere
GT::Sphere_3 bounding_sphere(bounding_sphere_center,
bounding_sphere_squared_radius);
// definition of the surface, with 10^-5 as relative precision
Surface_3 surface(image, bounding_sphere, 1e-5);
// defining meshing criteria
CGAL::Surface_mesh_default_criteria_3
criteria(facet_angle, facet_size, facet_distance,
cell_radius_edge, cell_size);
// meshing surface, with the "manifold without boundary" algorithm
C2t3 c2t3 = CGAL::make_surface_mesh(c2t3, surface, criteria,
CGAL::Manifold_tag());
// Output
std::ofstream medit_file(outfn.c_str());
c2t3(medit_file);
return 0;
}
/////////////////////////////////end
Thank you
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/CGAL-Surface-mesh-generation-tp4660545.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] CGAL Surface mesh generation, venki1130, 03/02/2015
- Re: [cgal-discuss] CGAL Surface mesh generation, Laurent Rineau (CGAL/GeometryFactory), 03/03/2015
- Re: [cgal-discuss] CGAL Surface mesh generation, venki1130, 03/03/2015
- Re: [cgal-discuss] CGAL Surface mesh generation, Laurent Rineau (CGAL/GeometryFactory), 03/03/2015
Archive powered by MHonArc 2.6.18.