(WARNING: partially compiles, runtime errors, temporary commit)

- Added an undocumented class Surface_mesh_triangulation_generator_3 which
  is a meta functor Kernel->Triangulation, that computes the right
  triangulation for make_surface_mesh()
- Added documented files:
    - include/CGAL/Implicit_surface_3.h
    - include/CGAL/Surface_mesh_default_criteria_3.h
    - include/CGAL/Surface_mesh_complex_2_in_triangulation_3.h
- In doc, rename:
    - SurfaceMeshCriteria to SurfaceMeshCriteria_3
    - Surface_mesh_default_criteria to Surface_mesh_default_criteria_3
- Added doc_tex GNUmakefile, for developers uses.

- Wrote the first test file!
- Find Triangulation_mesher_level_traits_3.h in include/CGAL/Mesh_2/, now.
- Major changes in template arguments, data members, and constructors of:
  - class Surface_mesher,
  - class Implicit_oracle,
- Minor changes everywhere (sorry for the imprecision, too long).
This commit is contained in:
Laurent Rineau 2006-03-02 16:40:43 +00:00
parent ca753a3ec2
commit f2dbff8b5d
21 changed files with 710 additions and 477 deletions

6
.gitattributes vendored
View File

@ -1619,11 +1619,17 @@ Surface_mesher/demo/Surface_mesher/windows/res/idb7.bmp -text svneol=unset#unset
Surface_mesher/demo/Surface_mesher/windows/res/idb8.bmp -text svneol=unset#unset Surface_mesher/demo/Surface_mesher/windows/res/idb8.bmp -text svneol=unset#unset
Surface_mesher/doc/scheme.fig -text Surface_mesher/doc/scheme.fig -text
Surface_mesher/doc/scheme.ps -text Surface_mesher/doc/scheme.ps -text
Surface_mesher/doc_tex/GNUmakefile -text
Surface_mesher/examples/Surface_mesher/inputs/ALSTOM_TEST4.off -text Surface_mesher/examples/Surface_mesher/inputs/ALSTOM_TEST4.off -text
Surface_mesher/examples/Surface_mesher/inputs/boeing.off -text Surface_mesher/examples/Surface_mesher/inputs/boeing.off -text
Surface_mesher/examples/Surface_mesher/inputs/geosphere.off -text Surface_mesher/examples/Surface_mesher/inputs/geosphere.off -text
Surface_mesher/examples/Surface_mesher/inputs/triceratops.off -text Surface_mesher/examples/Surface_mesher/inputs/triceratops.off -text
Surface_mesher/include/CGAL/Implicit_surface_3.h -text
Surface_mesher/include/CGAL/Surface_mesh_cell_base_3.h -text Surface_mesher/include/CGAL/Surface_mesh_cell_base_3.h -text
Surface_mesher/include/CGAL/Surface_mesh_complex_2_in_triangulation_3.h -text
Surface_mesher/include/CGAL/Surface_mesh_default_criteria_3.h -text
Surface_mesher/include/CGAL/Surface_mesh_traits_generator_3.h -text
Surface_mesher/include/CGAL/Surface_mesh_triangulation_generator_3.h -text
Surface_mesher/include/CGAL/Surface_mesh_vertex_base_3.h -text Surface_mesher/include/CGAL/Surface_mesh_vertex_base_3.h -text
Surface_mesher/include/CGAL/make_surface_mesh.h -text Surface_mesher/include/CGAL/make_surface_mesh.h -text
Surface_mesher/test/Surface_mesher/implicit_surface_mesher_test.C -text Surface_mesher/test/Surface_mesher/implicit_surface_mesher_test.C -text

1
.gitignore vendored
View File

@ -312,6 +312,7 @@ Surface_mesher/examples/Surface_mesher/sphere_union.mesh
Surface_mesher/examples/Surface_mesher/sphere_union.off Surface_mesher/examples/Surface_mesher/sphere_union.off
Surface_mesher/examples/Surface_mesher/surface_mesher Surface_mesher/examples/Surface_mesher/surface_mesher
Surface_mesher/examples/Surface_mesher/surfaces_union Surface_mesher/examples/Surface_mesher/surfaces_union
Surface_mesher/include/CGAL/Mesh_3
Surface_mesher/test/Surface_mesher/test_robust_circumcenter Surface_mesher/test/Surface_mesher/test_robust_circumcenter
Tutorial/tutorial/Polyhedron/sgp2004/paper/paper.aux Tutorial/tutorial/Polyhedron/sgp2004/paper/paper.aux
Tutorial/tutorial/Polyhedron/sgp2004/paper/paper.bbl Tutorial/tutorial/Polyhedron/sgp2004/paper/paper.bbl

View File

@ -1,11 +1,16 @@
.PHONY: all examples clean dist-clean doxygen update diff .PHONY: all clean diff dist-clean doc doxygen examples test update
all: test examples
all: examples doc:
${MAKE} -C doc_tex
examples: examples:
${MAKE} -C examples/Surface_mesher ${MAKE} -C examples/Surface_mesher
test:
$(MAKE) -C test/Surface_mesher
doxygen: doxygen:
doxygen doxygen

View File

@ -1,3 +1,24 @@
2 March 2006 Laurent Rineau
(WARNING: partially compiles, runtime errors, temporary commit)
- Added an undocumented class Surface_mesh_triangulation_generator_3 which
is a meta functor Kernel->Triangulation, that computes the right
triangulation for make_surface_mesh()
- Added documented files:
- include/CGAL/Implicit_surface_3.h
- include/CGAL/Surface_mesh_default_criteria_3.h
- include/CGAL/Surface_mesh_complex_2_in_triangulation_3.h
- In doc, rename:
- SurfaceMeshCriteria to SurfaceMeshCriteria_3
- Surface_mesh_default_criteria to Surface_mesh_default_criteria_3
- Added doc_tex GNUmakefile, for developers uses.
- Wrote the first test file!
- Find Triangulation_mesher_level_traits_3.h in include/CGAL/Mesh_2/, now.
- Major changes in template arguments, data members, and constructors of:
- class Surface_mesher,
- class Implicit_oracle,
- Minor changes everywhere (sorry for the imprecision, too long).
27 february 2006 Laurent Rineau 27 february 2006 Laurent Rineau
(WARNING: no longer compiles, temporary commit) (WARNING: no longer compiles, temporary commit)
- Added number_of_facets() to C2T3 (code and documentation) - Added number_of_facets() to C2T3 (code and documentation)

View File

@ -0,0 +1,9 @@
.PHONY: Surface_mesher_ref.doc Surface_mesher.doc
all: Surface_mesher_ref.doc Surface_mesher.doc
Surface_mesher_ref.doc:
cgal_manual Surface_mesher_ref
Surface_mesher.doc:
cgal_manual Surface_mesher

View File

