58#include <OpenMesh/Core/Utils/vector_cast.hh>
59#include <OpenMesh/Core/Utils/Property.hh>
63#if defined(OM_CC_MIPS)
79template <
typename MeshType,
typename RealType =
double>
83 typedef std::pair<typename MeshType::EdgeHandle, RealType> queueElement;
85 bool operator()(
const queueElement& t1,
const queueElement& t2)
87 return (t1.second < t2.second);
98template <
typename MeshType,
typename RealType =
float>
103 typedef RealType real_t;
104 typedef MeshType mesh_t;
107 typedef std::vector< std::vector<real_t> > weights_t;
108 typedef std::vector<real_t> weight_t;
110 typedef std::pair< typename mesh_t::EdgeHandle, real_t > queueElement;
129 const char *
name()
const {
return "Longest Edge Split"; }
131 void set_max_edge_length(
double _value) {
132 max_edge_length_squared_ = _value * _value;
150 bool subdivide( MeshType& _m,
size_t _n ,
const bool _update_points =
true)
159 for (
typename mesh_t::EdgeIter eit = _m.edges_begin(); eit != edgesEnd; ++eit) {
160 const typename MeshType::Point to = _m.point(_m.to_vertex_handle(_m.halfedge_handle(*eit,0)));
161 const typename MeshType::Point from = _m.point(_m.from_vertex_handle(_m.halfedge_handle(*eit,0)));
163 real_t length = sqrnorm(to - from);
166 if ( length > max_edge_length_squared_ )
167 queue.push( queueElement(*eit,length) );
171 while ( !stop && ! queue.empty() ) {
172 queueElement a = queue.top();
175 if ( a.second < max_edge_length_squared_ ) {
179 const typename MeshType::Point to = _m.point(_m.to_vertex_handle(_m.halfedge_handle(a.first,0)));
180 const typename MeshType::Point from = _m.point(_m.from_vertex_handle(_m.halfedge_handle(a.first,0)));
181 const typename MeshType::Point midpoint =
static_cast<typename MeshType::Point::value_type
>(0.5) * (to + from);
183 const typename MeshType::VertexHandle newVertex = _m.add_vertex(midpoint);
184 _m.split(a.first,newVertex);
186 for (
typename MeshType::VertexOHalfedgeIter voh_it(_m,newVertex); voh_it.is_valid(); ++voh_it) {
187 typename MeshType::EdgeHandle eh = _m.edge_handle(*voh_it);
188 const typename MeshType::Point to = _m.point(_m.to_vertex_handle(*voh_it));
189 const typename MeshType::Point from = _m.point(_m.from_vertex_handle(*voh_it));
190 real_t length = sqrnorm(to - from);
193 if ( length > max_edge_length_squared_ )
194 queue.push( queueElement(eh,length) );
200#if defined(_DEBUG) || defined(DEBUG)
211 real_t max_edge_length_squared_;
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
Kernel::EdgeIter EdgeIter
Scalar type.
Definition: PolyMeshT.hh:145
Definition: LongestEdgeT.hh:80
Uniform LongestEdgeT subdivision algorithm
Definition: LongestEdgeT.hh:100
bool prepare(mesh_t &_m)
Prepare mesh, e.g. add properties.
Definition: LongestEdgeT.hh:138
bool cleanup(mesh_t &_m)
Cleanup mesh after usage, e.g. remove added properties.
Definition: LongestEdgeT.hh:144
const char * name() const
Return name of subdivision algorithm.
Definition: LongestEdgeT.hh:129
bool subdivide(MeshType &_m, size_t _n, const bool _update_points=true)
Subdivide mesh _m _n times.
Definition: LongestEdgeT.hh:150
Abstract base class for uniform subdivision algorithms.
Definition: SubdividerT.hh:89
Check integrity of mesh.
Definition: MeshCheckerT.hh:74