57#ifndef OPENMESH_POLYMESHT_HH
58#define OPENMESH_POLYMESHT_HH
64#include <OpenMesh/Core/System/config.h>
65#include <OpenMesh/Core/Geometry/MathDefs.hh>
66#include <OpenMesh/Core/Mesh/PolyConnectivity.hh>
67#include <OpenMesh/Core/Mesh/FinalMeshItemsT.hh>
93template <
class Kernel>
104 enum { IsPolyMesh = 1 };
105 enum { IsTriMesh = 0 };
106 static bool is_polymesh() {
return true; }
107 static bool is_trimesh() {
return false; }
115 typedef typename Kernel::Point
Point;
119 typedef typename Kernel::Color
Color;
131 typedef typename Kernel::Edge
Edge;
133 typedef typename Kernel::Face
Face;
203 {
return Kernel::new_vertex(); }
213 this->set_point(vh, _p);
231 this->set_point(vh, _p);
274 const Point& _p2)
const;
387 return this->point(this->to_vertex_handle(_heh)) -
388 this->point(this->from_vertex_handle(_heh));
407 return edge_vec.sqrnorm();
429 Scalar denom = v0.norm()*v1.norm();
435 if (this->is_boundary(_in_heh))
437 FaceHandle fh(this->face_handle(this->opposite_halfedge_handle(_in_heh)));
440 return angle(cos_a, sign_a);
474 _sector_normal = cross(vec0, vec1);
484 return sector_normal.norm()/2;
492 assert(Kernel::has_face_normals());
494 if (this->is_boundary(this->edge_handle(_heh)))
498 const Normal& n0 = this->normal(this->face_handle(_heh));
499 const Normal& n1 = this->normal(this->face_handle(this->opposite_halfedge_handle(_heh)));
504 Scalar da_sin_sign =
dot(cross(n0, n1), he);
505 return angle(da_cos, da_sin_sign);
516 if (this->is_boundary(this->edge_handle(_heh)))
524 Scalar denom = n0.norm()*n1.norm();
531 Scalar da_sin_sign =
dot(cross(n0, n1), he);
532 return angle(da_cos, da_sin_sign);
549 { Kernel::split(_fh, _vh); }
555 { Kernel::split_edge(_eh, _vh); }
558 struct PointIs3DTag {};
559 struct PointIsNot3DTag {};
591template<
typename LHS,
typename KERNEL>
596template<
typename LHS,
typename KERNEL>
598 return MeshCast<LHS, PolyMeshT<KERNEL>*>::cast(rhs);
601template<
typename LHS,
typename KERNEL>
602const LHS
mesh_cast(
const PolyMeshT<KERNEL> &rhs) {
603 return MeshCast<LHS, const PolyMeshT<KERNEL>&>::cast(rhs);
606template<
typename LHS,
typename KERNEL>
607const LHS
mesh_cast(
const PolyMeshT<KERNEL> *rhs) {
608 return MeshCast<LHS, const PolyMeshT<KERNEL>*>::cast(rhs);
614#if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_POLYMESH_C)
615# define OPENMESH_POLYMESH_TEMPLATES
616# include "PolyMeshT.cc"
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:181
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:145
bool is_zero(const T &_a, Real _eps)
comparison operators with user-selected precision control
Definition: MathDefs.hh:66
LHS mesh_cast(PolyMeshT< KERNEL > &rhs)
Cast a mesh with different but identical traits into each other.
Definition: PolyMeshT.hh:592
T sane_aarg(T _aarg)
Trigonometry/angles - related.
Definition: MathDefs.hh:127
Cast a mesh with different but identical traits into each other.
Definition: FinalMeshItemsT.hh:183
Handle for a vertex entity.
Definition: Handles.hh:126
Handle for a halfedge entity.
Definition: Handles.hh:133
Handle for a face entity.
Definition: Handles.hh:147
Base type for a polygonal mesh.
Definition: PolyMeshT.hh:95
Kernel::Vertex Vertex
Vertex type.
Definition: PolyMeshT.hh:127
Kernel::FaceEdgeIter FaceEdgeIter
Circulator.
Definition: PolyMeshT.hh:172
void calc_face_centroid(FaceHandle _fh, Point &_pt) const
calculates the average of the vertices defining _fh
Definition: PolyMeshT.hh:276
Kernel::ConstFaceIter ConstFaceIter
Scalar type.
Definition: PolyMeshT.hh:154
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:139
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:113
Kernel::ConstVertexVertexIter ConstVertexVertexIter
Circulator.
Definition: PolyMeshT.hh:175
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:378
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:181
Kernel::EdgeHandle EdgeHandle
Scalar type.
Definition: PolyMeshT.hh:141
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Definition: PolyMeshT.hh:169
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
Definition: PolyMeshT.hh:180
Kernel::Halfedge Halfedge
Halfedge type.
Definition: PolyMeshT.hh:129
void calc_vertex_normal_fast(VertexHandle _vh, Normal &_n) const
Different methods for calculation of the normal at _vh:
Definition: PolyMeshT.cc:387
void calc_vertex_normal_correct(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Definition: PolyMeshT.cc:397
PolyMeshT()
Circulator.
Definition: PolyMeshT.hh:188
Scalar calc_dihedral_angle(EdgeHandle _eh) const
Compute normals for all primitives.
Definition: PolyMeshT.hh:536
Kernel::FaceIter FaceIter
Scalar type.
Definition: PolyMeshT.hh:149
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:117
Kernel::FaceVertexIter FaceVertexIter
Circulator.
Definition: PolyMeshT.hh:170
Kernel::VertexIHalfedgeIter VertexIHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:167
void split(FaceHandle _fh, VertexHandle _vh)
Compute normals for all primitives.
Definition: PolyMeshT.hh:548
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
Definition: PolyMeshT.hh:123
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:480
void update_face_normals()
Update normal vectors for all faces.
Definition: PolyMeshT.cc:259
void update_halfedge_normals(const double _feature_angle=0.8)
Update normal vectors for all halfedges.
Definition: PolyMeshT.cc:274
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:79
virtual Normal calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle=0.8) const
Calculate halfedge normal for one specific halfedge.
Definition: PolyMeshT.cc:289
Scalar calc_sector_angle(HalfedgeHandle _in_heh) const
calculates the sector angle.
Definition: PolyMeshT.hh:425
Kernel::ConstFaceEdgeIter ConstFaceEdgeIter
Circulator.
Definition: PolyMeshT.hh:182
Kernel::TexCoord3D TexCoord3D
TexCoord3D type.
Definition: PolyMeshT.hh:125
void update_normals()
Compute normals for all primitives.
Definition: PolyMeshT.cc:241
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
Definition: PolyMeshT.hh:179
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:166
Kernel::VertexEdgeIter VertexEdgeIter
Circulator.
Definition: PolyMeshT.hh:168
Scalar calc_dihedral_angle(HalfedgeHandle _heh) const
Compute normals for all primitives.
Definition: PolyMeshT.hh:514
Kernel::Face Face
Face type.
Definition: PolyMeshT.hh:133
Kernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:177
virtual Normal calc_face_normal(FaceHandle _fh) const
Calculate normal vector for face _fh.
Definition: PolyMeshT.cc:102
VertexHandle new_vertex(const Point &_p)
Adds a new vertex initialized to a custom position.
Definition: PolyMeshT.hh:210
Scalar calc_edge_length(EdgeHandle _eh) const
Compute normals for all primitives.
Definition: PolyMeshT.hh:392
Kernel::ConstHalfedgeIter ConstHalfedgeIter
Scalar type.
Definition: PolyMeshT.hh:152
VertexHandle new_vertex_dirty(const Point &_p)
Same as new_vertex(const Point&) but never shrinks, only enlarges the vertex property vectors.
Definition: PolyMeshT.hh:228
void update_normal(VertexHandle _vh)
Update normal for vertex _vh.
Definition: PolyMeshT.hh:318
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:414
Kernel::FaceFaceIter FaceFaceIter
Circulator.
Definition: PolyMeshT.hh:173
bool is_estimated_feature_edge(HalfedgeHandle _heh, const double _feature_angle) const
identifies feature edges w.r.t.
Definition: PolyMeshT.cc:342
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:371
virtual ~PolyMeshT()
Circulator.
Definition: PolyMeshT.hh:189
Kernel::ConstVertexEdgeIter ConstVertexEdgeIter
Circulator.
Definition: PolyMeshT.hh:178
Scalar calc_edge_sqr_length(HalfedgeHandle _heh) const
Compute normals for all primitives.
Definition: PolyMeshT.hh:403
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:364
Kernel::Edge Edge
Edge type.
Definition: PolyMeshT.hh:131
Kernel::FaceHandle FaceHandle
Scalar type.
Definition: PolyMeshT.hh:142
void update_normal(FaceHandle _fh)
Update normal for face _fh.
Definition: PolyMeshT.hh:259
Scalar calc_dihedral_angle_fast(EdgeHandle _eh) const
calculates the dihedral angle on the edge _eh
Definition: PolyMeshT.hh:510
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Definition: PolyMeshT.hh:236
void calc_vertex_normal_loop(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Definition: PolyMeshT.cc:425
void split(EdgeHandle _eh, const Point &_p)
Compute normals for all primitives.
Definition: PolyMeshT.hh:551
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Definition: PolyMeshT.hh:140
Kernel::EdgeIter EdgeIter
Scalar type.
Definition: PolyMeshT.hh:148
void update_normal(HalfedgeHandle _heh, const double _feature_angle=0.8)
Update normal for halfedge _heh.
Definition: PolyMeshT.hh:284
Kernel::ConstEdgeIter ConstEdgeIter
Scalar type.
Definition: PolyMeshT.hh:153
Kernel::ConstVertexIter ConstVertexIter
Scalar type.
Definition: PolyMeshT.hh:151
void update_vertex_normals()
Update normal vectors for all vertices.
Definition: PolyMeshT.cc:448
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,...
Definition: PolyMeshT.hh:470
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:176
VertexHandle add_vertex_dirty(const Point &_p)
Alias for new_vertex_dirty().
Definition: PolyMeshT.hh:240
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:385
Scalar calc_edge_sqr_length(EdgeHandle _eh) const
Compute normals for all primitives.
Definition: PolyMeshT.hh:400
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Definition: PolyMeshT.hh:165
void split(EdgeHandle _eh, VertexHandle _vh)
Compute normals for all primitives.
Definition: PolyMeshT.hh:554
Kernel::HalfedgeIter HalfedgeIter
Scalar type.
Definition: PolyMeshT.hh:147
Scalar calc_edge_length(HalfedgeHandle _heh) const
Calculates the length of the edge _heh.
Definition: PolyMeshT.hh:397
Kernel::FaceHalfedgeIter FaceHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:171
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:115
VertexHandle new_vertex()
Uses default copy and assignment operator.
Definition: PolyMeshT.hh:202
PolyMeshT< Kernel > This
Self type. Used to specify iterators/circulators.
Definition: PolyMeshT.hh:99
Kernel::ConstFaceFaceIter ConstFaceFaceIter
Circulator.
Definition: PolyMeshT.hh:183
void split(FaceHandle _fh, const Point &_p)
Face split (= 1-to-n split)
Definition: PolyMeshT.hh:545
Kernel::Color Color
Color type.
Definition: PolyMeshT.hh:119
Kernel::TexCoord1D TexCoord1D
TexCoord1D type.
Definition: PolyMeshT.hh:121
Kernel::VertexIter VertexIter
Scalar type.
Definition: PolyMeshT.hh:146
Scalar calc_dihedral_angle_fast(HalfedgeHandle _heh) const
calculates the dihedral angle on the halfedge _heh
Definition: PolyMeshT.hh:489
Normal calc_vertex_normal(VertexHandle _vh) const
Calculate vertex normal for one specific vertex.
Definition: PolyMeshT.cc:373