@ -1,11 +1,12 @@
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
% | Reference manual page: Implicit_surface_3.tex % | Reference manual page: Implicit_surface_3.tex
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
% | 09.12.2005 Author % | 09.12.2005 Mariette Yvinec
% | Package: Package % | Package: Surface_mesher
% | ($ URL: $)
% | % |
\RCSdef{\RCSImplicitsurfaceoracleRev}{$Id$} \RCSdef{\RCSImplicitsurface3Rev}{$Id$}
\RCSdefDate{\RCSImplicitsurfaceoracleDate}{$Date$} \RCSdefDate{\RCSImplicitsurface3Date}{$Date$}
% | % |
%%RefPage: end of header, begin of main body %%RefPage: end of header, begin of main body
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
@ -43,52 +44,15 @@ of the concept \ccc{ImplicitFunction}
The numerical type \ccc{Func::FT} has to match The numerical type \ccc{Func::FT} has to match
the type \ccc{Traits::FT}. the type \ccc{Traits::FT}.
NEED TO DOCUMENT CONSTRUCTOR!
\ccInclude{CGAL/Implicit_surface_3.h} \ccInclude{CGAL/Implicit_surface_3.h}
%\ccIsModel
%\ccc{SurfaceOracle}
%\ccTypes
%\ccNestedType{TYPE}{some nested types}
%\ccCreation
%\ccCreationVariable{a} %% choose variable name
%\ccConstructor{Implicit_surface_oracle();}{default constructor.}
%\ccOperations
%\ccMethod{void foo();}{some member functions}
\ccSeeAlso \ccSeeAlso
\ccc{make_surface_mesh},\\ \ccc{make_surface_mesh},\\
\ccc{Surface_mesh_traits_generator_3<Surface>},\\ \ccc{Surface_mesh_traits_generator_3<Surface>},\\
\ccc{ImplicitSurfaceTraits}, \\ \ccc{ImplicitSurfaceTraits}, \\
\ccc{ImplicitFunction}.\\ \ccc{ImplicitFunction}.
%\ccExample
%A short example program.
%Instead of a short program fragment, a full running program can be
%included using the
%\verb|\ccIncludeExampleCode{Package/Implicit_surface_oracle.C}|
%macro. The program example would be part of the source code distribution and
%also part of the automatic test suite.
%\begin{ccExampleCode}
%void your_example_code() {
%}
%\end{ccExampleCode}
%%% \ccIncludeExampleCode{Package/Implicit_surface_oracle.C}
\end{ccRefClass} \end{ccRefClass}

View File

@ -1,8 +1,9 @@
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
% | Reference manual page: SurfaceMeshCriteria.tex % | Reference manual page: SurfaceMeshCriteria.tex
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
% | 02.12.2005 Author % | 02.12.2005 Mariette Yvinec, Laurent Rineau
% | Package: Package % | Package: Surface_mesher
% | ( $URL$ )
% | % |
\RCSdef{\RCSSurfaceMeshCriteriaRev}{$Id$} \RCSdef{\RCSSurfaceMeshCriteriaRev}{$Id$}
\RCSdefDate{\RCSSurfaceMeshCriteriaDate}{$Date$} \RCSdefDate{\RCSSurfaceMeshCriteriaDate}{$Date$}
@ -11,10 +12,7 @@
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
\begin{ccRefConcept}{SurfaceMeshCriteria} \begin{ccRefConcept}{SurfaceMeshCriteria_3}
%% \ccHtmlCrossLink{} %% add further rules for cross referencing links
%% \ccHtmlIndexC[concept]{} %% add further index entries
\ccDefinition \ccDefinition
@ -46,56 +44,9 @@ one criterion and measures how much the facet deviates from
meeting this criterion. Then, the comparison operator on qualities meeting this criterion. Then, the comparison operator on qualities
is just a lexicographical comparison. is just a lexicographical comparison.
\ccHasModel
%\ccGeneralizes \ccc{Surface_mesh_default_criteria_3<Tr>}
%ThisConcept \\
%ThatConcept
\ccTypes
\ccNestedType{Quality}{A type to measure the quality of mesh facets.
This type is required to be \ccc{LessThanComparable}.}
\ccCreation
\ccCreationVariable{criteria} %% choose variable name
\ccConstructor{SurfaceMeshCriteria();}{Default constructor.}
\ccOperations
\ccMethod{bool is_bad(Facet f);}{Returns true if facet \ccc{f}
does not meet the criteria.}
\ccMethod{Quality quality(Facet f);}{Computes the quality
of facet \ccc{f}.}
\ccHasModels
\ccc{Surface_mesher_default_criteria<FT>}
\ccSeeAlso
\ccc{make_surface_mesh}
%Some\_other\_concept,
%\ccc{some_other_function}.
%\ccExample
%A short example program.
%Instead of a short program fragment, a full running program can be
%included using the
%\verb|\ccIncludeExampleCode{Package/SurfaceMeshCriteria.C}|
%macro. The program example would be part of the source code distribution and
%also part of the automatic test suite.
%\begin{ccExampleCode}
%void your_example_code() {
%}
%\end{ccExampleCode}
%% \ccIncludeExampleCode{Package/SurfaceMeshCriteria.C}
\end{ccRefConcept} \end{ccRefConcept}

View File

@ -49,7 +49,7 @@ three dimensional embedding triangulation
\ccNestedType{Intersect_3} \ccNestedType{Intersect_3}
{A model of this type provides the operator \\ {A model of this type provides the operator \\
\ccc{CGAL::object operator()(Type1 type1, Surface_3 surface)}\\ \ccc{CGAL::object operator()(Surface_3 surface, Type1 type1)}\\
to compute the intersection of the surface to compute the intersection of the surface
with an object of type \ccc{Type1} which may be with an object of type \ccc{Type1} which may be
\ccc{Segment_3}, \ccc{Ray_3} or \ccc{Line_3} .} \ccc{Segment_3}, \ccc{Ray_3} or \ccc{Line_3} .}
@ -59,11 +59,11 @@ with an object of type \ccc{Type1} which may be
{A model of this type provides the following operators {A model of this type provides the following operators
to construct initial points on the surface \\ to construct initial points on the surface \\
\ccc{template <class OutputIteratorPoints> \\ \ccc{template <class OutputIteratorPoints> \\
OutputIteratorPoints ()(OutputIteratorPoints pts);}\\ OutputIteratorPoints operator()(OutputIteratorPoints pts);}\\
which outputs a set of points on the surface. which outputs a set of points on the surface.
\\ \\
\ccc{template <class OutputIteratorPoints>\\ \ccc{template <class OutputIteratorPoints>\\
OutputIteratorPoints () (OutputIteratorPoints pts, int n);} \\ OutputIteratorPoints operator() (OutputIteratorPoints pts, int n);} \\
which outputs a set of \ccc{n} points on the surface.} which outputs a set of \ccc{n} points on the surface.}

View File

@ -1,20 +1,17 @@
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
% | Reference manual page: Surface_mesh_default_criteria.tex % | Reference manual page: Surface_mesh_default_criteria.tex
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
% | 08.12.2005 Author % | 08.12.2005 Mariette Yvinec, Laurent Rineau
% | Package: Package % | Package: Surface_mesher
% | ($ URL: $)
% | % |
\RCSdef{\RCSSurfacemeshdefaultcriteriaRev}{$Id$} \RCSdef{\RCSSurfacemeshdefaultcriteria3Rev}{$Id$}
\RCSdefDate{\RCSSurfacemeshdefaultcriteriaDate}{$Date$} \RCSdefDate{\RCSSurfacemeshdefaultcriteria3Date}{$Date$}
% | % |
%%RefPage: end of header, begin of main body %%RefPage: end of header, begin of main body
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
\begin{ccRefClass}{Surface_mesh_default_criteria_3<Tr>}
\begin{ccRefClass}{Surface_mesh_default_criteria<FT>} %% add template arg's if necessary
%% \ccHtmlCrossLink{} %% add further rules for cross referencing links
%% \ccHtmlIndexC[class]{} %% add further index entries
\ccDefinition \ccDefinition
@ -37,55 +34,31 @@ the sampling that have a Delaunay surface ball. \\
is the distance between the facet circumcenter and the is the distance between the facet circumcenter and the
center of its surface Delaunay ball. center of its surface Delaunay ball.
\ccInclude{CGAL/Surface_mesh_default_criteria_3.h}
\ccInclude{CGAL/Surface_mesh_default_criteria.h}
\ccIsModel \ccIsModel
\ccc{SurfaceMeshCriteria} \ccc{SurfaceMeshCriteria_3}
%\ccTypess \ccTypes
%\ccTypedef{FT}{some nested types} \ccTypedef{typedef Tr::FT FT;}{The numerical type.}
\ccCreation \ccCreation
\ccCreationVariable{criteria} %% choose variable name \ccCreationVariable{criteria}
\ccConstructor{Surface_mesh_default_criteria();}{Default constructor.} \ccConstructor{Surface_mesh_default_criteria_3(FT angle_bound,
\ccConstructor{Surface_mesh_default_criteria(FT angle_bound, FT radius_bound,
FT radius_bound
FT distance_bound);} FT distance_bound);}
{Returns a \ccRefName\ with \ccc{angle_bound}, \ccc{radius_bound}, {Returns a \ccRefName\ with \ccc{angle_bound}, \ccc{radius_bound},
\ccc{distance_bound} as bounds for the minimum facet angle, \ccc{distance_bound} as bounds for the minimum facet angle,
the radius of the surface Delaunay balls the radius of the surface Delaunay balls
and the center-center distances respectively.} and the center-center distances respectively.}
%\ccOperations
%\ccMethod{void foo();}{some member functions}
\ccSeeAlso \ccSeeAlso
\ccc{make_surface_mesh} \ccc{make_surface_mesh}
%\ccExample
%A short example program.
%Instead of a short program fragment, a full running program can be
%included using the
%\verb|\ccIncludeExampleCode{Package/Surface_mesh_default_criteria.C}|
%macro. The program example would be part of the source code distribution and
%also part of the automatic test suite.
%\begin{ccExampleCode}
%void your_example_code() {
%}
%\end{ccExampleCode}
%% \ccIncludeExampleCode{Package/Surface_mesh_default_criteria.C}
\end{ccRefClass} \end{ccRefClass}
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+

