50 #ifndef OPENMESH_POLYMESHT_HH
51 #define OPENMESH_POLYMESHT_HH
57 #include <OpenMesh/Core/System/config.h>
58 #include <OpenMesh/Core/Geometry/MathDefs.hh>
59 #include <OpenMesh/Core/Mesh/PolyConnectivity.hh>
60 #include <OpenMesh/Core/Mesh/FinalMeshItemsT.hh>
86 template <
class Kernel>
96 enum { IsPolyMesh = 1 };
98 enum { IsTriMesh = 0 };
105 typedef typename Kernel::Scalar
Scalar;
108 typedef typename Kernel::Point
Point;
124 typedef typename Kernel::Edge
Edge;
126 typedef typename Kernel::Face
Face;
133 typedef typename Kernel::HalfedgeHandle HalfedgeHandle;
134 typedef typename Kernel::EdgeHandle EdgeHandle;
135 typedef typename Kernel::FaceHandle FaceHandle;
139 typedef typename Kernel::VertexIter VertexIter;
140 typedef typename Kernel::HalfedgeIter HalfedgeIter;
141 typedef typename Kernel::EdgeIter EdgeIter;
142 typedef typename Kernel::FaceIter FaceIter;
144 typedef typename Kernel::ConstVertexIter ConstVertexIter;
145 typedef typename Kernel::ConstHalfedgeIter ConstHalfedgeIter;
146 typedef typename Kernel::ConstEdgeIter ConstEdgeIter;
147 typedef typename Kernel::ConstFaceIter ConstFaceIter;
190 {
return Kernel::new_vertex(); }
192 inline VertexHandle
new_vertex(
const Point& _p)
194 VertexHandle vh(Kernel::new_vertex());
195 this->set_point(vh, _p);
199 inline VertexHandle add_vertex(
const Point& _p)
233 const Point& _p2)
const;
269 virtual Normal
calc_halfedge_normal(HalfedgeHandle _heh,
const double _feature_angle = 0.8)
const;
346 return this->point(this->to_vertex_handle(_heh)) -
347 this->point(this->from_vertex_handle(_heh));
351 Scalar calc_edge_length(EdgeHandle _eh)
const
352 {
return calc_edge_length(this->halfedge_handle(_eh,0)); }
357 {
return (Scalar)sqrt(calc_edge_sqr_length(_heh)); }
359 Scalar calc_edge_sqr_length(EdgeHandle _eh)
const
360 {
return calc_edge_sqr_length(this->halfedge_handle(_eh,0)); }
362 Scalar calc_edge_sqr_length(HalfedgeHandle _heh)
const
366 return edge_vec.sqrnorm();
388 Scalar denom = v0.norm()*v1.norm();
393 Scalar cos_a =
dot(v0 , v1) / denom;
394 if (this->is_boundary(_in_heh))
396 FaceHandle fh(this->face_handle(this->opposite_halfedge_handle(_in_heh)));
398 Scalar sign_a =
dot(
cross(v0, v1), f_n);
399 return angle(cos_a, sign_a);
433 _sector_normal =
cross(vec0, vec1);
441 Normal sector_normal;
443 return sector_normal.norm()/2;
451 assert(Kernel::has_face_normals());
453 if (this->is_boundary(this->edge_handle(_heh)))
457 const Normal& n0 = this->normal(this->face_handle(_heh));
458 const Normal& n1 = this->normal(this->face_handle(this->opposite_halfedge_handle(_heh)));
461 Scalar da_cos =
dot(n0, n1);
463 Scalar da_sin_sign =
dot(
cross(n0, n1), he);
464 return angle(da_cos, da_sin_sign);
473 Scalar calc_dihedral_angle(HalfedgeHandle _heh)
const
475 if (this->is_boundary(this->edge_handle(_heh)))
483 Scalar denom = n0.norm()*n1.norm();
488 Scalar da_cos =
dot(n0, n1)/denom;
490 Scalar da_sin_sign =
dot(
cross(n0, n1), he);
491 return angle(da_cos, da_sin_sign);
495 Scalar calc_dihedral_angle(EdgeHandle _eh)
const
496 {
return calc_dihedral_angle(this->halfedge_handle(_eh,0)); }
504 inline void split(FaceHandle _fh,
const Point& _p)
505 { Kernel::split(_fh, add_vertex(_p)); }
507 inline void split(FaceHandle _fh, VertexHandle _vh)
508 { Kernel::split(_fh, _vh); }
510 inline void split(EdgeHandle _eh,
const Point& _p)
511 { Kernel::split_edge(_eh, add_vertex(_p)); }
513 inline void split(EdgeHandle _eh, VertexHandle _vh)
514 { Kernel::split_edge(_eh, _vh); }
543 template<
typename LHS,
typename KERNEL>
548 template<
typename LHS,
typename KERNEL>
550 return MeshCast<LHS, PolyMeshT<KERNEL>*>::cast(rhs);
553 template<
typename LHS,
typename KERNEL>
554 const LHS
mesh_cast(
const PolyMeshT<KERNEL> &rhs) {
555 return MeshCast<LHS, const PolyMeshT<KERNEL>&>::cast(rhs);
558 template<
typename LHS,
typename KERNEL>
559 const LHS
mesh_cast(
const PolyMeshT<KERNEL> *rhs) {
560 return MeshCast<LHS, const PolyMeshT<KERNEL>*>::cast(rhs);
567 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_POLYMESH_C)
568 # define OPENMESH_POLYMESH_TEMPLATES
569 # include "PolyMeshT.cc"
572 #endif // OPENMESH_POLYMESHT_HH defined
void calc_edge_vector(EdgeHandle _eh, Normal &_edge_vec) const
Calculates the edge vector as the vector defined by the halfedge with id #0 (see below) ...
Definition: PolyMeshT.hh:323
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Definition: PolyMeshT.hh:158
void calc_vertex_normal_loop(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Definition: PolyMeshT.cc:371
Scalar calc_dihedral_angle_fast(EdgeHandle _eh) const
calculates the dihedral angle on the edge _eh
Definition: PolyMeshT.hh:469
Kernel::ConstVertexEdgeIter ConstVertexEdgeIter
Circulator.
Definition: PolyMeshT.hh:171
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:169
void update_face_normals()
Update normal vectors for all faces.
Definition: PolyMeshT.cc:205
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:81
Scalar calc_sector_angle(HalfedgeHandle _in_heh) const
calculates the sector angle.
Definition: PolyMeshT.hh:384
void update_halfedge_normals(const double _feature_angle=0.8)
Update normal vectors for all halfedges.
Definition: PolyMeshT.cc:220
void update_normals()
Compute normals for all primitives.
Definition: PolyMeshT.cc:187
static bool is_trimesh()
Determine whether this is a PolyMeshT or TriMeshT ( This function does not check the per face vertex ...
Definition: PolyMeshT.hh:100
Cast a mesh with different but identical traits into each other.
Definition: FinalMeshItemsT.hh:176
void calc_sector_vectors(HalfedgeHandle _in_heh, Normal &_vec0, Normal &_vec1) const
defines a consistent representation of a sector geometry: the halfedge _in_heh defines the sector ori...
Definition: PolyMeshT.hh:373
static bool is_polymesh()
Determine whether this is a PolyMeshT or TriMeshT ( This function does not check the per face vertex ...
Definition: PolyMeshT.hh:99
Add 2D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:85
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:174
void calc_face_centroid(FaceHandle _fh, Point &_pt) const
calculates the average of the vertices defining _fh
Definition: PolyMeshT.hh:235
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:56
Normal calc_edge_vector(HalfedgeHandle _heh) const
Calculates the edge vector as the difference of the the points defined by to_vertex_handle() and from...
Definition: PolyMeshT.hh:344
Add 1D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:84
void split(FaceHandle _fh, const Point &_p)
Face split (= 1-to-n split)
Definition: PolyMeshT.hh:504
void calc_vertex_normal_correct(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Definition: PolyMeshT.cc:343
void update_normal(VertexHandle _vh)
Update normal for vertex _vh.
Definition: PolyMeshT.hh:277
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:110
Kernel::Halfedge Halfedge
Halfedge type.
Definition: PolyMeshT.hh:122
Scalar calc_dihedral_angle_fast(HalfedgeHandle _heh) const
calculates the dihedral angle on the halfedge _heh
Definition: PolyMeshT.hh:448
bool is_zero(const T &_a, Real _eps)
comparison operators with user-selected precision control
Definition: MathDefs.hh:58
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:159
Kernel::FaceFaceIter FaceFaceIter
Circulator.
Definition: PolyMeshT.hh:166
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Definition: PolyMeshT.hh:162
void update_normal(FaceHandle _fh)
Update normal for face _fh.
Definition: PolyMeshT.hh:218
Kernel::ConstFaceFaceIter ConstFaceFaceIter
Circulator.
Definition: PolyMeshT.hh:176
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
Definition: PolyMeshT.hh:116
void update_vertex_normals()
Update normal vectors for all vertices.
Definition: PolyMeshT.cc:394
void calc_sector_normal(HalfedgeHandle _in_heh, Normal &_sector_normal) const
calculates the normal (non-normalized) of the face sector defined by the angle <(_in_heh,next_halfedge(_in_heh))
Definition: PolyMeshT.hh:429
Normal calc_vertex_normal(VertexHandle _vh) const
Calculate vertex normal for one specific vertex.
Definition: PolyMeshT.cc:319
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:106
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
Definition: PolyMeshT.hh:173
Base type for a polygonal mesh.
Definition: PolyMeshT.hh:87
void calc_edge_vector(HalfedgeHandle _heh, Normal &_edge_vec) const
Calculates the edge vector as the difference of the the points defined by to_vertex_handle() and from...
Definition: PolyMeshT.hh:337
Kernel::Edge Edge
Edge type.
Definition: PolyMeshT.hh:124
PolyMeshT< Kernel > This
Self type. Used to specify iterators/circulators.
Definition: PolyMeshT.hh:92
Kernel::ConstFaceEdgeIter ConstFaceEdgeIter
Circulator.
Definition: PolyMeshT.hh:175
Scalar calc_edge_length(HalfedgeHandle _heh) const
Calculates the length of the edge _heh.
Definition: PolyMeshT.hh:356
Kernel::VertexEdgeIter VertexEdgeIter
Circulator.
Definition: PolyMeshT.hh:161
Kernel::ConstVertexVertexIter ConstVertexVertexIter
Circulator.
Definition: PolyMeshT.hh:168
Kernel::Face Face
Face type.
Definition: PolyMeshT.hh:126
VertexHandle new_vertex()
Uses default copy and assignment operator.
Definition: PolyMeshT.hh:189
LHS mesh_cast(PolyMeshT< KERNEL > &rhs)
Cast a mesh with different but identical traits into each other.
Definition: PolyMeshT.hh:544
void update_normal(HalfedgeHandle _heh, const double _feature_angle=0.8)
Update normal for halfedge _heh.
Definition: PolyMeshT.hh:243
Kernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:170
osg::Vec3f cross(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:189
T sane_aarg(T _aarg)
Trigonometry/angles - related.
Definition: MathDefs.hh:119
T angle(T _cos_angle, T _sin_angle)
returns the angle determined by its cos and the sign of its sin result is positive if the angle is in...
Definition: MathDefs.hh:137
Add 3D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:86
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:132
unsigned int find_feature_edges(Scalar _angle_tresh=OpenMesh::deg_to_rad(44.0))
tags an edge as a feature if its dihedral angle is larger than _angle_tresh returns the number of the...
Definition: PolyMeshT.cc:70
Kernel::Color Color
Color type.
Definition: PolyMeshT.hh:112
Scalar calc_sector_area(HalfedgeHandle _in_heh) const
calculates the area of the face sector defined by the angle <(_in_heh,next_halfedge(_in_heh)) NOTE: s...
Definition: PolyMeshT.hh:439
virtual Normal calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle=0.8) const
Calculate halfedge normal for one specific halfedge.
Definition: PolyMeshT.cc:235
Kernel::VertexIHalfedgeIter VertexIHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:160
Kernel::FaceVertexIter FaceVertexIter
Circulator.
Definition: PolyMeshT.hh:163
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:174
bool is_estimated_feature_edge(HalfedgeHandle _heh, const double _feature_angle) const
identifies feature edges w.r.t.
Definition: PolyMeshT.cc:288
Normal calc_edge_vector(EdgeHandle _eh) const
Calculates the edge vector as the vector defined by the halfedge with id #0 (see below) ...
Definition: PolyMeshT.hh:330
Kernel::TexCoord1D TexCoord1D
TexCoord1D type.
Definition: PolyMeshT.hh:114
Kernel::FaceEdgeIter FaceEdgeIter
Circulator.
Definition: PolyMeshT.hh:165
Kernel::Vertex Vertex
Vertex type.
Definition: PolyMeshT.hh:120
void calc_vertex_normal_fast(VertexHandle _vh, Normal &_n) const
Different methods for calculation of the normal at _vh:
Definition: PolyMeshT.cc:333
Kernel::TexCoord3D TexCoord3D
TexCoord3D type.
Definition: PolyMeshT.hh:118
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
Definition: PolyMeshT.hh:172
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:108
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:80
virtual Normal calc_face_normal(FaceHandle _fh) const
Calculate normal vector for face _fh.
Definition: PolyMeshT.cc:94
Kernel::FaceHalfedgeIter FaceHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:164