working on the subdivision of the skin surface mesh

This commit is contained in:
Nico Kruithof 2006-09-29 20:26:50 +00:00
parent 7ed3fe39a5
commit f5520fc084
7 changed files with 193 additions and 156 deletions

View File

@ -1,6 +1,6 @@
// examples/Skin_surface_3/NGHK_skin_surface_subdiv.C // examples/Skin_surface_3/NGHK_skin_surface_subdiv.C
#define CGAL_PROFILE //#define CGAL_PROFILE
#define CGAL_NO_ASSERTIONS //#define CGAL_NO_ASSERTIONS
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Skin_surface_3.h> #include <CGAL/Skin_surface_3.h>
@ -15,13 +15,11 @@
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Skin_surface_traits_3<K> Traits; typedef CGAL::Skin_surface_traits_3<K> Traits;
typedef CGAL::Skin_surface_3<Traits> Skin_surface_3; typedef CGAL::Skin_surface_3<Traits> Skin_surface_3;
typedef Skin_surface_3::FT FT; typedef Skin_surface_3::RT RT;
typedef Skin_surface_3::Weighted_point Weighted_point; typedef Skin_surface_3::Weighted_point Weighted_point;
typedef Weighted_point::Point Bare_point; typedef Weighted_point::Point Bare_point;
typedef CGAL::Polyhedron_3< typedef CGAL::Polyhedron_3<K,
K, CGAL::Skin_surface_polyhedral_items_3<Skin_surface_3> > Polyhedron;
CGAL::Skin_surface_polyhedral_items_3<Skin_surface_3>
> Polyhedron;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc < 2) { if (argc < 2) {
@ -30,7 +28,7 @@ int main(int argc, char *argv[]) {
} }
std::list<Weighted_point> l; std::list<Weighted_point> l;
FT shrinkfactor = 0.5; RT shrinkfactor = 0.5;
Weighted_point wp; Weighted_point wp;
std::ifstream in(argv[1]); std::ifstream in(argv[1]);

View File

@ -24,6 +24,9 @@ void write_polyhedron_with_normals(SkinSurface &skin,
<< std::endl; << std::endl;
// Write vertices // Write vertices
// typedef CGAL::Skin_surface_subdivision_policy_default_3<Polyhedron, SkinSurface>
// Subdivision_policy;
// Subdivision_policy *policy = get_subdivision_policy(p, skin);
for (Vertex_iterator vit = p.vertices_begin(); for (Vertex_iterator vit = p.vertices_begin();
vit != p.vertices_end(); vit ++) { vit != p.vertices_end(); vit ++) {
Vector_3 n = skin.normal(vit->point()); Vector_3 n = skin.normal(vit->point());

View File

@ -1,61 +0,0 @@
// Copyright (c) 2005 Rijksuniversiteit Groningen (Netherlands)
// 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$
// $Id$
//
//
// Author(s) : Nico Kruithof <Nico@cs.rug.nl>
#ifndef CGAL_MARCHING_TETRAHEDRA_OBSERVER_SKIN_SURFACE_3_H
#define CGAL_MARCHING_TETRAHEDRA_OBSERVER_SKIN_SURFACE_3_H
#include <CGAL/Marching_tetrahedra_observer_default_3.h>
CGAL_BEGIN_NAMESPACE
template <class Vertex_iterator,
class Cell_iterator,
class Polyhedron_3>
class Marching_tetrahedra_observer_skin_surface_3
: public Marching_tetrahedra_observer_default_3
<Vertex_iterator, Cell_iterator, Polyhedron_3>
{
public:
typedef Marching_tetrahedra_observer_default_3
<Vertex_iterator, Cell_iterator, Polyhedron_3> Base;
typedef Polyhedron_3 Polyhedron;
typedef Cell_iterator T_Cell_iterator;
typedef typename Polyhedron::Vertex_handle Polyhedron_vertex_handle;
typedef typename Polyhedron::Facet_handle Polyhedron_facet_handle;
Marching_tetrahedra_observer_skin_surface_3() : Base() {
}
Marching_tetrahedra_observer_skin_surface_3(
const Marching_tetrahedra_observer_skin_surface_3& traits2) : Base(traits2)
{}
void after_facet_insertion(
T_Cell_iterator ch,
Polyhedron_facet_handle fh) {
fh->sim = ch->mixed_cell();
}
};
CGAL_END_NAMESPACE
#endif // CGAL_MARCHING_TETRAHEDRA_OBSERVER_SKIN_SURFACE_3_H

View File

@ -41,6 +41,10 @@
#include <CGAL/Random.h> #include <CGAL/Random.h>
#include <CGAL/Skin_surface_traits_3.h> #include <CGAL/Skin_surface_traits_3.h>
#include <CGAL/Skin_surface_marching_tetrahedra_observer_3.h>
#include <CGAL/Skin_surface_refinement_policy_3.h>
#include <CGAL/subdivide_skin_surface_mesh_3.h>
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
template <class MixedComplexTraits_3> template <class MixedComplexTraits_3>
@ -50,10 +54,10 @@ class Skin_surface_3 {
public: public:
typedef MixedComplexTraits_3 Geometric_traits; typedef MixedComplexTraits_3 Geometric_traits;
typedef typename Gt::Weighted_point Weighted_point; typedef typename Gt::Weighted_point Weighted_point;
typedef typename Gt::FT FT; typedef typename Weighted_point::Weight RT;
// NGHK:: added for the Delaunay mesher // NGHK:: added for the Delaunay mesher
typedef typename Gt::Sphere_3 Sphere; typedef typename Gt::Sphere_3 Sphere;
typedef typename Gt::Bare_point Bare_point; typedef typename Weighted_point::Point Bare_point;
typedef typename Gt::Vector_3 Vector; typedef typename Gt::Vector_3 Vector;
typedef Regular_triangulation_3<Gt> Regular; typedef Regular_triangulation_3<Gt> Regular;
@ -97,7 +101,7 @@ private:
public: public:
template < class WP_iterator > template < class WP_iterator >
Skin_surface_3(WP_iterator begin, WP_iterator end, Skin_surface_3(WP_iterator begin, WP_iterator end,
FT shrink_factor, RT shrink_factor,
bool grow_balls = true, bool grow_balls = true,
Gt gt_ = Gt(), Gt gt_ = Gt(),
bool _verbose = false bool _verbose = false
@ -139,12 +143,16 @@ public:
class HalfedgeDS> class HalfedgeDS>
friend class Marching_tetrahedra_traits_skin_surface_3; friend class Marching_tetrahedra_traits_skin_surface_3;
template <class SkinSurface_3, class Polyhedron_3>
friend class Skin_surface_subdivision_policy_default_3;
template <class Polyhedron_3> template <class Polyhedron_3>
void mesh_skin_surface_3(Polyhedron_3 &p) const; void mesh_skin_surface_3(Polyhedron_3 &p) const;
// This class has to be a friend:
template <class SkinSurface_3, class Polyhedron_3>
friend class Skin_surface_refinement_policy_3;
template <class Polyhedron_3>
void subdivide_skin_surface_mesh_3(Polyhedron_3 &p) const;
Sign sign(const Bare_point &p, const Simplex &start = Simplex()) const { Sign sign(const Bare_point &p, const Simplex &start = Simplex()) const {
return get_sign(locate_mixed(p,start), p); return get_sign(locate_mixed(p,start), p);
} }
@ -289,13 +297,13 @@ private:
(sim, (sim,
Exact_predicates_exact_constructions_kernel()).sign(p); Exact_predicates_exact_constructions_kernel()).sign(p);
} }
FT RT
value(const Bare_point &p) const { value(const Bare_point &p) const {
Simplex sim = locate_mixed(p); Simplex sim = locate_mixed(p);
return value(sim,p); return value(sim,p);
} }
FT RT
value(const Simplex &sim, const Bare_point &p) const { value(const Simplex &sim, const Bare_point &p) const {
return return
construct_surface(sim, typename Geometric_traits::Kernel()).value(p); construct_surface(sim, typename Geometric_traits::Kernel()).value(p);
@ -351,11 +359,11 @@ private:
Simplex &s1, Simplex &s2, Simplex &s1, Simplex &s2,
Bare_point &p) const { Bare_point &p) const {
typedef typename Bare_point::R Traits; typedef typename Bare_point::R Traits;
typedef typename Traits::FT FT; typedef typename Traits::RT RT;
Cartesian_converter<Traits, Cartesian_converter<Traits,
typename Geometric_traits::Bare_point::R> converter; typename Geometric_traits::Bare_point::R> converter;
FT sq_dist = squared_distance(p1,p2); RT sq_dist = squared_distance(p1,p2);
// Use value to make the computation robust (endpoints near the surface) // Use value to make the computation robust (endpoints near the surface)
if (value(s1, p1) > value(s2, p2)) std::swap(p1, p2); if (value(s1, p1) > value(s2, p2)) std::swap(p1, p2);
Simplex sp = s1; Simplex sp = s1;
@ -379,8 +387,8 @@ private:
p = midpoint(p1, p2); p = midpoint(p1, p2);
} }
void void intersect_with_transversal_segment
intersect_with_transversal_segment(Bare_point &p, (Bare_point &p,
const Simplex &start = Simplex()) const const Simplex &start = Simplex()) const
{ {
@ -469,8 +477,8 @@ private:
typedef Weighted_converter_3<Cartesian_converter< typedef Weighted_converter_3<Cartesian_converter<
typename Geometric_traits::Bare_point::R, Traits> > Converter; typename Geometric_traits::Bare_point::R, Traits> > Converter;
typedef typename Traits::Point_3 Point; typedef typename Traits::Point_3 Point;
typedef typename Traits::FT FT; typedef typename Traits::RT RT;
typedef CGAL::Weighted_point<Point,FT> Weighted_point; typedef CGAL::Weighted_point<Point,RT> Weighted_point;
Converter conv; Converter conv;
@ -528,11 +536,11 @@ private:
Sphere bounding_sphere() const { Sphere bounding_sphere() const {
return _bounding_sphere; return _bounding_sphere;
} }
FT squared_error_bound() const { RT squared_error_bound() const {
return .01; return .01;
} }
typename Mesher_Gt::FT typename Mesher_Gt::RT
get_density(const typename Mesher_Gt::Point_3 &p) const { get_density(const typename Mesher_Gt::Point_3 &p) const {
// NGHK: Make adaptive // NGHK: Make adaptive
return 1; return 1;
@ -540,7 +548,7 @@ private:
const Regular &get_regular_triangulation() const { const Regular &get_regular_triangulation() const {
return regular; return regular;
} }
FT get_shrink_factor() const { RT get_shrink_factor() const {
return gt.get_shrink(); return gt.get_shrink();
} }
@ -568,12 +576,12 @@ construct_bounding_box(Regular &regular)
typedef typename Regular::Geom_traits GT; typedef typename Regular::Geom_traits GT;
typedef typename GT::Bare_point Point; typedef typename GT::Bare_point Point;
typedef typename GT::Point Weighted_point; typedef typename GT::Point Weighted_point;
typedef typename GT::FT FT; typedef typename GT::RT RT;
Finite_vertices_iterator vit = regular.finite_vertices_begin(); Finite_vertices_iterator vit = regular.finite_vertices_begin();
if (vit != regular.finite_vertices_end()) { if (vit != regular.finite_vertices_end()) {
Bbox_3 bbox = vit->point().bbox(); Bbox_3 bbox = vit->point().bbox();
FT max_weight=vit->point().weight(); RT max_weight=vit->point().weight();
while (++vit != regular.finite_vertices_end()) { while (++vit != regular.finite_vertices_end()) {
bbox = bbox + vit->point().bbox(); bbox = bbox + vit->point().bbox();
if (max_weight < vit->point().weight()) if (max_weight < vit->point().weight())
@ -581,12 +589,12 @@ construct_bounding_box(Regular &regular)
} }
// add a bounding octahedron: // add a bounding octahedron:
FT dx = bbox.xmax() - bbox.xmin(); RT dx = bbox.xmax() - bbox.xmin();
FT dy = bbox.ymax() - bbox.ymin(); RT dy = bbox.ymax() - bbox.ymin();
FT dz = bbox.zmax() - bbox.zmin(); RT dz = bbox.zmax() - bbox.zmin();
Bare_point mid(bbox.xmin() + dx/2, bbox.ymin() + dy/2, bbox.zmin() + dz/2); Bare_point mid(bbox.xmin() + dx/2, bbox.ymin() + dy/2, bbox.zmin() + dz/2);
FT dr = sqrt(CGAL::to_double(max_weight)) + .001; RT dr = sqrt(CGAL::to_double(max_weight)) + .001;
regular.insert(Weighted_point( regular.insert(Weighted_point(
Bare_point(bbox.xmax()+(dy+dz+dr)/gt.get_shrink(),mid.y(),mid.z()),-1)); Bare_point(bbox.xmax()+(dy+dz+dr)/gt.get_shrink(),mid.y(),mid.z()),-1));
@ -790,30 +798,6 @@ locate_mixed(const Bare_point &p, const Simplex &start) const {
return s; return s;
} }
template <class SkinSurface_3, class Polyhedron_3>
struct Skin_surface_3_marching_tetrahedra_observer {
typedef Marching_tetrahedra_observer_default_3<
typename SkinSurface_3::CMCT_Vertex_iterator,
typename SkinSurface_3::CMCT_Cell_iterator,
Polyhedron_3> value_type;
};
template <class SkinSurface_3, class PolyhedronTraits>
struct Skin_surface_3_marching_tetrahedra_observer
<SkinSurface_3,
Polyhedron_3<PolyhedronTraits,
Skin_surface_polyhedral_items_3<SkinSurface_3> > >
{
typedef Polyhedron_3
<PolyhedronTraits,
Skin_surface_polyhedral_items_3<SkinSurface_3> > Polyhedron;
typedef Marching_tetrahedra_observer_skin_surface_3<
typename SkinSurface_3::CMCT_Vertex_iterator,
typename SkinSurface_3::CMCT_Cell_iterator,
Polyhedron> value_type;
};
template <class MixedComplexTraits_3> template <class MixedComplexTraits_3>
template <class Polyhedron_3> template <class Polyhedron_3>
void void
@ -826,14 +810,15 @@ Skin_surface_3<MixedComplexTraits_3>::mesh_skin_surface_3(Polyhedron_3 &p) const
Self, Self,
CMCT_Vertex_iterator, CMCT_Vertex_iterator,
CMCT_Cell_iterator, CMCT_Cell_iterator,
typename Polyhedron::HalfedgeDS> Marching_tetrahedra_traits; typename Polyhedron::HalfedgeDS> Traits;
typedef typename typedef Skin_surface_marching_tetrahedra_observer_3<
Skin_surface_3_marching_tetrahedra_observer<Self, Polyhedron_3>::value_type CMCT_Vertex_iterator,
Marching_tetrahedra_observer; CMCT_Cell_iterator,
Polyhedron> Observer;
// Extract the coarse mesh using marching_tetrahedra // Extract the coarse mesh using marching_tetrahedra
Marching_tetrahedra_traits marching_traits(*this); Traits marching_traits(*this);
Marching_tetrahedra_observer marching_observer; Observer marching_observer;
marching_tetrahedra_3(cmct_vertices_begin(), marching_tetrahedra_3(cmct_vertices_begin(),
cmct_vertices_end(), cmct_vertices_end(),
cmct_cells_begin(), cmct_cells_begin(),
@ -843,6 +828,22 @@ Skin_surface_3<MixedComplexTraits_3>::mesh_skin_surface_3(Polyhedron_3 &p) const
marching_observer); marching_observer);
} }
template <class MixedComplexTraits_3>
template <class Polyhedron_3>
void
Skin_surface_3<MixedComplexTraits_3>::subdivide_skin_surface_mesh_3(Polyhedron_3 &p) const {
std::cout << "Skin_Surface_3.subdivide_skin_surface_mesh_3(p)" << std::endl;
typedef Skin_surface_refinement_policy_3<Self, Polyhedron_3> Policy;
typedef Skin_surface_sqrt3<Self, Polyhedron_3, Policy> Subdivider;
Policy policy(*this);
Subdivider subdivider(*this, p, policy);
subdivider.subdivide();
}
CGAL_END_NAMESPACE CGAL_END_NAMESPACE

View File

@ -0,0 +1,90 @@
// Copyright (c) 2005 Rijksuniversiteit Groningen (Netherlands)
// 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$
// $Id$
//
//
// Author(s) : Nico Kruithof <Nico@cs.rug.nl>
#ifndef CGAL_SKIN_SURFACE_MARCHING_TETRAHEDRA_OBSERVER_3_H
#define CGAL_SKIN_SURFACE_MARCHING_TETRAHEDRA_OBSERVER_3_H
#include <CGAL/Marching_tetrahedra_observer_default_3.h>
CGAL_BEGIN_NAMESPACE
template <class Vertex_iterator,
class Cell_iterator,
class Polyhedron_3>
class Skin_surface_marching_tetrahedra_observer_3
: public Marching_tetrahedra_observer_default_3
<Vertex_iterator, Cell_iterator, Polyhedron_3>
{
typedef Polyhedron_3 Polyhedron;
typedef Marching_tetrahedra_observer_default_3
<Vertex_iterator, Cell_iterator, Polyhedron> Base;
public:
Skin_surface_marching_tetrahedra_observer_3() : Base() {
std::cout << "Default Skin_surface_marching_tetrahedra_observer_3"
<< std::endl;
}
};
template <class Vertex_iterator,
class Cell_iterator,
class P_Traits,
class SkinSurface_3>
class Skin_surface_marching_tetrahedra_observer_3
<Vertex_iterator, Cell_iterator,
Polyhedron_3<P_Traits,
Skin_surface_polyhedral_items_3<SkinSurface_3> > >
: public Marching_tetrahedra_observer_default_3
<Vertex_iterator, Cell_iterator,
Polyhedron_3<P_Traits,
Skin_surface_polyhedral_items_3<SkinSurface_3> > >
{
public:
typedef Polyhedron_3<P_Traits,
Skin_surface_polyhedral_items_3<SkinSurface_3> >
Polyhedron;
typedef Marching_tetrahedra_observer_default_3
<Vertex_iterator, Cell_iterator, Polyhedron> Base;
typedef Cell_iterator T_Cell_iterator;
typedef typename Polyhedron::Vertex_handle Polyhedron_vertex_handle;
typedef typename Polyhedron::Facet_handle Polyhedron_facet_handle;
Skin_surface_marching_tetrahedra_observer_3() : Base() {
std::cout << "Optimized Skin_surface_marching_tetrahedra_observer_3"
<< std::endl;
}
Skin_surface_marching_tetrahedra_observer_3(
const Skin_surface_marching_tetrahedra_observer_3& traits2) : Base(traits2)
{}
void after_facet_insertion(
T_Cell_iterator ch,
Polyhedron_facet_handle fh) {
fh->sim = ch->mixed_cell();
}
};
CGAL_END_NAMESPACE
#endif // CGAL_SKIN_SURFACE_MARCHING_TETRAHEDRA_OBSERVER_3_H

View File

@ -17,29 +17,29 @@
// //
// Author(s) : Nico Kruithof <Nico@cs.rug.nl> // Author(s) : Nico Kruithof <Nico@cs.rug.nl>
#ifndef CGAL_SKIN_SURFACE_SUBDIVISION_POLICY_H #ifndef CGAL_SKIN_SURFACE_REFINEMENT_POLICY_3_H
#define CGAL_SKIN_SURFACE_SUBDIVISION_POLICY_H #define CGAL_SKIN_SURFACE_REFINEMENT_POLICY_3_H
#include <CGAL/intersection_3_1.h> #include <CGAL/intersection_3_1.h>
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
// template <class Polyhedron_3, class SkinSurface_3> // template <class Polyhedron_3, class SkinSurface_3>
// class Skin_surface_subdivision_policy_base_3 { // class Skin_surface_refinement_policy_3 {
// public: // public:
// typedef Polyhedron_3 Polyhedron; // typedef Polyhedron_3 Polyhedron;
// typedef SkinSurface_3 Skin_surface; // typedef SkinSurface_3 Skin_surface;
// typedef typename Polyhedron::Traits P_traits; // typedef typename Polyhedron::Policy P_policy;
// typedef typename Polyhedron::Vertex_handle P_vertex_handle; // typedef typename Polyhedron::Vertex_handle P_vertex_handle;
// typedef typename P_traits::RT P_rt; // typedef typename P_policy::RT P_rt;
// typedef typename P_traits::Point_3 P_point; // typedef typename P_policy::Point_3 P_point;
// typedef typename P_traits::Segment_3 P_segment; // typedef typename P_policy::Segment_3 P_segment;
// typedef typename P_traits::Line_3 P_line; // typedef typename P_policy::Line_3 P_line;
// typedef typename P_traits::Vector_3 P_vector; // typedef typename P_policy::Vector_3 P_vector;
// typedef typename P_traits::Plane_3 P_plane; // typedef typename P_policy::Plane_3 P_plane;
// Skin_surface_subdivision_policy_base_3(Skin_surface const& skin) // Skin_surface_refinement_policy_base_3(Skin_surface const& skin)
// : ss_3(skin) // : ss_3(skin)
// {} // {}
@ -52,7 +52,7 @@ CGAL_BEGIN_NAMESPACE
// }; // };
template <class SkinSurface_3, class Polyhedron_3> template <class SkinSurface_3, class Polyhedron_3>
class Skin_surface_subdivision_policy_default_3 class Skin_surface_refinement_policy_3
{ {
public: public:
typedef SkinSurface_3 Skin_surface; typedef SkinSurface_3 Skin_surface;
@ -68,7 +68,7 @@ public:
typedef typename P_traits::Vector_3 P_vector; typedef typename P_traits::Vector_3 P_vector;
typedef typename P_traits::Plane_3 P_plane; typedef typename P_traits::Plane_3 P_plane;
Skin_surface_subdivision_policy_default_3(Skin_surface const& skin) Skin_surface_refinement_policy_3(Skin_surface const& skin)
: ss_3(skin) : ss_3(skin)
{ {
@ -105,23 +105,23 @@ protected:
// // Partial specialisation for Skin_surface_polyhedral_items_3 // // Partial specialisation for Skin_surface_polyhedral_items_3
// #include <CGAL/Skin_surface_polyhedral_items_3.h> // #include <CGAL/Skin_surface_polyhedral_items_3.h>
// #include <CGAL/Skin_surface_refinement_traits_with_face_info_3.h> // #include <CGAL/Skin_surface_refinement_policy_with_face_info_3.h>
// CGAL_BEGIN_NAMESPACE // CGAL_BEGIN_NAMESPACE
// template <class P_Traits, // template <class P_Policy,
// class SkinSurface_3> // class SkinSurface_3>
// Skin_surface_subdivision_policy_base_3<Polyhedron_3<P_Traits, // Skin_surface_refinement_policy_base_3<Polyhedron_3<P_Policy,
// Skin_surface_polyhedral_items_3<SkinSurface_3> >, SkinSurface_3> * // Skin_surface_polyhedral_items_3<SkinSurface_3> >, SkinSurface_3> *
// get_subdivision_policy(Polyhedron_3<P_Traits, // get_refinement_policy(Polyhedron_3<P_Policy,
// Skin_surface_polyhedral_items_3<SkinSurface_3> > &p, // Skin_surface_polyhedral_items_3<SkinSurface_3> > &p,
// const SkinSurface_3 &skinsurface) // const SkinSurface_3 &skinsurface)
// { // {
// typedef Polyhedron_3<P_Traits, // typedef Polyhedron_3<P_Policy,
// Skin_surface_polyhedral_items_3<SkinSurface_3> > Polyhedron; // Skin_surface_polyhedral_items_3<SkinSurface_3> > Polyhedron;
// typedef // typedef
// Skin_surface_subdivision_policy_with_face_info_3<Polyhedron, SkinSurface_3> // Skin_surface_refinement_policy_with_face_info_3<Polyhedron, SkinSurface_3>
// Policy; // Policy;
// return new Policy(skinsurface); // return new Policy(skinsurface);
@ -130,4 +130,4 @@ protected:
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_SKIN_SURFACE_SUBDIVISION_TRAITS_H #endif // CGAL_SKIN_SURFACE_REFINEMENT_POLICY_3_H

View File

@ -20,7 +20,7 @@
#ifndef CGAL_SUBDIVIDE_SKIN_SURFACE_MESH_3_H #ifndef CGAL_SUBDIVIDE_SKIN_SURFACE_MESH_3_H
#define CGAL_SUBDIVIDE_SKIN_SURFACE_MESH_3_H #define CGAL_SUBDIVIDE_SKIN_SURFACE_MESH_3_H
#include <CGAL/Skin_surface_refinement_traits_3.h> #include <CGAL/Skin_surface_refinement_policy_3.h>
#include <CGAL/Polyhedron_3.h> #include <CGAL/Polyhedron_3.h>
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
@ -57,14 +57,15 @@ class Skin_surface_sqrt3
typedef typename Kernel::FT FT; typedef typename Kernel::FT FT;
public: public:
Skin_surface_sqrt3(const SkinSurface_3 &skin, Polyhedron &P, Skin_surface_sqrt3(const SkinSurface_3 &skin,
Polyhedron &P,
const SubdivisionPolicy_3 &policy) const SubdivisionPolicy_3 &policy)
: P(P), ss(skin), policy(policy) {} : P(P), ss(skin), policy(policy) {}
//********************************************* //*********************************************
// Subdivision // Subdivision
//********************************************* //*********************************************
int subdivide(int iter) int subdivide(int iter=1)
{ {
// check for valid polygon mesh // check for valid polygon mesh
if(P.size_of_facets() == 0) if(P.size_of_facets() == 0)
@ -74,7 +75,7 @@ public:
P.normalize_border(); P.normalize_border();
while (iter > 0) { while (iter > 0) {
subdivide(); do_subdivide();
iter--; iter--;
} }
return true; return true;
@ -85,7 +86,7 @@ private:
//********************************************* //*********************************************
// Subdivide // Subdivide
//********************************************* //*********************************************
void subdivide() void do_subdivide()
{ {
// We use that new vertices/halfedges/facets are appended at the end. // We use that new vertices/halfedges/facets are appended at the end.
@ -141,20 +142,25 @@ private:
const Subdivision_policy &policy; const Subdivision_policy &policy;
}; };
template <class SkinSurface_3, template <class SkinSurface_3, class Polyhedron_3>
class Polyhedron_3>
void subdivide_skin_surface_mesh_3( void subdivide_skin_surface_mesh_3(
const SkinSurface_3 &skin, const SkinSurface_3 &skin,
Polyhedron_3 &p, Polyhedron_3 &p,
int nSubdiv = 1) { int nSubdiv = 1) {
typedef Skin_surface_subdivision_policy_default_3<SkinSurface_3, while (nSubdiv > 0) {
Polyhedron_3> Policy; skin.subdivide_skin_surface_mesh_3(p);
typedef Skin_surface_sqrt3<SkinSurface_3, Polyhedron_3, Policy> Subdivider; nSubdiv--;
}
// typedef Skin_surface_subdivision_policy_default_3<Polyhedron_3,
// SkinSurface_3> Policy;
// typedef Skin_surface_sqrt3<Polyhedron_3,
// SkinSurface_3,
// Policy> Subdivider;
Policy policy(skin); // Policy policy(skin);
Subdivider subdivider(skin, p, policy); // Subdivider subdivider(p, skin, policy);
subdivider.subdivide(nSubdiv); // subdivider.subdivide(nSubdiv);
} }
CGAL_END_NAMESPACE CGAL_END_NAMESPACE