View File

@ -0,0 +1,90 @@
// Copyright (c) 2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $Source:
// $Revision: 1.9 $ $Date: 2005/12/01 10:30:11 $
// $Name: $
//
// Author(s) : Laurent RINEAU
#ifndef CGAL_IMPLICIT_SURFACE_3_H
#define CGAL_IMPLICIT_SURFACE_3_H
#include <CGAL/Surface_mesher/Oracles/Implicit_oracle.h>
namespace CGAL {
template<
typename GT,
typename Function
>
class Implicit_surface_3
{
public:
typedef GT Geom_traits;
typedef typename Geom_traits::Sphere_3 Sphere_3;
typedef typename Geom_traits::FT FT;
Implicit_surface_3(Function f,
const Sphere_3 bounding_sphere,
const FT error_bound)
: func(f),
sphere(bounding_sphere),
squared_error(error_bound*error_bound)
{
}
FT operator()(FT x, FT y, FT z)
{
return func(x, y, z);
}
const FT& squared_error_bound() const
{
return squared_error;
}
const Sphere_3& bounding_sphere() const
{
return sphere;
}
private:
Function func;
Sphere_3 sphere;
double squared_error;
}; // end Implicit_surface_3
template <typename GT, typename Function>
Implicit_surface_3<GT, Function>
make_implicit_surface_3(GT, Function f,
typename GT::Sphere_3 sphere,
typename GT::FT error_bound)
{
typedef Implicit_surface_3<GT, Function> surface;
return surface(f, sphere, error_bound);
}
template <typename GT, typename Function>
struct Surface_mesh_traits_generator_3<Implicit_surface_3<GT, Function> >
{
typedef Implicit_surface_3<GT, Function> Surface_type;
typedef typename Surface_mesher::Implicit_surface_oracle<GT,
Surface_type> type;
typedef type Type; // Boost meta-programming compatibility
};
} // end namespace CGAL
#endif // CGAL_IMPLICIT_SURFACE_3_H

View File

@ -0,0 +1,45 @@
// Copyright (c) 2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: svn+ssh://lrineau@scm.gforge.inria.fr/svn/cgal/trunk/Surface_mesher/include/CGAL/Complex_2_in_triangulation_3.h $
// $Id: Complex_2_in_triangulation_3.h 28848 2006-02-27 16:04:07Z lrineau $
//
//
// Author(s) : Laurent Rineau
#ifndef CGAL_SURFACE_MESH_COMPLEX_2_IN_TRIANGULATION_3_H
#define CGAL_SURFACE_MESH_COMPLEX_2_IN_TRIANGULATION_3_H
#include <CGAL/Complex_2_in_triangulation_3.h>
namespace CGAL {
/** Simple forward class for CGAL::Complex_2_in_triangulation_3<Tr>.
*
* CGAL::Surface_mesher_complex_2_in_triangulation_3<Tr> is an alias
* for CGAL::Complex_2_in_triangulation_3<Tr>.
*/
template <class Tr>
class Surface_mesh_complex_2_in_triangulation_3 :
public Complex_2_in_triangulation_3<Tr>
{
public:
Surface_mesh_complex_2_in_triangulation_3 (Tr& tr)
: Complex_2_in_triangulation_3<Tr>(tr)
{
}
}; // end Surface_mesh_complex_2_in_triangulation_3
} // end namespace CGAL
#endif // CGAL_SURFACE_MESH_COMPLEX_2_IN_TRIANGULATION_3_H

View File

@ -0,0 +1,84 @@
// Copyright (c) 2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $Source:
// $Revision: 1.1 $ $Date: 2005/12/12 16:20:58 $
// $Name: $
//
// Author(s) : Laurent Rineau
#ifndef CGAL_SURFACE_MESH_DEFAULT_CRITERIA_3_H
#define CGAL_SURFACE_MESH_DEFAULT_CRITERIA_3_H
#include <CGAL/Surface_mesher/Criteria/Standard_criteria.h>
namespace CGAL {
template <class Tr>
class Surface_mesh_default_criteria_3
{
typedef Surface_mesher::Refine_criterion<Tr> Criterion;
typedef Surface_mesher::Standard_criteria<Criterion> Criteria;
public:
typedef Tr Triangulation;
typedef typename Tr::Geom_traits::FT FT;
typedef typename Criteria::Quality Quality;
typedef typename Tr::Facet Facet;
Surface_mesh_default_criteria_3(const FT angle_bound,
const FT radius_bound,
const FT distance_bound)
: curvature_size_criterion(distance_bound),
uniform_size_criterion(radius_bound),
aspect_ratio_criterion(angle_bound)
{
criterion_vector.reserve(4);
criterion_vector.push_back (&aspect_ratio_criterion);
criterion_vector.push_back (&uniform_size_criterion);
criterion_vector.push_back (&curvature_size_criterion);
criteria.set_criteria(criterion_vector);
}
bool is_bad (const Facet& f)
{
return criteria.is_bad(f);
}
Quality quality(const Facet& f)
{
return criteria.quality(f);
}
private:
Surface_mesher::Curvature_size_criterion<Tr> curvature_size_criterion;
// bound on Hausdorff distance does not play any role if bigger than
// the square of the Uniform_size_criterion
Surface_mesher::Uniform_size_criterion<Tr> uniform_size_criterion;
// bound on radii of surface Delaunay balls
Surface_mesher::Aspect_ratio_criterion<Tr> aspect_ratio_criterion;
// lower bound on minimum angle in degrees
std::vector<Criterion*> criterion_vector;
Criteria criteria;
}; // end class Surface_mesh_default_criteria_3
} // end namespace CGAL
#endif // CGAL_SURFACE_MESH_DEFAULT_CRITERIA_3_H

View File

@ -0,0 +1,38 @@
// Copyright (c) 2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $Source:
// $Revision: 1.1 $ $Date: 2005/12/12 16:20:58 $
// $Name: $
//
// Author(s) : Laurent Rineau
#ifndef CGAL_SURFACE_MESH_TRAITS_GENERATOR_3_H
#define CGAL_SURFACE_MESH_TRAITS_GENERATOR_3_H
namespace CGAL {
/** Defaut traits class.
* Partial specialization will be in other headers
*/
template <typename Surface>
struct Surface_mesh_traits_generator_3
{
typedef typename Surface::Surface_mesher_traits_3 Type;
typedef Type type; // for Boost compatiblity (meta-programming)
};
} // end namespace CGAL
#endif // CGAL_SURFACE_MESH_TRAITS_GENERATOR_3_H

View File

