Subject: CGAL users discussion list
List archive
- From: Dan Lior <>
- To:
- Subject: [cgal-discuss] attaching values to cells and vertices in a 3d triangulation
- Date: Thu, 19 Feb 2015 13:13:13 -0800 (PST)
Hello,
I have written code that successfully:
1) specifies a closed polyhedral surface and a second polyhedral surface
within
2) specifies some 1 dimensional polyline features within the closed
polyhedral surface
3) generates a mesh domain with these surfaces and features
4) uses make_mesh to generate a tetrahedralization of the surfaces with the
protected features.
My next step is to add user data (for now, just floats) to each vertex of
the resulting triangulation and to each cell of the triangulation. That
involves changing the way that I declare the triangulation structure.
Specifically,
I provide my own versions of the 4th and 5th template parameter for the
class CGAL::Mesh_triangulation_3 instead of just using the default
parameters.
I must have done something wrong because this causes a compiler error which
I don't understand and can't fix. I've included the code followed by the
compiler error below. If anyone can offer any insight on what I'm doing
wrong I would really appreciate it.
Dan
#include <iostream>
//#include <vector>
//#include <list>
//#include <CGAL/algorithm.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Mesh_polyhedron_3.h>
#include <CGAL/convex_hull_3.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Mesh_domain_with_polyline_features_3.h>
#include <CGAL/Polyhedral_mesh_domain_3.h>
#include <CGAL/Polyhedral_mesh_domain_with_features_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/refine_mesh_3.h>
#include <CGAL/tags.h>
#include <CGAL/Triangulation_3.h>
#include <CGAL/Regular_triangulation_3.h>
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
#include <CGAL/Mesh_vertex_base_3.h>
#include <CGAL/Mesh_cell_base_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <CGAL/Triangulation_cell_base_with_info_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel
Kernel;
typedef CGAL::Mesh_polyhedron_3<Kernel>::type
Polyhedral_surface;
typedef Kernel::Point_3
Point;
typedef std::vector<Point>
Polyline;
typedef std::list<Polyline>
Polyline_graph;
// specify domain to be meshed
typedef CGAL::Polyhedral_mesh_domain_with_features_3<Kernel> Mesh_domain;
// specify cell and vertex structure
typedef float My_vertex_info;
typedef float My_cell_info;
typedef CGAL::Triangulation_vertex_base_with_info_3<My_vertex_info, Kernel>
Vb;
typedef CGAL::Triangulation_cell_base_with_info_3<My_cell_info, Kernel>
Cb;
// specify triangulation
typedef CGAL::Kernel_traits<Mesh_domain>::Kernel Gt;
//typedef CGAL::Regular_triangulation_euclidean_traits_3<Kernel, Kernel::RT>
Gt;
typedef CGAL::Sequential_tag Concurrency_tag;
typedef CGAL::Mesh_vertex_base_3<Gt, Mesh_domain, Vb> Mvb;
typedef CGAL::Mesh_cell_base_3<Gt, Mesh_domain, Cb> Mcb;
//typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
typedef CGAL::Mesh_triangulation_3<Mesh_domain, Gt, Concurrency_tag, Mvb,
Mcb>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr,
Mesh_domain::Corner_index, Mesh_domain::Curve_segment_index> C3t3;
// specify criteria for meshing algorithm
typedef CGAL::Mesh_criteria_3
Mesh_criteria;
// A modifier creating a triangulated polyhedral surface using the
incremental builder.
template <class HDS>
class Build_surface : public CGAL::Modifier_base<HDS> {
public:
Build_surface() {}
void operator()(HDS& hds) {
typedef typename HDS::Vertex::Point Point;
CGAL::Polyhedron_incremental_builder_3<HDS> B(hds, true);
B.begin_surface(4, 2, 10); // number of new verts,
facets, halfedges
B.add_vertex(Point(0.5, 0, 0));
B.add_vertex(Point(0.5, 0, 1));
B.add_vertex(Point(0.5, 1, 0));
B.add_vertex(Point(0.5, 1, 1));
B.begin_facet();
B.add_vertex_to_facet(0);
B.add_vertex_to_facet(1);
B.add_vertex_to_facet(3);
B.end_facet();
B.begin_facet();
B.add_vertex_to_facet(0);
B.add_vertex_to_facet(3);
B.add_vertex_to_facet(2);
B.end_facet();
B.end_surface();
}
};
using namespace CGAL::parameters;
int main()
{
Mvb testvb;
// create horizon
Polyhedral_surface horizon;
Build_surface<Polyhedral_surface::HalfedgeDS> surface;
horizon.delegate(surface);
assert(!horizon.empty());
// create resevoir
std::vector<Point> points;
points.push_back(Point(0, 0, 0));
points.push_back(Point(0, 0, 1));
points.push_back(Point(0, 1, 0));
points.push_back(Point(0, 1, 1));
points.push_back(Point(1, 0, 0));
points.push_back(Point(1, 0, 1));
points.push_back(Point(1, 1, 0));
points.push_back(Point(1, 1, 1));
Polyhedral_surface resevoir;
CGAL::convex_hull_3(points.begin(), points.end(), resevoir);
assert(!resevoir.empty());
// create well
Polyline well;
well.push_back(Point(1, 0.5, 0.5));
well.push_back(Point(0, 0.5, 0.5));
// create domain (specifies the surfaces bounding the region to be
triangulated)
Mesh_domain domain(horizon, resevoir);
// specify 1D features which should be protected during the coming
triangulation stage
Polyline_graph protected1DFeatures;
// a polyline graph is a graph whose edges are polylines and
whose
vertices are the endpoints of the polylines
// edges cannot be degenerate: ie polylines must contain at
least two
distinct endpoints
// polylines cannot intersect (themselves or each other),
except at
vertices
// Note: violations to these restrictions are only apparent
at run time :(
protected1DFeatures.push_back(well);
// the well itself should be protected
Polyline horizonPerimeter;
horizonPerimeter.push_back(Point(0.5, 0, 0));
horizonPerimeter.push_back(Point(0.5, 0, 1));
horizonPerimeter.push_back(Point(0.5, 1, 1));
horizonPerimeter.push_back(Point(0.5, 1, 0));
horizonPerimeter.push_back(Point(0.5, 0, 0));
protected1DFeatures.push_back(horizonPerimeter);
// one can't protect 2D or 3D surfaces but, as long as the
perimeter of
the horizon does not intersect existing protected features,
// in this case, the well, we can protect that perimeter of
the horizon
// impose protected features on the domain to be triangulated
domain.add_features(protected1DFeatures.begin(),
protected1DFeatures.end());
// set criterion for coming tetrahedralization!
Mesh_criteria criteria(
CGAL::parameters::edge_size = 0.025,
CGAL::parameters::facet_angle = 25,
CGAL::parameters::facet_size = 0.05,
CGAL::parameters::facet_distance = 0.05, // 0.005,
// controls the distance of the mesh to the domain
surfaces (a weak form
of surface protection)
CGAL::parameters::cell_radius_edge_ratio = 3,
CGAL::parameters::cell_size = 0.05
);
// Generate mesh/tetrahedralization
C3t3 c3t3;
c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
return 0;
}
1> mesh_to_file.cpp
1>C:\Program Files\CGAL-4.5.1\include\CGAL/Triangulation_3.h(2882): error
C2440: 'initializing' : cannot convert from 'CGAL::Point_3<Kernel_> *' to
'const CGAL::Weighted_point<CGAL::Point_3<Kernel_>,Weight> *'
1> with
1> [
1> Kernel_=CGAL::Epick
1> ]
1> Cast from base to derived requires dynamic_cast or static_cast
1> C:\Program Files\CGAL-4.5.1\include\CGAL/Triangulation_3.h(2825)
: while compiling class template member function
'CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Mesh_cell_base_3<GT,MD,CGAL::Triangulation_cell_base_with_info_3<float,CGAL::Epick,CGAL::Triangulation_cell_base_3<CGAL::Epick,CGAL::Triangulation_ds_cell_base_3<TDS2>>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>
CGAL::Triangulation_3<Gt,CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<GT,MD,Vb>,CGAL::Mesh_cell_base_3<GT,MD,Cb>,CGAL::Sequential_tag>,Lock_data_structure_>::inexact_locate(const
CGAL::Weighted_point<CGAL::Point_3<Kernel_>,Weight>
&,CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Mesh_cell_base_3<GT,MD,CGAL::Triangulation_cell_base_with_info_3<float,CGAL::Epick,CGAL::Triangulation_cell_base_3<CGAL::Epick,CGAL::Triangulation_ds_cell_base_3<TDS2>>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int,bool
*) const'
1> with
1> [
1> GT=Gt
1> , MD=Mesh_domain
1> ,
TDS2=CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<Gt,Mesh_domain,Vb>,CGAL::Mesh_cell_base_3<Gt,Mesh_domain,Cb>,CGAL::Sequential_tag>
1> , Gt=CGAL::Robust_weighted_circumcenter_filtered_traits_3<Gt>
1> , Lock_data_structure_=CGAL::Default
1> , Kernel_=CGAL::Epick
1> , Weight=double
1> ]
1> C:\Program Files\CGAL-4.5.1\include\CGAL/Triangulation_3.h(875)
: see reference to function template instantiation
'CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Mesh_cell_base_3<GT,MD,CGAL::Triangulation_cell_base_with_info_3<float,CGAL::Epick,CGAL::Triangulation_cell_base_3<CGAL::Epick,CGAL::Triangulation_ds_cell_base_3<TDS2>>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>
CGAL::Triangulation_3<Gt,CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<GT,MD,Vb>,CGAL::Mesh_cell_base_3<GT,MD,Cb>,CGAL::Sequential_tag>,Lock_data_structure_>::inexact_locate(const
CGAL::Weighted_point<CGAL::Point_3<Kernel_>,Weight>
&,CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Mesh_cell_base_3<GT,MD,CGAL::Triangulation_cell_base_with_info_3<float,CGAL::Epick,CGAL::Triangulation_cell_base_3<CGAL::Epick,CGAL::Triangulation_ds_cell_base_3<TDS2>>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int,bool
*) const' being compiled
1> with
1> [
1> GT=Gt
1> , MD=Mesh_domain
1> ,
TDS2=CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<Gt,Mesh_domain,Vb>,CGAL::Mesh_cell_base_3<Gt,Mesh_domain,Cb>,CGAL::Sequential_tag>
1> , Gt=CGAL::Robust_weighted_circumcenter_filtered_traits_3<Gt>
1> , Lock_data_structure_=CGAL::Default
1> , Kernel_=CGAL::Epick
1> , Weight=double
1> ]
1> C:\Program Files\CGAL-4.5.1\include\CGAL/Triangulation_3.h(2353)
: while compiling class template member function 'bool
CGAL::Triangulation_3<Gt,CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<Gt,Mesh_domain,Vb>,CGAL::Mesh_cell_base_3<Gt,Mesh_domain,Cb>,CGAL::Sequential_tag>,Lock_data_structure_>::is_vertex(const
CGAL::Weighted_point<CGAL::Point_3<Kernel_>,Weight>
&,CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Mesh_vertex_base_3<GT,MD,CGAL::Triangulation_vertex_base_with_info_3<float,CGAL::Epick,CGAL::Triangulation_vertex_base_3<CGAL::Epick,CGAL::Triangulation_ds_vertex_base_3<TDS2>>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>
&) const'
1> with
1> [
1> Gt=CGAL::Robust_weighted_circumcenter_filtered_traits_3<Gt>
1> , Lock_data_structure_=CGAL::Default
1> , Kernel_=CGAL::Epick
1> , Weight=double
1> , GT=Gt
1> , MD=Mesh_domain
1> ,
TDS2=CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<Gt,Mesh_domain,Vb>,CGAL::Mesh_cell_base_3<Gt,Mesh_domain,Cb>,CGAL::Sequential_tag>
1> ]
1> C:\Program
Files\CGAL-4.5.1\include\CGAL/Mesh_complex_3_in_triangulation_3.h(570) : see
reference to function template instantiation 'bool
CGAL::Triangulation_3<Gt,CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<Gt,Mesh_domain,Vb>,CGAL::Mesh_cell_base_3<Gt,Mesh_domain,Cb>,CGAL::Sequential_tag>,Lock_data_structure_>::is_vertex(const
CGAL::Weighted_point<CGAL::Point_3<Kernel_>,Weight>
&,CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Mesh_vertex_base_3<GT,MD,CGAL::Triangulation_vertex_base_with_info_3<float,CGAL::Epick,CGAL::Triangulation_vertex_base_3<CGAL::Epick,CGAL::Triangulation_ds_vertex_base_3<TDS2>>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>
&) const' being compiled
1> with
1> [
1> Gt=CGAL::Robust_weighted_circumcenter_filtered_traits_3<Gt>
1> , Lock_data_structure_=CGAL::Default
1> , Kernel_=CGAL::Epick
1> , Weight=double
1> , GT=Gt
1> , MD=Mesh_domain
1> ,
TDS2=CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<Gt,Mesh_domain,Vb>,CGAL::Mesh_cell_base_3<Gt,Mesh_domain,Cb>,CGAL::Sequential_tag>
1> ]
1> C:\Program
Files\CGAL-4.5.1\include\CGAL/Mesh_complex_3_in_triangulation_3.h(558) :
while compiling class template member function
'CGAL::Mesh_complex_3_in_triangulation_3<Tr,CGAL::Polyhedral_mesh_domain_with_features_3<Kernel,CGAL::Polyhedron_3<Gt,CGAL::Mesh_3::Mesh_polyhedron_items<Patch_id>,CGAL::HalfedgeDS_default,std::allocator<int>>,CGAL::Triangle_accessor_3<Polyhedron_,IGT_>,CGAL::Tag_true,CGAL::Tag_true>::Corner_index,CGAL::Polyhedral_mesh_domain_with_features_3<IGT_,Polyhedron_,CGAL::Triangle_accessor_3<Polyhedron_,IGT_>,CGAL::Tag_true,CGAL::Tag_true>::Curve_segment_index>::Mesh_complex_3_in_triangulation_3(const
CGAL::Mesh_complex_3_in_triangulation_3<Tr,CGAL::Polyhedral_mesh_domain_with_features_3<IGT_,Polyhedron_,CGAL::Triangle_accessor_3<Polyhedron_,IGT_>,CGAL::Tag_true,CGAL::Tag_true>::Corner_index,CGAL::Polyhedral_mesh_domain_with_features_3<IGT_,Polyhedron_,CGAL::Triangle_accessor_3<Polyhedron_,IGT_>,CGAL::Tag_true,CGAL::Tag_true>::Curve_segment_index>
&)'
1> with
1> [
1> Gt=Kernel
1> , Patch_id=int
1> ,
Polyhedron_=CGAL::Polyhedron_3<Kernel,CGAL::Mesh_3::Mesh_polyhedron_items<int>,CGAL::HalfedgeDS_default,std::allocator<int>>
1> , IGT_=Kernel
1> ]
1> C:\Program Files\CGAL-4.5.1\include\CGAL/make_mesh_3.h(294) :
see reference to function template instantiation
'CGAL::Mesh_complex_3_in_triangulation_3<Tr,CGAL::Polyhedral_mesh_domain_with_features_3<Kernel,CGAL::Polyhedron_3<Gt,CGAL::Mesh_3::Mesh_polyhedron_items<Patch_id>,CGAL::HalfedgeDS_default,std::allocator<int>>,CGAL::Triangle_accessor_3<Polyhedron_,IGT_>,CGAL::Tag_true,CGAL::Tag_true>::Corner_index,CGAL::Polyhedral_mesh_domain_with_features_3<IGT_,Polyhedron_,CGAL::Triangle_accessor_3<Polyhedron_,IGT_>,CGAL::Tag_true,CGAL::Tag_true>::Curve_segment_index>::Mesh_complex_3_in_triangulation_3(const
CGAL::Mesh_complex_3_in_triangulation_3<Tr,CGAL::Polyhedral_mesh_domain_with_features_3<IGT_,Polyhedron_,CGAL::Triangle_accessor_3<Polyhedron_,IGT_>,CGAL::Tag_true,CGAL::Tag_true>::Corner_index,CGAL::Polyhedral_mesh_domain_with_features_3<IGT_,Polyhedron_,CGAL::Triangle_accessor_3<Polyhedron_,IGT_>,CGAL::Tag_true,CGAL::Tag_true>::Curve_segment_index>
&)' being compiled
1> with
1> [
1> Gt=Kernel
1> , Patch_id=int
1> ,
Polyhedron_=CGAL::Polyhedron_3<Kernel,CGAL::Mesh_3::Mesh_polyhedron_items<int>,CGAL::HalfedgeDS_default,std::allocator<int>>
1> , IGT_=Kernel
1> ]
1> mesh_to_file.cpp(183) : see reference to function template
instantiation 'C3T3 CGAL::make_mesh_3<C3t3,Mesh_domain,Mesh_criteria,>(const
MD &,const MC &)' being compiled
1> with
1> [
1> C3T3=C3t3
1> , MD=Mesh_domain
1> , MC=Mesh_criteria
1> ]
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/attaching-values-to-cells-and-vertices-in-a-3d-triangulation-tp4660499.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] attaching values to cells and vertices in a 3d triangulation, Dan Lior, 02/19/2015
- Re: [cgal-discuss] attaching values to cells and vertices in a 3d triangulation, Sebastien Loriot (GeometryFactory), 02/20/2015
- Re: [cgal-discuss] attaching values to cells and vertices in a 3d triangulation, Dan Lior, 02/21/2015
- Re: [cgal-discuss] attaching values to cells and vertices in a 3d triangulation, Sebastien Loriot (GeometryFactory), 02/20/2015
Archive powered by MHonArc 2.6.18.