64 #include <OpenMesh/Core/Utils/vector_cast.hh> 65 #include <OpenMesh/Core/Utils/Property.hh> 69 #if defined(OM_CC_MIPS) 79 namespace Subdivider {
85 template <
typename MeshType,
typename RealType =
double>
89 typedef std::pair<typename MeshType::EdgeHandle, RealType> queueElement;
91 bool operator()(
const queueElement& t1,
const queueElement& t2)
93 return (t1.second < t2.second);
104 template <
typename MeshType,
typename RealType =
float>
109 typedef RealType real_t;
110 typedef MeshType mesh_t;
113 typedef std::vector< std::vector<real_t> > weights_t;
114 typedef std::vector<real_t> weight_t;
116 typedef std::pair< typename mesh_t::EdgeHandle, real_t > queueElement;
135 const char *
name()
const {
return "Longest Edge Split"; }
137 void set_max_edge_length(
double _value) {
138 max_edge_length_squared_ = _value * _value;
156 bool subdivide( MeshType& _m,
size_t _n ,
const bool _update_points =
true)
164 typename mesh_t::EdgeIter edgesEnd = _m.edges_end();
165 for (
typename mesh_t::EdgeIter eit = _m.edges_begin(); eit != edgesEnd; ++eit) {
166 const typename MeshType::Point to = _m.point(_m.to_vertex_handle(_m.halfedge_handle(*eit,0)));
167 const typename MeshType::Point from = _m.point(_m.from_vertex_handle(_m.halfedge_handle(*eit,0)));
169 real_t length = (to - from).sqrnorm();
172 if ( length > max_edge_length_squared_ )
173 queue.push( queueElement(*eit,length) );
177 while ( !stop && ! queue.empty() ) {
178 queueElement a = queue.top();
181 if ( a.second < max_edge_length_squared_ ) {
185 const typename MeshType::Point to = _m.point(_m.to_vertex_handle(_m.halfedge_handle(a.first,0)));
186 const typename MeshType::Point from = _m.point(_m.from_vertex_handle(_m.halfedge_handle(a.first,0)));
187 const typename MeshType::Point midpoint =
static_cast<typename MeshType::Point::value_type
>(0.5) * (to + from);
189 const typename MeshType::VertexHandle newVertex = _m.add_vertex(midpoint);
190 _m.split(a.first,newVertex);
192 for (
typename MeshType::VertexOHalfedgeIter voh_it(_m,newVertex); voh_it.is_valid(); ++voh_it) {
193 typename MeshType::EdgeHandle eh = _m.edge_handle(*voh_it);
194 const typename MeshType::Point to = _m.point(_m.to_vertex_handle(*voh_it));
195 const typename MeshType::Point from = _m.point(_m.from_vertex_handle(*voh_it));
196 real_t length = (to - from).sqrnorm();
199 if ( length > max_edge_length_squared_ )
200 queue.push( queueElement(eh,length) );
206 #if defined(_DEBUG) || defined(DEBUG) 217 real_t max_edge_length_squared_;
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
bool cleanup(mesh_t &_m)
Cleanup mesh after usage, e.g. remove added properties.
Definition: LongestEdgeT.hh:150
Uniform LongestEdgeT subdivision algorithm
Definition: LongestEdgeT.hh:105
const char * name() const
Return name of subdivision algorithm.
Definition: LongestEdgeT.hh:135
Abstract base class for uniform subdivision algorithms.
Definition: SubdividerT.hh:93
Check integrity of mesh.
Definition: MeshCheckerT.hh:78
Definition: LongestEdgeT.hh:86
bool prepare(mesh_t &_m)
Prepare mesh, e.g. add properties.
Definition: LongestEdgeT.hh:144
bool subdivide(MeshType &_m, size_t _n, const bool _update_points=true)
Subdivide mesh _m _n times.
Definition: LongestEdgeT.hh:156