@ -0,0 +1,42 @@
// Copyright (c) 2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $Source:
// $Revision: 1.1 $ $Date: 2005/12/12 16:20:58 $
// $Name: $
//
// Author(s) : Laurent Rineau
#ifndef CGAL_SURFACE_MESH_TRIANGULATION_GENERATOR_3_H
#define CGAL_SURFACE_MESH_TRIANGULATION_GENERATOR_3_H
#ifndef CGAL_SURFACE_MESHER_TEST
# warning This header is not documented.
#endif
namespace CGAL {
template <class Kernel>
class Surface_mesh_triangulation_generator_3
{
typedef CGAL::Surface_mesh_vertex_base_3<Kernel> Vb;
typedef CGAL::Surface_mesh_cell_base_3<Kernel> Cb;
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> Tds;
public:
typedef CGAL::Delaunay_triangulation_3<Kernel, Tds> Type;
typedef Type type; // Boost meta-programming compatibility
};
} // end namespace CGAL
#endif // CGAL_SURFACE_MESH_TRIANGULATION_GENERATOR_3_H

View File

@ -42,7 +42,13 @@ namespace CGAL {
typedef typename Criterion::Facet Facet; typedef typename Criterion::Facet Facet;
typedef std::vector<FT> Quality; typedef std::vector<FT> Quality;
Standard_criteria (Criteria& c) : criteria (c) {} Standard_criteria() {};
Standard_criteria (const Criteria& c) : criteria (c) {}
void set_criteria(const Criteria& c)
{
criteria = c;
}
bool is_bad (const Facet& f) { bool is_bad (const Facet& f) {
for (typename Criteria::iterator cit = criteria.begin(); cit != for (typename Criteria::iterator cit = criteria.begin(); cit !=
@ -94,7 +100,7 @@ namespace CGAL {
public: public:
// Nb: the default bound of the criterion is such that the criterion // Nb: the default bound of the criterion is such that the criterion
// is always fulfilled // is always fulfilled
Aspect_ratio_criterion(const int angle_min = 0, bool dbg = false) : Aspect_ratio_criterion(const double angle_min = 0., bool dbg = false) :
debug (dbg) { debug (dbg) {
if (debug) if (debug)
std::cerr << "angle min = " << angle_min << " degrees\n"; std::cerr << "angle min = " << angle_min << " degrees\n";
@ -104,11 +110,11 @@ namespace CGAL {
std::cerr << "B = " << B << std::endl; std::cerr << "B = " << B << std::endl;
} }
Aspect_ratio_criterion(const Quality b, bool dbg = false) : // Aspect_ratio_criterion(const Quality b, bool dbg = false) :
debug (dbg), B (b) { // debug (dbg), B (b) {
if (debug) // if (debug)
std::cerr << "B = " << B << std::endl; // std::cerr << "B = " << B << std::endl;
} // }
inline inline

View File

@ -30,73 +30,49 @@ namespace CGAL {
namespace Surface_mesher { namespace Surface_mesher {
template < class GT, template <
class Function, class GT,
class Visitor = Null_oracle_visitor, class Surface,
class Point_creator = class Point_creator = Creator_uniform_3<typename GT::RT,
Creator_uniform_3<typename GT::RT, typename GT::Point_3>,
typename GT::Point_3> > class Visitor = Null_oracle_visitor
>
class Implicit_surface_oracle class Implicit_surface_oracle
{ {
public: // private types
// Public types typedef Implicit_surface_oracle<GT, Surface, Point_creator, Visitor> Self;
typedef GT Geom_traits;
typedef typename GT::Point_3 Point; typedef typename GT::Point_3 Point;
typedef typename Kernel_traits<Point>::Kernel::Point_3 Kernel_point; typedef typename Kernel_traits<Point>::Kernel::Point_3 Kernel_point;
typedef typename GT::Segment_3 Segment;
typedef typename GT::Ray_3 Ray;
typedef typename GT::Line_3 Line;
typedef typename GT::FT FT; typedef typename GT::FT FT;
typedef typename Surface::Sphere_3 Sphere_3;
public:
// Public types
typedef GT Geom_traits;
typedef typename GT::Point_3 Point_3;
typedef typename GT::Segment_3 Segment_3;
typedef typename GT::Ray_3 Ray_3;
typedef typename GT::Line_3 Line_3;
typedef Surface Surface_3;
private: private:
// Private members // Private members
Function& func;
Point center; // center of bounding ball
FT radius; // radius of bounding ball
FT min_squared_length; // minimal length of a segment for
// detecting intersections with surface
bool parity_oracle; // flag that tells whether the surface has no boundary bool parity_oracle; // flag that tells whether the surface has no boundary
bool debug; // flag for debug mode Visitor visitor; // a visitor that can modify a point, before returning it.
Visitor visitor;
public: public:
// Constructors // Constructors
Implicit_surface_oracle (Function& f, Implicit_surface_oracle (bool parity = false,
Point emb_center,
FT emb_radius,
FT precision,
bool parity = false,
bool dbg = false,
Visitor visitor_ = Visitor() ) : Visitor visitor_ = Visitor() ) :
func (f),
center (emb_center),
radius (emb_radius),
min_squared_length (precision * precision),
parity_oracle (parity), parity_oracle (parity),
debug (dbg),
visitor(visitor_) visitor(visitor_)
{} {}
//Public Queries
Point get_center() {
return center;
}
FT get_radius() {
return radius;
}
FT get_precision() {
return CGAL::sqrt (min_squared_length);
}
// Predicates and Constructions // Predicates and Constructions
bool is_in_volume(const Point& p) bool is_in_volume(const Point& p)
@ -104,58 +80,69 @@ namespace CGAL {
return surf_equation(p)<0.; return surf_equation(p)<0.;
} }
Object intersect_segment_surface(Segment s) class Intersect_3
{
Self& oracle;
public:
Intersect_3(Self& oracle) : oracle(oracle)
{
}
Object operator()(const Surface_3& surface, Segment_3 s) const
// s is passed by value, because it is used in a CGAL::assign below. // s is passed by value, because it is used in a CGAL::assign below.
{ {
GT ker; GT ker;
// First rescale segment if necessary // First rescale segment if necessary
Object obj=rescale_seg_bounding_sphere(s); Object obj=oracle.rescale_seg_bounding_sphere(surface, s);
if (!assign(s,obj)) if (!assign(s,obj))
return Object(); return Object();
// ATTENTION: optimization for closed surfaces: if both // ATTENTION: optimization for closed surfaces: if both
// extremities are on the same side of the surface, return no // extremities are on the same side of the surface, return no
// intersection // intersection
if(parity_oracle && if(oracle.parity_oracle &&
(surf_equation(s.source()) * surf_equation(s.target())>0)) (surf_equation(surface, s.source()) *
surf_equation(surface, s.target())>0))
return Object(); return Object();
// Code for surfaces with boundaries // Code for surfaces with boundaries
std::list<Segment> f; std::list<Segment_3> f;
f.push_back(s); f.push_back(s);
while(!f.empty()) { while(!f.empty()) {
const Segment sf = f.front(); const Segment_3 sf = f.front();
f.pop_front(); f.pop_front();
const Point& p1 = sf.source(); const Point& p1 = sf.source();
const Point& p2 = sf.target(); const Point& p2 = sf.target();
if (surf_equation(p1) * surf_equation(p2) < 0) { if (surf_equation(surface, p1) * surf_equation(surface, p2) < 0) {
return intersect_segment_surface_rec(p1,p2); return oracle.intersect_segment_surface_rec(surface, p1, p2);
} }
if (ker.compute_squared_distance_3_object() if (ker.compute_squared_distance_3_object()
(p1,p2) >= min_squared_length) (p1,p2) >= surface.squared_error_bound())
{ {
Point mid=ker.construct_midpoint_3_object()(p1,p2); Point mid=ker.construct_midpoint_3_object()(p1,p2);
f.push_back(Segment(p1,mid)); f.push_back(Segment_3(p1,mid));
f.push_back(Segment(mid,p2)); f.push_back(Segment_3(mid,p2));
} }
} }
return Object(); return Object();
} } // end operator()(Surface_3, Segment_3)
Object operator()(const Surface_3& surface, const Ray_3& r) const {
Object intersect_ray_surface(const Ray& r) {
GT ker; GT ker;
Point p1,p2; Point p1,p2;
const Sphere_3& sphere = surface.bounding_sphere();
const Point center = ker.construct_center_3_object()(sphere);
const FT squared_radius =
ker.construct_squared_radius_3_object()(sphere);
p1=r.point(0); p1=r.point(0);
// The second point is calculated with the radius of the bounding ball // The second point is calculated with the radius of the bounding ball
@ -163,19 +150,23 @@ namespace CGAL {
ker.construct_scaled_vector_3_object() ker.construct_scaled_vector_3_object()
(ker.construct_vector_3_object() (ker.construct_vector_3_object()
(p1,r.point(1)), (p1,r.point(1)),
2*approximate_sqrt(std::max(radius*radius,approximate_sqrt 2*approximate_sqrt(std::max(squared_radius,approximate_sqrt
(ker.compute_squared_distance_3_object() (ker.compute_squared_distance_3_object()
(center,p1))) / (center,p1))) /
ker.compute_squared_distance_3_object()(p1,r.point(1)))); ker.compute_squared_distance_3_object()(p1,r.point(1))));
return(intersect_segment_surface(Segment(p1,p2))); return( operator()(surface, Segment_3(p1,p2)) );
} } // end operator()(Surface_3, Ray_3)
Object operator()(const Surface_3& surface, const Line_3& l) const {
Object intersect_line_surface(const Line& l) {
GT ker; GT ker;
const Sphere_3& sphere = surface.bounding_sphere();
const Point center = ker.construct_center_3_object()(sphere);
const FT squared_radius =
ker.compute_squared_radius_3_object()(sphere);
Point p1=l.point(0); Point p1=l.point(0);
Point p2=l.point(1); Point p2=l.point(1);
@ -185,7 +176,7 @@ namespace CGAL {
ker.construct_scaled_vector_3_object() ker.construct_scaled_vector_3_object()
(ker.construct_vector_3_object() (ker.construct_vector_3_object()
(p1,p2), (p1,p2),
2*approximate_sqrt(std::max(radius*radius,approximate_sqrt 2*approximate_sqrt(std::max(squared_radius,approximate_sqrt
(ker.compute_squared_distance_3_object() (ker.compute_squared_distance_3_object()
(center,p1))) / (center,p1))) /
ker.compute_squared_distance_3_object()(p1,p2))); ker.compute_squared_distance_3_object()(p1,p2)));
@ -194,40 +185,58 @@ namespace CGAL {
ker.construct_scaled_vector_3_object() ker.construct_scaled_vector_3_object()
(ker.construct_vector_3_object() (ker.construct_vector_3_object()
(p2,p1), (p2,p1),
2*approximate_sqrt(std::max(radius*radius,approximate_sqrt 2*approximate_sqrt(std::max(squared_radius,approximate_sqrt
(ker.compute_squared_distance_3_object() (ker.compute_squared_distance_3_object()
(center,p1))) / (center,p1))) /
ker.compute_squared_distance_3_object()(p1,p2))); ker.compute_squared_distance_3_object()(p1,p2)));
Object result_temp = intersect_segment_surface(Segment(p1,p3)); Object result_temp = operator()(surface, Segment_3(p1,p3));
Point result; Point result;
if (assign(result,result_temp)) if (assign(result,result_temp))
return result_temp; return result_temp;
else else
return(intersect_segment_surface(Segment(p1,p4))); return( operator()(surface, Segment_3(p1,p4)) );
} // end operator()(Surface_3, Line_3)
}; // end nested class Intersect_3
class Construct_initial_points
{
Self& oracle;
public:
Construct_initial_points(Self& oracle) : oracle(oracle)
{
} }
// Random points // Random points
template <typename OutputIteratorPoints> template <typename OutputIteratorPoints>
OutputIteratorPoints initial_points (OutputIteratorPoints out, OutputIteratorPoints operator() (const Surface_3& surface,
OutputIteratorPoints out,
int n = 20) // WARNING: why 20? int n = 20) // WARNING: why 20?
{ {
CGAL_precondition (n > 0); CGAL_precondition (n > 0);
GT geom_traits;
const Sphere_3& sphere = surface.bounding_sphere();
const Point center =
geom_traits.construct_center_3_object()(sphere);
const FT squared_radius =
geom_traits.compute_squared_radius_3_object()(sphere);
const FT radius = CGAL::sqrt(squared_radius);
typename CGAL::Random_points_in_sphere_3<Point, typename CGAL::Random_points_in_sphere_3<Point,
Point_creator> random_point_in_sphere(radius); Point_creator> random_point_in_sphere(radius);
typename GT::Construct_line_3 line_3 = typename GT::Construct_line_3 line_3 =
GT().construct_line_3_object(); geom_traits.construct_line_3_object();
typename GT::Construct_vector_3 vector_3 = typename GT::Construct_vector_3 vector_3 =
GT().construct_vector_3_object(); geom_traits.construct_vector_3_object();
typename GT::Construct_translated_point_3 translate = typename GT::Construct_translated_point_3 translate =
GT().construct_translated_point_3_object(); geom_traits.construct_translated_point_3_object();
// the exhaustive oracle is used // the exhaustive oracle is used
bool save_parity = parity_oracle; bool save_parity = oracle.parity_oracle;
// parity_oracle = false; // !! WHY?? // parity_oracle = false; // !! WHY??
while (n>0) { while (n>0) {
@ -236,7 +245,7 @@ namespace CGAL {
Point p2 = translate(*random_point_in_sphere++, Point p2 = translate(*random_point_in_sphere++,
vector_3(CGAL::ORIGIN, center)); vector_3(CGAL::ORIGIN, center));
Object o = intersect_line_surface (line_3 (p1,p2)); Object o = oracle.intersect_3_object()(surface, line_3(p1,p2));
Point p; Point p;
if (assign(p,o)) { if (assign(p,o)) {
*out++= p; *out++= p;
@ -245,33 +254,44 @@ namespace CGAL {
} }
// We restore the user-defined oracle // We restore the user-defined oracle
parity_oracle = save_parity; oracle.parity_oracle = save_parity;
return out; return out;
} }
}; // end nested class Construct_initial_points
Construct_initial_points construct_initial_points_object()
{
return Construct_initial_points(*this);
}
Intersect_3 intersect_3_object()
{
return Intersect_3(*this);
}
private: private:
// Private functions // Private functions
Object intersect_segment_surface_rec(Point p1, Point p2) { Object intersect_segment_surface_rec(const Surface_3& surface,
Point p1,
Point p2) {
GT ker; GT ker;
while(true){ while(true){
Point mid = ker.construct_midpoint_3_object()(p1,p2); Point mid = ker.construct_midpoint_3_object()(p1,p2);
// If the two points are close, then we must decide // If the two points are close, then we must decide
if (ker.compute_squared_distance_3_object() if (ker.compute_squared_distance_3_object()
(p1,p2) < min_squared_length) (p1,p2) < surface.squared_error_bound())
{ {
visitor.new_point(mid); visitor.new_point(mid);
return make_object(mid); return make_object(mid);
} }
// Else we must go on // Else we must go on
if (surf_equation(p1) * surf_equation(mid) < 0) if (surf_equation(surface, p1) * surf_equation(surface, mid) < 0)
p2 = mid; p2 = mid;
else else
p1 = mid; p1 = mid;
@ -279,22 +299,29 @@ namespace CGAL {
} }
private: private:
double surf_equation (const Point& p) { static double surf_equation (Surface_3 surface, Point p) {
return func(p.x(), p.y(), p.z()); return surface(p.x(), p.y(), p.z());
} // @WARNING: we use x(), y() and z() } // @WARNING: we use x(), y() and z()
private: private:
// Rescale segment according to bounding sphere // Rescale segment according to bounding sphere
Object rescale_seg_bounding_sphere(const Segment& s) Object rescale_seg_bounding_sphere(const Surface_3& surface,
const Segment_3& s)
{ {
GT ker; GT ker;
const Sphere_3& sphere = surface.bounding_sphere();
const Point center = ker.construct_center_3_object()(sphere);
const FT squared_radius =
ker.compute_squared_radius_3_object()(sphere);
const FT radius = CGAL::sqrt(squared_radius);
Point p1=s.source(); Point p1=s.source();
Point p2=s.target(); Point p2=s.target();
// If both points are too far away from each other, then replace them // If both points are too far away from each other, then replace them
if (ker.compute_squared_distance_3_object()(p1,p2) > if (ker.compute_squared_distance_3_object()(p1,p2) >
17*radius*radius) 17*squared_radius)
{ {
// cerr << "[" << p1 << "," << p2 << "] -> ["; // cerr << "[" << p1 << "," << p2 << "] -> [";
@ -302,7 +329,7 @@ namespace CGAL {
// If p1 is in the sphere, then replace p2 // If p1 is in the sphere, then replace p2
if (ker.compute_squared_distance_3_object()(center,p1) if (ker.compute_squared_distance_3_object()(center,p1)
<= radius*radius) <= squared_radius)
p2=p1 + p2=p1 +
ker.construct_scaled_vector_3_object() ker.construct_scaled_vector_3_object()
(ker.construct_vector_3_object()(p1,p2), (ker.construct_vector_3_object()(p1,p2),
@ -311,7 +338,7 @@ namespace CGAL {
// If p2 is in the sphere, then replace p1 // If p2 is in the sphere, then replace p1
else if (ker.compute_squared_distance_3_object()(center,p2) else if (ker.compute_squared_distance_3_object()(center,p2)
<= radius*radius) <= squared_radius)
p1=p2 + p1=p2 +
ker.construct_scaled_vector_3_object() ker.construct_scaled_vector_3_object()
(ker.construct_vector_3_object()(p2,p1), (ker.construct_vector_3_object()(p2,p1),
@ -322,7 +349,7 @@ namespace CGAL {
else else
{ {
// First find a point on [p1,p2] in the sphere // First find a point on [p1,p2] in the sphere
Object obj = intersect_segment_sphere(p1, p2); Object obj = intersect_segment_sphere(surface, p1, p2);
// If no point is found, then return // If no point is found, then return
Kernel_point mid; Kernel_point mid;
@ -350,14 +377,20 @@ namespace CGAL {
} }
return(make_object(Segment(p1,p2))); return(make_object(Segment_3(p1,p2)));
} }
Object intersect_segment_sphere Object intersect_segment_sphere(const Surface_3& surface,
(const Point& a, const Point& b) { const Point& a,
const Point& b) {
FT cosine, deltaprime, root1, root2; FT cosine, deltaprime, root1, root2;
GT ker; GT ker;
const Sphere_3& sphere = surface.bounding_sphere();
const Point center = ker.construct_center_3_object()(sphere);
const FT squared_radius =
ker.compute_squared_radius_3_object()(sphere);
// Compute the squared cosine of angle ([a,center),[a,b)) // Compute the squared cosine of angle ([a,center),[a,b))
cosine=(center-a)*(b-a); cosine=(center-a)*(b-a);
cosine=cosine*cosine / cosine=cosine*cosine /
@ -369,7 +402,7 @@ namespace CGAL {
ker.compute_squared_distance_3_object()(a,b) * ker.compute_squared_distance_3_object()(a,b) *
((cosine-1)* ((cosine-1)*
ker.compute_squared_distance_3_object()(a,center) ker.compute_squared_distance_3_object()(a,center)
+ radius*radius); + squared_radius);
// cerr << endl << " -> discriminant=" << deltaprime << endl; // cerr << endl << " -> discriminant=" << deltaprime << endl;
@ -398,14 +431,12 @@ namespace CGAL {
else else
return Object(); return Object();
} }
}; // end Implicit_surface_oracle
// Private methods template <typename FT>
private:
FT approximate_sqrt(const FT x) { FT approximate_sqrt(const FT x) {
return FT (CGAL_NTS sqrt(CGAL_NTS to_double(x))); return FT (CGAL_NTS sqrt(CGAL_NTS to_double(x)));
} }
}; // end Implicit_surface_oracle
} // namespace Surface_mesher } // namespace Surface_mesher

View File

@ -15,7 +15,11 @@
// $Id$ // $Id$
// //
// //
// Author(s) : Steve Oudot, David Rey, Mariette Yvinec, Laurent Rineau, Andreas Fabri // Author(s) : Steve Oudot,
// David Rey,
// Mariette Yvinec,
// Laurent Rineau,
// Andreas Fabri
@ -23,7 +27,7 @@
#define CGAL_SURFACE_MESHER_SURFACE_MESHER_H #define CGAL_SURFACE_MESHER_SURFACE_MESHER_H
#include <CGAL/Mesher_level.h> #include <CGAL/Mesher_level.h>
#include <CGAL/Mesh_3/Triangulation_mesher_level_traits_3.h> #include <CGAL/Mesh_2/Triangulation_mesher_level_traits_3.h>
#include <CGAL/Double_map.h> #include <CGAL/Double_map.h>
#include <CGAL/Complex_2_in_triangulation_3.h> #include <CGAL/Complex_2_in_triangulation_3.h>
@ -37,13 +41,14 @@ namespace CGAL {
template < template <
class C2T3, class C2T3,
class Surface, class Surface,
class SurfaceMeshTraits,
class Criteria class Criteria
> >
class Surface_mesher_base class Surface_mesher_base
: public Triangulation_mesher_level_traits_3<typename C2T3::Triangulation> : public Triangulation_mesher_level_traits_3<typename C2T3::Triangulation_3>
{ {
public: public:
typedef typename C2T3::Triangulation Tr; typedef typename C2T3::Triangulation_3 Tr;
typedef typename Tr::Point Point; typedef typename Tr::Point Point;
typedef typename Tr::Edge Edge; typedef typename Tr::Edge Edge;
typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Vertex_handle Vertex_handle;
@ -51,6 +56,8 @@ namespace CGAL {
typedef typename Tr::Geom_traits GT; typedef typename Tr::Geom_traits GT;
typedef SurfaceMeshTraits Surface_mesh_traits;
typedef Triangulation_mesher_level_traits_3<Tr> Triangulation_traits; typedef Triangulation_mesher_level_traits_3<Tr> Triangulation_traits;
typedef typename Triangulation_traits::Zone Zone; typedef typename Triangulation_traits::Zone Zone;
@ -63,11 +70,15 @@ namespace CGAL {
typedef Double_map<Facet, Quality> Bad_facets; typedef Double_map<Facet, Quality> Bad_facets;
// Constructor // Constructor
Surface_mesher_base (C2T3& co, Surface& s, Criteria& c) : Surface_mesher_base (C2T3& co,
Surface& s,
Surface_mesh_traits mesh_traits,
Criteria& c) :
Triangulation_mesher_level_traits_3<Tr>(co.triangulation()), Triangulation_mesher_level_traits_3<Tr>(co.triangulation()),
c2t3(co), c2t3(co),
tr(co.triangulation()), tr(co.triangulation()),
surf(s), surf(s),
meshtraits(mesh_traits),
criteria(c) criteria(c)
{ {
} }
@ -76,8 +87,9 @@ namespace CGAL {
C2T3& c2t3; C2T3& c2t3;
Tr& tr; // Associated triangulation reference Tr& tr; // Associated triangulation reference
Surface& surf; // Surface Surface& surf; // Surface
Bad_facets facets_to_refine; // Set of facets to refine Surface_mesh_traits meshtraits; // Surface mesh traits
Criteria& criteria; // Meshing criteria Criteria& criteria; // Meshing criteria
Bad_facets facets_to_refine; // Set of facets to refine
public: public:
@ -495,9 +507,8 @@ namespace CGAL {
// Tests whether a given facet is restricted or not // Tests whether a given facet is restricted or not
bool is_facet_on_surface(const Facet& f, Point& center, bool is_facet_on_surface(const Facet& f, Point& center,
const bool check_visits = false) { const bool check_visits = false) {
typename GT::Segment_3 s; typedef typename Surface_mesh_traits::Intersect_3 Intersect_3;
typename GT::Ray_3 r; Intersect_3 intersect = meshtraits.intersect_3_object();
typename GT::Line_3 l;
if (check_visits) { if (check_visits) {
const Cell_handle& c = f.first; const Cell_handle& c = f.first;
@ -510,28 +521,31 @@ namespace CGAL {
other_side.first->set_facet_visited(other_side.second); other_side.first->set_facet_visited(other_side.second);
} }
Object dual = tr.dual(f);
Object dual, intersection; // typename GT::Segment_3 segment;
dual = tr.dual(f); typename GT::Segment_3 segment;
typename GT::Ray_3 ray;
typename GT::Line_3 line;
// If the dual is a segment // If the dual is a segment
if (assign(s,dual)) { if (assign(segment, dual)) {
intersection = surf.intersect_segment_surface(s); Object intersection = intersect(surf, segment);
if (assign(center,intersection)) if (assign(center,intersection))
return true; return true;
} }
// If the dual is a ray // If the dual is a ray
else if(assign(r,dual)) { else if(assign(ray, dual)) {
intersection = surf.intersect_ray_surface(r); Object intersection = intersect(surf, ray);
//std::cerr << "intersection: " << std::endl; //std::cerr << "intersection: " << std::endl;
if (assign(center,intersection)) if (assign(center,intersection))
return true; return true;
} }
// If the dual is a line // If the dual is a line
else if(assign(l,dual)) { else if(assign(line, dual)) {
intersection = surf.intersect_line_surface(l); Object intersection = intersect(surf, line);
if (assign(center,intersection)) if (assign(center,intersection))
return true; return true;
} }
@ -596,22 +610,23 @@ namespace CGAL {
template < template <
typename C2T3, typename C2T3,
typename Surface, typename Surface,
typename SurfaceMeshTraits,
typename Criteria, typename Criteria,
typename Base = Surface_mesher_base<C2T3, Surface, Criteria> typename Base = Surface_mesher_base<C2T3, Surface, SurfaceMeshTraits, Criteria>
> >
struct Surface_mesher struct Surface_mesher
: public Base, : public Base,
public Mesher_level < public Mesher_level <
C2T3::Triangulation, typename C2T3::Triangulation_3,
Surface_mesher<C2T3::Triangulation, Surface, Criteria, Base>, Surface_mesher<C2T3, Surface, SurfaceMeshTraits, Criteria, Base>,
typename C2T3::Triangulation::Facet, typename C2T3::Triangulation_3::Facet,
Null_mesher_level, Null_mesher_level,
Triangulation_mesher_level_traits_3<C2T3::Triangulation> Triangulation_mesher_level_traits_3<typename C2T3::Triangulation_3>
> >
{ {
public: public:
typedef typename C2T3::Triangulation Tr; typedef typename C2T3::Triangulation_3 Tr;
typedef Surface_mesher<C2T3, Surface, Criteria, Base> Self; typedef Surface_mesher<C2T3, Surface, SurfaceMeshTraits, Criteria, Base> Self;
typedef Mesher_level < typedef Mesher_level <
Tr, Tr,
Self, Self,
@ -627,6 +642,7 @@ namespace CGAL {
using Base::check_restricted_delaunay; using Base::check_restricted_delaunay;
typedef C2T3 Complex_2_in_triangulation_3; typedef C2T3 Complex_2_in_triangulation_3;
typedef SurfaceMeshTraits Surface_mesh_traits;
private: private:
Null_mesher_level null_mesher_level; Null_mesher_level null_mesher_level;
@ -634,8 +650,11 @@ namespace CGAL {
bool initialized; bool initialized;
public: public:
Surface_mesher(C2T3& co, Surface& s, Criteria& c): Surface_mesher(C2T3& c2t3,
Base(co, s, c), Surface& surface,
Surface_mesh_traits mesh_traits,
Criteria& criteria):
Base(c2t3, surface, mesh_traits, criteria),
Mesher_lvl(null_mesher_level), Mesher_lvl(null_mesher_level),
initialized(false) initialized(false)
{} {}

View File

@ -81,7 +81,7 @@ namespace CGAL {
Vertex_handle v = c->vertex(j); Vertex_handle v = c->vertex(j);
if(bad_vertices_initialized){ if(bad_vertices_initialized){
if ( SMREB::c2t3.is_in_complex(v) ) { if ( SMREB::c2t3.is_in_complex(v) ) { // no need to test here
bad_vertices.erase(v); bad_vertices.erase(v);
} }
} }
@ -194,7 +194,12 @@ namespace CGAL {
for (typename Zone::Facets_iterator fit = for (typename Zone::Facets_iterator fit =
zone.boundary_facets.begin(); fit != zone.boundary_facets.begin(); fit !=
zone.boundary_facets.end(); ++fit) zone.boundary_facets.end(); ++fit)
handle_facet_on_boundary_of_conflict_zone (*fit); handle_facet_on_boundary_of_conflict_zone (*fit); // @TODO: test
// if *fit is
// in complex,
// before
// calling the
// handle function
SMREB::before_insertion_impl(Facet(), s, zone); SMREB::before_insertion_impl(Facet(), s, zone);
} }

View File

@ -20,11 +20,17 @@
#ifndef CGAL_MAKE_SURFACE_MESH_H #ifndef CGAL_MAKE_SURFACE_MESH_H
#define CGAL_MAKE_SURFACE_MESH_H #define CGAL_MAKE_SURFACE_MESH_H
#include <CGAL/Surface_mesher/Surface_mesher.h #include <CGAL/Surface_mesher/Surface_mesher.h>
#include <CGAL/Surface_mesh_traits_3_generator.h> #include <CGAL/Surface_mesh_traits_generator_3.h>
#include <CGAL/iterator.h> // CGAL::inserter()
namespace CGAL { namespace CGAL {
struct Non_manifold_tag {};
struct Manifold_tag {};
struct Manifold_with_boundary_tag {};
template <typename C2T3, template <typename C2T3,
typename Surface, typename Surface,
typename Criteria, typename Criteria,
@ -34,9 +40,9 @@ void make_surface_mesh(C2T3& c2t3,
Criteria criteria, Criteria criteria,
Tag tag = Non_manifold_tag() ) Tag tag = Non_manifold_tag() )
{ {
typedef typename CGAL::Surface_mesh_traits_3_generator<Surface>::type Traits; typedef typename CGAL::Surface_mesh_traits_generator_3<Surface>::type Traits;
make_surface_mesh(c2t3, surface, criteria, Traits(), tag); make_surface_mesh(c2t3, surface, Traits(), criteria, tag);
} }
template <typename C2T3, template <typename C2T3,
@ -44,21 +50,26 @@ template <typename C2T3,
typename Criteria> typename Criteria>
void make_surface_mesh(C2T3& c2t3, void make_surface_mesh(C2T3& c2t3,
typename SurfaceMeshTraits_3::Surface_3 surface, typename SurfaceMeshTraits_3::Surface_3 surface,
Criteria criteria,
SurfaceMeshTraits_3 traits, SurfaceMeshTraits_3 traits,
Criteria criteria,
Non_manifold_tag) Non_manifold_tag)
{ {
using namespace CGAL::Surface_mesher; using CGAL::Surface_mesher::Surface_mesher;
typedef Surface_mesher< typedef Surface_mesher<
C2T3,
typename SurfaceMeshTraits_3::Surface_3, typename SurfaceMeshTraits_3::Surface_3,
Criteria, SurfaceMeshTraits_3,
C2T3> Mesher; Criteria> Mesher;
Mesher mesher(c2t3, surface, criteria, traits); typename SurfaceMeshTraits_3::Construct_initial_points get_initial_points =
traits.construct_initial_points_object();
get_initial_points(surface, CGAL::inserter(c2t3.triangulation()));
Mesher mesher(c2t3, surface, traits, criteria);
// TODO initial, then refine() // TODO initial, then refine()
} }
} // end namespace CGAL } // end namespace CGAL
#endif CGAL_MAKE_SURFACE_MESH_H #endif // CGAL_MAKE_SURFACE_MESH_H

View File

@ -13,12 +13,13 @@ include $(CGAL_MAKEFILE)
# compiler flags # compiler flags
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
CXXFLAGS = \ CXXFLAGS = -I ../../../Mesh_2/include \
-I../../include \ -I../../include \
$(TESTSUITE_CXXFLAGS) \ $(TESTSUITE_CXXFLAGS) \
$(EXTRA_FLAGS) \ $(EXTRA_FLAGS) \
$(CGAL_CXXFLAGS) \ $(CGAL_CXXFLAGS) \
$(LONG_NAME_PROBLEM_CXXFLAGS) $(LONG_NAME_PROBLEM_CXXFLAGS) \
$(OTHER_CXXFLAGS)
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
# linker flags # linker flags

View File

@ -2,119 +2,50 @@
#include <CGAL/Surface_mesh_cell_base_3.h> #include <CGAL/Surface_mesh_cell_base_3.h>
#include <CGAL/Surface_mesh_vertex_base_3.h> #include <CGAL/Surface_mesh_vertex_base_3.h>
#include <CGAL/Delaunay_triangulation_3.h> #include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Surface_mesher/Surface_mesher.h> #include <CGAL/Surface_mesh_complex_2_in_triangulation_3.h>
// #include <CGAL/Surface_mesher/Surface_mesher_regular_edges.h> #include <CGAL/make_surface_mesh.h>
// #include <CGAL/Surface_mesher/Surface_mesher_regular_edges_without_boundary.h>
// #include <CGAL/Surface_mesher/Surface_mesher_manifold.h>
#include <CGAL/Surface_mesher/Criteria/Standard_criteria.h>
#include <CGAL/IO/Complex_2_in_triangulation_3_file_writer.h>
#ifndef SURFACE_MESHER_POLYHEDRAL #define CGAL_SURFACE_MESHER_TEST 1
# include <CGAL/Implicit_surface_oracle.h> #include <CGAL/Surface_mesh_triangulation_generator_3.h> // undocumented
# include "implicit_function.h"
#else // IMPLICIT
# include <CGAL/Surface_mesher/Oracles/Polyhedral.h>
#endif
#include <fstream> #include <CGAL/Surface_mesh_default_criteria_3.h>
#include <CGAL/Implicit_surface_3.h>
// triangulation type generator: Kernel -> Tr #include <iostream>
templace <class Kernel>
class Surface_mesh_Delaunay_triangulation_generator {
typedef CGAL::Surface_mesh_vertex_base_3<K> Vb;
typedef CGAL::Surface_mesh_cell_base_3<K> Cb;
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> Tds;
public:
typedef CGAL::Delaunay_triangulation_3<K, Tds> Type;
typedef Type type;
};
double sphere(double x, double y, double z)
{
return x*x+y*y+z*z-1.;
}
struct Kernel : public CGAL::Exact_predicates_inexact_constructions_kernel {};
typedef CGAL::Surface_mesh_triangulation_generator_3<Kernel>::Type Tr;
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<Tr> C2T3;
// Oracle typedef Kernel::Sphere_3 Sphere_3;
#ifndef SURFACE_MESHER_POLYHEDRAL
typedef Function <K::FT> Func;
typedef CGAL::Implicit_surface_oracle<K, Func> Oracle;
#else
typedef CGAL::Surface_mesher::Polyhedral <Tr> Oracle;
#endif
typedef CGAL::Surface_mesher::Refine_criterion<Tr> Criterion; using CGAL::make_surface_mesh;
typedef CGAL::Surface_mesher::Standard_criteria <Criterion > Criteria;
typedef CGAL::Surface_mesher::Surface_mesher<Tr, Oracle, Criteria> SM;
// typedef CGAL::Surface_mesher::Surface_mesher_regular_edges<Tr, Oracle, Criteria> SMRE;
// typedef CGAL::Surface_mesher::Surface_mesher_regular_edges_without_boundary<Tr, Oracle, Criteria> SMREWB;
// typedef CGAL::Surface_mesher::Surface_mesher_manifold<Tr, Oracle, Criteria> SMM;
// typedef CGAL::Surface_mesher::Surface_mesher_regular_edges_without_boundary_base<Tr, Oracle, Criteria> SMREWBB;
// typedef CGAL::Surface_mesher::Surface_mesher_manifold<Tr, Oracle, Criteria,
// CGAL::Surface_mesher::Surface_mesher_manifold_base <Tr, Oracle, Criteria, SMREWBB>
// > SMMWB;
typedef SM Surface; // basic mesher
//typedef SMM Surface; // manifold with boundary
// typedef SMMWB Surface; // manifold without boundary
// typedef SMRE Surface; // only regular edges
//typedef SMREWB Surface; // only regular edges, without boundary
/////////////// Main function ///////////////
int main(int argc, char **argv) { int main(int argc, char **argv) {
Func F;
Oracle O (F, K::Point_3 (0,0,0), 6, 1e-6, true); // parity oracle
// toggled
// 3D-Delaunay triangulation
Tr tr; Tr tr;
// Initial point sample CGAL::Surface_mesh_default_criteria_3<Tr> criteria(30., 0.05, 0.01);
O.initial_points (CGAL::inserter(tr), 30);
// Meshing criteria
CGAL::Surface_mesher::Curvature_size_criterion<Tr> c_s_crit (10000);
// bound on Hausdorff distance
// does not play any role if
// bigger than the square of
// the Uniform_size_criterion
CGAL::Surface_mesher::Uniform_size_criterion<Tr> u_s_crit (0.1);
// bound on radii of surface Delaunay balls
CGAL::Surface_mesher::Aspect_ratio_criterion<Tr> a_r_crit (30);
// lower bound on minimum angle in degrees
std::vector<Criterion*> crit_vect;
crit_vect.push_back (&a_r_crit);
crit_vect.push_back (&u_s_crit);
crit_vect.push_back (&c_s_crit);
Criteria C (crit_vect);
std::cout << "Initial number of points: " << tr.number_of_vertices() std::cout << "Initial number of points: " << tr.number_of_vertices()
<< std::endl; << std::endl;
// 2D-complex in 3D-Delaunay triangulation // 2D-complex in 3D-Delaunay triangulation
C2t3 Co2 (tr); C2T3 c2t3 (tr);
// Surface meshing // Surface meshing
Surface mesher (tr, Co2, O, C); make_surface_mesh(c2t3,
// Surface mesher (tr, O, a_r_crit); CGAL::make_implicit_surface_3(Kernel(),
mesher.refine_mesh(true); sphere,
Sphere_3(CGAL::ORIGIN, 2.),
1e-06),
criteria,
CGAL::Non_manifold_tag());
std::cout << "Final number of points: " << tr.number_of_vertices() std::cout << "Final number of points: " << tr.number_of_vertices()
<< std::endl; << std::endl;
// Output
#ifdef SURFACE_MESHER_POLYHEDRAL
const int out_filename_position_in_argv = 2;
#else
const int out_filename_position_in_argv = 1;
#endif
if (argc >= out_filename_position_in_argv + 1) {
std::cout << "Writing output to file " << argv[out_filename_position_in_argv] << "...";
std::ofstream os(argv[out_filename_position_in_argv]);
output_surface_facets_to_off (os, tr);
os.close();
std::cout << " done\n";
}
} }