mirror of https://github.com/CGAL/cgal
Be able to deal with Patch_id=pair<int,int>
So far, the files <CGAL/Mesh_3/Detect_features_in_polyhedra.h> <CGAL/Mesh_polyhedron_3.h> were assuming that the Patch_id was an integral type. Now they assumes that it is either an integral type, or a pair of integral types.
This commit is contained in:
parent
7889b90645
commit
1ec6cd429a
|
|
@ -53,6 +53,7 @@ public:
|
|||
typedef typename Polyhedron::Facet_handle Facet_handle;
|
||||
typedef typename Polyhedron::Halfedge Halfedge;
|
||||
typedef typename Polyhedron::Facet Facet;
|
||||
typedef typename Facet::Patch_id Patch_id;
|
||||
|
||||
typedef std::set<Facet*> Facet_handle_set;
|
||||
typedef std::set<Halfedge*> He_handle_set;
|
||||
|
|
@ -68,8 +69,14 @@ public:
|
|||
private:
|
||||
Vector_3 facet_normal(const Facet_handle& f) const;
|
||||
bool is_sharp(const Halfedge_handle& he, FT cos_angle) const;
|
||||
void flood(Facet& f, const int index,
|
||||
void flood(Facet& f, const Patch_id id,
|
||||
Facet_handle_set& unsorted_faces) const;
|
||||
|
||||
template <typename Int>
|
||||
Int generate_patch_id(Int, int);
|
||||
|
||||
template <typename Int>
|
||||
std::pair<Int, Int> generate_patch_id(std::pair<Int, Int>, int);
|
||||
|
||||
private:
|
||||
// Stores the current surface index (usefull to detect different patches
|
||||
|
|
@ -108,6 +115,24 @@ detect_sharp_edges(Polyhedron& polyhedron, FT angle_in_deg) const
|
|||
}
|
||||
|
||||
|
||||
template <typename P_>
|
||||
template <typename Int>
|
||||
Int
|
||||
Detect_features_in_polyhedra<P_>::
|
||||
generate_patch_id(Int, int i)
|
||||
{
|
||||
return Int(i);
|
||||
}
|
||||
|
||||
template <typename P_>
|
||||
template <typename Int>
|
||||
std::pair<Int, Int>
|
||||
Detect_features_in_polyhedra<P_>::
|
||||
generate_patch_id(std::pair<Int, Int>, int i)
|
||||
{
|
||||
return std::pair<Int, Int>(i, 0);
|
||||
}
|
||||
|
||||
template <typename P_>
|
||||
void
|
||||
Detect_features_in_polyhedra<P_>::
|
||||
|
|
@ -127,13 +152,15 @@ detect_surface_patches(Polyhedron& polyhedron)
|
|||
Facet& f = **(unsorted_faces.begin());
|
||||
unsorted_faces.erase(unsorted_faces.begin());
|
||||
|
||||
f.set_patch_id(current_surface_index_);
|
||||
flood(f,current_surface_index_,unsorted_faces);
|
||||
const Patch_id patch_id = generate_patch_id(Patch_id(),
|
||||
current_surface_index_);
|
||||
f.set_patch_id(patch_id);
|
||||
flood(f,patch_id,unsorted_faces);
|
||||
++current_surface_index_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template <typename P_>
|
||||
void
|
||||
Detect_features_in_polyhedra<P_>::
|
||||
|
|
@ -218,7 +245,7 @@ is_sharp(const Halfedge_handle& he, FT cos_angle) const
|
|||
template <typename P_>
|
||||
void
|
||||
Detect_features_in_polyhedra<P_>::
|
||||
flood(Facet& f, const int index, Facet_handle_set& unsorted_faces) const
|
||||
flood(Facet& f, const Patch_id patch_id, Facet_handle_set& unsorted_faces) const
|
||||
{
|
||||
typedef typename Facet::Halfedge_around_facet_circulator Facet_he_circ;
|
||||
|
||||
|
|
@ -245,7 +272,7 @@ flood(Facet& f, const int index, Facet_handle_set& unsorted_faces) const
|
|||
Facet& explored_facet = *(he.facet());
|
||||
|
||||
// Mark facet and delete it from unsorted
|
||||
explored_facet.set_patch_id(index);
|
||||
explored_facet.set_patch_id(patch_id);
|
||||
unsorted_faces.erase(&explored_facet);
|
||||
|
||||
// Add/Remove facet's halfedge to/from explore list
|
||||
|
|
|
|||
|
|
@ -89,6 +89,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <typename Integral>
|
||||
inline std::pair<Integral, Integral>
|
||||
patch_id_default_value(std::pair<Integral, Integral>)
|
||||
{
|
||||
return std::pair<Integral, Integral>(1, 0);
|
||||
}
|
||||
|
||||
template <typename Integral>
|
||||
inline Integral patch_id_default_value(Integral)
|
||||
{
|
||||
return Integral(1);
|
||||
}
|
||||
|
||||
template <class Refs, class T_, class Pln_, class Patch_id_>
|
||||
class Mesh_polyhedron_face :
|
||||
public CGAL::HalfedgeDS_face_base<Refs,T_,Pln_>
|
||||
|
|
@ -100,7 +113,7 @@ public:
|
|||
typedef Patch_id_ Patch_id;
|
||||
|
||||
Mesh_polyhedron_face()
|
||||
: patch_id_(1) {}
|
||||
: patch_id_(patch_id_default_value(Patch_id())) {}
|
||||
|
||||
const Patch_id& patch_id() const {
|
||||
return patch_id_;
|
||||
|
|
|
|||
Loading…
Reference in New Issue