Skip to content

Commit 9f11f46

Browse files
committed
Merge branch 'Periodic_3_mesh_3-Extended_mesh_3-MBogdanov'
This small feature adds a new constructor in Labeled_mesh_domain_3 and a new function wrapper. A Labeled_mesh_domain_3 can be built from an Iso_cuboid_3 now. (cf. https://cgal.geometryfactory.com/CGAL/Members/wiki/Features/Small_Features/New_constructor_in_Label_mesh_domain_3_and_new_function_wrapper) The new wrapper, Implicit_multi_domain_to_labeling_function_wrapper, is a helping class to get a function with integer values labeling the components of a multi-domain. This small feature was successfully tested in the internal release CGAL-4.5-Ic-45. Approved by the Release Manager. Conflicts: Installation/changes.html
2 parents fd06817 + 566ad10 commit 9f11f46

33 files changed

+2683
-54
lines changed

Installation/changes.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ <h3>STL_extension</h3>
148148
</li>
149149
</ul>
150150

151+
152+
<h3>3D Mesh Generation</h3>
153+
<ul>
154+
<li>Add a new constructor for the class <code>Labeled_mesh_domain_3</code> which
155+
takes an <code>Iso_cuboid_3</code>.</li>
156+
<li>Add a new labeling function wrapper for meshing multi-domain.</li>
157+
</ul>
158+
151159
</div>
152160

153161
<h2 id="release4.4">Release 4.4 </h2>
@@ -158,7 +166,7 @@ <h3>Installation</h3>
158166
<li>Additional supported platforms:
159167
<ul>
160168
<li>The Apple Clang compiler version 5.0 is now supported on
161-
OS X Mavericks.</li>
169+
OSXMavericks.</li>
162170
<li>The Microsoft Windows Visual C++ compiler 2013 (VC12) is now
163171
supported.</li>
164172
</ul>
@@ -298,7 +306,7 @@ <h3>CGAL ipelets</h3>
298306
<ul>
299307
<li> Better description of the demo ipelets in the user manual </li>
300308
<li> New ipelet for pencils of circles</li>
301-
<li> New ipelet for hyperbolic geometry in Poincaré model</li>
309+
<li> New ipelet for hyperbolic geometry in Poincar model</li>
302310
<li> The generator ipelet now generates point in a selected zone</li>
303311
<li> Hilbert sort ipelet implements two policies</li>
304312
</ul>
@@ -340,7 +348,7 @@ <h4>2D and 3D Geometry Kernel </h4>
340348
constructor added to <code>CGAL::Object</code>. However, it is
341349
recommended to upgrade your code. The previous behavior can be
342350
restored by defining the
343-
macro <code>CGAL_INTERSECTION_VERSION</code> to 1.
351+
macro <code>CGAL_INTERSECTION_VERSION</code> to1.
344352
</li>
345353
</ul>
346354
<h4>2D Arrangements</h4>
@@ -663,7 +671,7 @@ <h3>Installation</h3>
663671
<li>Additional supported platforms:
664672
<ul>
665673
<li>The Apple Clang compiler versions 3.1 and 3.2 are now supported on
666-
Mac OS X.</li>
674+
MacOSX.</li>
667675
</ul>
668676
</li>
669677
<li>Improved configuration for essential and optional external third party software</li>

Mesh_3/applications/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if ( CGAL_FOUND )
3838
endif()
3939
create_single_source_cgal_program( "mesh_polyhedral_domain.cpp" )
4040
create_single_source_cgal_program( "output_distribution_to_stdout.cpp" )
41-
# create_single_source_cgal_program( "mesher_tester.cpp" "../examples/Mesh_3/implicit_functions.cpp" )
41+
create_single_source_cgal_program( "mesher_tester.cpp" "../examples/Mesh_3/implicit_functions.cpp" )
4242
create_single_source_cgal_program( "mesher_tester_image.cpp" )
4343
create_single_source_cgal_program( "mesher_tester_polyhedron.cpp" )
4444
else()

Mesh_3/applications/mesh_implicit_domains.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
//******************************************************************************
2727

2828

29-
#include <debug.h>
29+
#include "debug.h"
3030
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
3131

3232
#include <CGAL/Mesh_triangulation_3.h>
3333
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
3434
#include <CGAL/Mesh_criteria_3.h>
3535

36-
#include <CGAL/Mesh_3/Implicit_to_labeled_function_wrapper.h>
37-
#include <CGAL/Mesh_3/Labeled_mesh_domain_3.h>
36+
#include <CGAL/Implicit_to_labeling_function_wrapper.h>
37+
#include <CGAL/Labeled_mesh_domain_3.h>
3838
#include <CGAL/make_mesh_3.h>
3939
#include "../examples/Mesh_3/implicit_functions.h"
4040

@@ -51,10 +51,10 @@ using namespace CGAL::parameters;
5151
// Domain
5252
struct K: public CGAL::Exact_predicates_inexact_constructions_kernel {};
5353
typedef FT_to_point_function_wrapper<K::FT, K::Point_3> Function;
54-
typedef CGAL::Mesh_3::Implicit_vector_to_labeled_function_wrapper<Function, K>
54+
typedef CGAL::Implicit_multi_domain_to_labeling_function_wrapper<Function>
5555
Function_wrapper;
5656
typedef Function_wrapper::Function_vector Function_vector;
57-
typedef CGAL::Mesh_3::Labeled_mesh_domain_3<Function_wrapper, K> Mesh_domain;
57+
typedef CGAL::Labeled_mesh_domain_3<Function_wrapper, K> Mesh_domain;
5858

5959
// Triangulation
6060
typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
@@ -95,7 +95,7 @@ void set_function(Function_vector& v,
9595
{
9696
if ( vm.count(function_name) )
9797
{
98-
v.push_back(&f);
98+
v.push_back(f);
9999
std::cout << function_name << " ";
100100
}
101101
}

Mesh_3/applications/mesher_tester.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
1515
#include <CGAL/Mesh_criteria_3.h>
1616
// Implicit domain
17-
#include <CGAL/Mesh_3/Implicit_to_labeled_function_wrapper.h>
18-
#include <CGAL/Mesh_3/Labeled_mesh_domain_3.h>
17+
#include <CGAL/Implicit_to_labeling_function_wrapper.h>
18+
#include <CGAL/Labeled_mesh_domain_3.h>
1919

2020
#include <CGAL/make_mesh_3.h>
2121
#include "../examples/Mesh_3/implicit_functions.h"
@@ -63,9 +63,9 @@ typedef CGAL::Polyhedron_3<Geom_traits> Polyhedron;
6363
typedef CGAL::Polyhedral_mesh_domain_3<Polyhedron, Geom_traits> Polyhedral_domain;
6464
// Implicit domain
6565
typedef FT_to_point_function_wrapper<K::FT, K::Point_3> I_Function;
66-
typedef CGAL::Mesh_3::Implicit_vector_to_labeled_function_wrapper<I_Function, K> I_Function_wrapper;
66+
typedef CGAL::Implicit_multi_domain_to_labeling_function_wrapper<I_Function> I_Function_wrapper;
6767
typedef I_Function_wrapper::Function_vector I_Function_vector;
68-
typedef CGAL::Mesh_3::Labeled_mesh_domain_3<I_Function_wrapper, K> Implicit_domain;
68+
typedef CGAL::Labeled_mesh_domain_3<I_Function_wrapper, K> Implicit_domain;
6969
// 3D Image
7070
typedef CGAL::Image_3 Image;
7171
typedef CGAL::Labeled_image_mesh_domain_3<Image,K> Image_domain;
@@ -121,7 +121,7 @@ void set_implicit_function(I_Function_vector& v,
121121
{
122122
if(vm.count(function_name))
123123
{
124-
v.push_back(&f);
124+
v.push_back(f);
125125
std::cout << function_name << " ";
126126
}
127127
}
@@ -398,7 +398,7 @@ void mesh(const std::string& data, const po::variables_map& vm)
398398
//Load the domain
399399
std::cout << "****** [" << filename << "] Create domain...";
400400
std::flush(std::cout);
401-
Domain_builder<Domain> domain_builder(it->string());
401+
Domain_builder<Domain> domain_builder(it->path().string());
402402
std::cout <<"done (" << timer.time() << "s) ******\n\n";
403403

404404
while(std::getline(file_param,line_param))

Mesh_3/applications/mesher_tester.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ void mesh(const std::string& data, const std::string& output_dir, const int nb_t
570570
//Load the domain
571571
std::stringstream cout_loc;
572572
cout_loc << "+ [" << filename << "] Create domain...";
573-
std::tr1::shared_ptr<Domain_builder<Domain> > pdomain_builder(new Domain_builder<Domain>(it->string()));
573+
std::tr1::shared_ptr<Domain_builder<Domain> > pdomain_builder(new Domain_builder<Domain>(it->path().string()));
574574
cout_loc << "done (" << timer.time() << "s)\n";
575575
std::cout << cout_loc.str();
576576

Mesh_3/demo/Mesh_3/C3t3_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef CGAL::Polyhedral_mesh_domain_with_features_3<Kernel,
4242

4343
typedef CGAL::Labeled_image_mesh_domain_3<Image,Kernel> Image_mesh_domain;
4444
typedef Wrapper<Kernel> Function_wrapper;
45-
typedef CGAL::Mesh_3::Labeled_mesh_domain_3<Function_wrapper, Kernel> Function_mesh_domain;
45+
typedef CGAL::Labeled_mesh_domain_3<Function_wrapper, Kernel> Function_mesh_domain;
4646

4747
// Triangulation
4848
typedef CGAL::Mesh_triangulation_3<Polyhedral_mesh_domain>::type Tr;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
namespace CGAL {
2+
3+
/*!
4+
\ingroup PkgMesh_3Domains
5+
6+
The class `Implicit_multi_domain_to_labeling_function_wrapper` is an helping class to get a function with integer values
7+
labeling the components of a multi-domain. The multidomain is described through a set of function {fi(p), i=1, ...n}.
8+
Each component corresponds to a sign vector [s1, s2, ..., sn] where si is the sign of the function fi(p) at a point p of the component.
9+
This wrapper class can be passed to `Labeled_mesh_domain_3` as first template parameter.
10+
11+
\par Example
12+
For example, the multidomain described by the three funstions [f1,f2,f3] and the two sign vectors [-,-,+] and [+,-,+]
13+
includes two components.<br />
14+
The first one matches the locus of points satisfying f1(p)<0 and f2(p)<0 and f3(p)>0.<br />
15+
The second one matches the locus of points satisfying f1(p)>0 and f2(p)<0 and f3(p)>0.<br />
16+
17+
\tparam Function provides the definition of the function.
18+
This parameter stands for a model of the concept ImplicitFunction described in the surface mesh generation package.
19+
The number types Function::FT and BGT::FT are required to match.
20+
21+
\sa `Implicit_mesh_domain_3`.
22+
23+
*/
24+
template<class Function>
25+
class Implicit_multi_domain_to_labeling_function_wrapper
26+
{
27+
public:
28+
/// \name Types
29+
/// @{
30+
//!
31+
typedef std::vector<Function*> Function_vector;
32+
//!
33+
typedef typename Function::Point Point_3;
34+
/// @}
35+
36+
/// \name Creation
37+
/// @{
38+
/*!
39+
* \brief Construction from a vector of implicit functions.
40+
* \param implicit_functions the vector of implicit functions.
41+
*
42+
* Poistions vectors are built automatically so that the union of components equals the union of the functions.
43+
*/
44+
Implicit_multi_domain_to_labeling_function_wrapper (const Function_vector& implicit_functions);
45+
46+
/*!
47+
* \brief Construction from a vector of implicit functions and a vector of vector of signs.
48+
* \param implicit_functions the vector of implicit functions.
49+
* \param positions_vectors the vector of vector of signs. Each vector of position describes a component.
50+
* \sa `Sign`
51+
*/
52+
Implicit_multi_domain_to_labeling_function_wrapper (const Function_vector& implicit_functions, const std::vector<std::vector<Sign> >& positions_vectors);
53+
54+
/*!
55+
* \brief Construction from a vector of implicit functions and a vector of strings.
56+
* \param implicit_functions the vector of implicit functions.
57+
* \param positions_strings the vector of string. The strings contained in this vector must contain '+' or '-' only. Each string (vector of positions) describes a component.
58+
*/
59+
Implicit_multi_domain_to_labeling_function_wrapper (const Function_vector& implicit_functions, const std::vector<std::string>& positions_strings);
60+
/// @}
61+
62+
}; /* end Implicit_multi_domain_to_labeling_function_wrapper */
63+
/// @}
64+
} /* end namespace CGAL */
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
namespace CGAL {
2+
3+
/*!
4+
\ingroup PkgMesh_3Domains
5+
6+
\brief The class `Labeled_mesh_domain_3` implements indexed domains.
7+
8+
This class is a model of concept `MeshDomain_3`.
9+
10+
Any boundary facet is labeled <a,b>, a<b, where a and b are the
11+
tags of its incident subdomain.
12+
Thus, a boundary facet of the domain is labeled <0,b>, where b!=0.
13+
14+
This class includes a function that provides, the subdomain index of any
15+
query point. An intersection between a segment and bounding
16+
surfaces is detected when both segment endpoints are associated with different
17+
values of subdomain indices. The intersection is then constructed by bisection.
18+
The bisection stops when the query segment is shorter than an error bound
19+
`e` given by the product of the
20+
length of the diagonal of the bounding box (in world coordinates), or the radius of the bounding sphere, and
21+
a relative error bound passed as argument to the constructor of `Labeled_mesh_domain_3`.
22+
23+
Implicit_mesh_domain_3 is a heir of Labeled_mesh_domain_3. It uses a satisfying labeling function if there is only one component to mesh.
24+
25+
\tparam LabelingFunction is the type of the input function.<br />
26+
This parameter stands for a model of the concept ImplicitFunction described in the surface mesh generation package.<br />
27+
Labeling function f must return 0 if the point isn't located in any subdomain. Usually, the return type of labeling functions are integer.<br />
28+
Let p be a Point.
29+
<ul>
30+
<li>f(p)=0 means that p is outside domain.</li>
31+
<li>f(p)=a, a!=0 means that p is inside subdomain a.</li>
32+
</ul>
33+
Implicit_multi_domain_to_labeling_function_wrapper is a good candidate for this template parameter
34+
if there are several components to mesh.
35+
36+
\tparam BGT is a geometric traits class that provides
37+
the basic operations to implement
38+
intersection tests and intersection computations
39+
through a bisection method. This parameter must be instantiated
40+
with a model of the concept `BisectionGeometricTraits_3`.
41+
42+
\cgalModels MeshDomain_3
43+
44+
\sa `Implicit_mesh_domain_3`
45+
\sa `Implicit_multi_domain_to_labeling_function_wrapper`
46+
\sa `CGAL::make_mesh_3()`.
47+
48+
*/
49+
template<class LabelingFunction, class BGT>
50+
class Labeled_mesh_domain_3
51+
{
52+
public:
53+
54+
/// \name Creation
55+
/// @{
56+
57+
/*!
58+
\brief Construction from a labeling function, a bounding Sphere and a relative error bound.
59+
\param f the labeling function.
60+
\param bounding_sphere the bounding sphere of the meshable space.
61+
\param relative_error_bound is the relative error bound used to compute intersection points between the implicit surface and query segments. The
62+
bisection is stopped when the length of the intersected segment is less than the product of `relative_error_bound` by the radius of
63+
`bounding_sphere`.
64+
*/
65+
Labeled_mesh_domain_3(const LabelingFunction& f,
66+
const Sphere_3& bounding_sphere,
67+
const FT& relative_error_bound = FT(1e-3));
68+
69+
/*!
70+
\brief Construction from a labeling function, a bounding box and a relative error bound.
71+
\param f the labeling function.
72+
\param bbox the bounding box of the meshable space.
73+
\param relative_error_bound is the relative error bound used to compute intersection points between the implicit surface and query segments. The
74+
bisection is stopped when the length of the intersected segment is less than the product of `relative_error_bound` by the diagonal of
75+
`bounding_box`.
76+
*/
77+
Labeled_mesh_domain_3(const LabelingFunction& f,
78+
const Bbox_3& bbox,
79+
const FT& relative_error_bound = FT(1e-3));
80+
81+
/*!
82+
\brief Construction from a function, a bounding Iso_cuboid_3 and a relative error bound.
83+
\param f the function.
84+
\param bbox the bounding box of the meshable space.
85+
\param relative_error_bound is the relative error bound used to compute intersection points between the implicit surface and query segments. The
86+
bisection is stopped when the length of the intersected segment is less than the product of `relative_error_bound` by the diagonal of
87+
`bounding_box`.
88+
*/
89+
Labeled_mesh_domain_3(const LabelingFunction& f,
90+
const Iso_cuboid_3& bbox,
91+
const FT& relative_error_bound = FT(1e-3));
92+
93+
/// @}
94+
95+
}; /* end Labeled_mesh_domain_3 */
96+
} /* end namespace CGAL */

Mesh_3/examples/Mesh_3/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ if ( CGAL_FOUND )
3535
create_single_source_cgal_program( "mesh_implicit_sphere.cpp" )
3636
create_single_source_cgal_program( "mesh_implicit_sphere_variable_size.cpp" )
3737
create_single_source_cgal_program( "mesh_two_implicit_spheres_with_balls.cpp" )
38-
# create_single_source_cgal_program( "mesh_implicit_domains.cpp" "implicit_functions.cpp" )
38+
create_single_source_cgal_program( "mesh_implicit_domains_2.cpp" "implicit_functions.cpp" )
39+
create_single_source_cgal_program( "mesh_cubes_intersection.cpp" )
40+
create_single_source_cgal_program( "mesh_cubes_intersection_with_features.cpp" )
41+
create_single_source_cgal_program( "mesh_implicit_domains.cpp" "implicit_functions.cpp" )
3942
create_single_source_cgal_program( "mesh_polyhedral_domain.cpp" )
4043
create_single_source_cgal_program( "mesh_polyhedral_domain_with_features.cpp" )
4144
if( WITH_CGAL_ImageIO )

Mesh_3/examples/Mesh_3/implicit_functions.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ double sphere_function (double x, double y, double z) // (c=(0,0,0), r=Sq_radius
2424

2525

2626

27-
template <typename FT, typename Point>
28-
class FT_to_point_function_wrapper : public std::unary_function<Point, FT>
27+
template <typename FT, typename P>
28+
class FT_to_point_function_wrapper : public std::unary_function<P, FT>
2929
{
3030
typedef FT (*Implicit_function)(FT, FT, FT);
3131
Implicit_function function;
3232
public:
33+
typedef P Point;
3334
FT_to_point_function_wrapper(Implicit_function f) : function(f) {}
3435
FT operator()(Point p) const { return function(p.x(), p.y(), p.z()); }
3536
};

0 commit comments

Comments
 (0)