57 #ifndef OPENMESH_POLYMESHT_HH
58 #define OPENMESH_POLYMESHT_HH
65 #include <OpenMesh/Core/Geometry/MathDefs.hh>
66 #include <OpenMesh/Core/Mesh/PolyConnectivity.hh>
67 #include <OpenMesh/Core/Mesh/FinalMeshItemsT.hh>
93 template <
class Kernel>
103 enum { IsPolyMesh = 1 };
105 enum { IsTriMesh = 0 };
112 typedef typename Kernel::Scalar
Scalar;
115 typedef typename Kernel::Point
Point;
131 typedef typename Kernel::Edge
Edge;
133 typedef typename Kernel::Face
Face;
140 typedef typename Kernel::HalfedgeHandle HalfedgeHandle;
141 typedef typename Kernel::EdgeHandle EdgeHandle;
142 typedef typename Kernel::FaceHandle FaceHandle;
146 typedef typename Kernel::VertexIter VertexIter;
147 typedef typename Kernel::HalfedgeIter HalfedgeIter;
148 typedef typename Kernel::EdgeIter EdgeIter;
149 typedef typename Kernel::FaceIter FaceIter;
151 typedef typename Kernel::ConstVertexIter ConstVertexIter;
152 typedef typename Kernel::ConstHalfedgeIter ConstHalfedgeIter;
153 typedef typename Kernel::ConstEdgeIter ConstEdgeIter;
154 typedef typename Kernel::ConstFaceIter ConstFaceIter;
203 {
return Kernel::new_vertex(); }
212 VertexHandle vh(Kernel::new_vertex());
213 this->set_point(vh, _p);
230 VertexHandle vh(Kernel::new_vertex_dirty());
231 this->set_point(vh, _p);
274 const Point& _p2)
const;
310 virtual Normal
calc_halfedge_normal(HalfedgeHandle _heh,
const double _feature_angle = 0.8)
const;
387 return this->point(this->to_vertex_handle(_heh)) -
388 this->point(this->from_vertex_handle(_heh));
392 Scalar calc_edge_length(EdgeHandle _eh)
const
393 {
return calc_edge_length(this->halfedge_handle(_eh,0)); }
398 {
return (Scalar)sqrt(calc_edge_sqr_length(_heh)); }
400 Scalar calc_edge_sqr_length(EdgeHandle _eh)
const
401 {
return calc_edge_sqr_length(this->halfedge_handle(_eh,0)); }
403 Scalar calc_edge_sqr_length(HalfedgeHandle _heh)
const
407 return edge_vec.sqrnorm();
429 Scalar denom = v0.norm()*v1.norm();
434 Scalar cos_a =
dot(v0 , v1) / denom;
435 if (this->is_boundary(_in_heh))
437 FaceHandle fh(this->face_handle(this->opposite_halfedge_handle(_in_heh)));
439 Scalar sign_a =
dot(
cross(v0, v1), f_n);
440 return angle(cos_a, sign_a);
474 _sector_normal =
cross(vec0, vec1);
482 Normal sector_normal;
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)));
502 Scalar da_cos =
dot(n0, n1);
504 Scalar da_sin_sign =
dot(
cross(n0, n1), he);
505 return angle(da_cos, da_sin_sign);
514 Scalar calc_dihedral_angle(HalfedgeHandle _heh)
const
516 if (this->is_boundary(this->edge_handle(_heh)))
524 Scalar denom = n0.norm()*n1.norm();
529 Scalar da_cos =
dot(n0, n1)/denom;
531 Scalar da_sin_sign =
dot(
cross(n0, n1), he);
532 return angle(da_cos, da_sin_sign);
536 Scalar calc_dihedral_angle(EdgeHandle _eh)
const
537 {
return calc_dihedral_angle(this->halfedge_handle(_eh,0)); }
545 inline void split(FaceHandle _fh,
const Point& _p)
548 inline void split(FaceHandle _fh, VertexHandle _vh)
549 { Kernel::split(_fh, _vh); }
551 inline void split(EdgeHandle _eh,
const Point& _p)
554 inline void split(EdgeHandle _eh, VertexHandle _vh)
555 { Kernel::split_edge(_eh, _vh); }
560 Normal calc_face_normal_impl(FaceHandle,
PointIs3DTag)
const;
562 Normal calc_face_normal_impl(
const Point&,
const Point&,
const Point&,
PointIs3DTag)
const;
563 Normal calc_face_normal_impl(
const Point&,
const Point&,
const Point&,
PointIsNot3DTag)
const;
591 template<
typename LHS,
typename KERNEL>
596 template<
typename LHS,
typename KERNEL>
598 return MeshCast<LHS, PolyMeshT<KERNEL>*>::cast(rhs);
601 template<
typename LHS,
typename KERNEL>
602 const LHS
mesh_cast(
const PolyMeshT<KERNEL> &rhs) {
603 return MeshCast<LHS, const PolyMeshT<KERNEL>&>::cast(rhs);
606 template<
typename LHS,
typename KERNEL>
607 const 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"
619 #endif // OPENMESH_POLYMESHT_HH defined
static bool is_polymesh()
Determine whether this is a PolyMeshT or TriMeshT ( This function does not check the per face vertex ...
Add colors to mesh item (vertices/faces/edges)
Kernel::ConstVertexEdgeIter ConstVertexEdgeIter
Circulator.
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
Kernel::ConstVertexVertexIter ConstVertexVertexIter
Circulator.
Normal calc_edge_vector(EdgeHandle _eh) const
Kernel::VertexIHalfedgeIter VertexIHalfedgeIter
Circulator.
VertexHandle new_vertex()
Adds a new default-initialized vertex.
Kernel::Color Color
Color type.
static bool is_trimesh()
Determine whether this is a PolyMeshT or TriMeshT ( This function does not check the per face vertex ...
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Kernel::ConstFaceEdgeIter ConstFaceEdgeIter
Circulator.
Kernel::FaceEdgeIter FaceEdgeIter
Circulator.
void calc_face_centroid(FaceHandle _fh, Point &_pt) const
calculates the average of the vertices defining _fh
void calc_edge_vector(HalfedgeHandle _heh, Normal &_edge_vec) const
Add 1D texture coordinates (vertices, halfedges)
Kernel::VertexVertexIter VertexVertexIter
Circulator.
virtual Normal calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle=0.8) const
Calculate halfedge normal for one specific halfedge.
Kernel::Face Face
Face type.
void update_halfedge_normals(const double _feature_angle=0.8)
Update normal vectors for all halfedges.
Kernel::Vertex Vertex
Vertex type.
void update_normal(FaceHandle _fh)
Update normal for face _fh.
Kernel::Point Point
Coordinate type.
osg::Vec3f cross(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Normal calc_vertex_normal(VertexHandle _vh) const
Calculate vertex normal for one specific vertex.
Cast a mesh with different but identical traits into each other.
unsigned int find_feature_edges(Scalar _angle_tresh=OpenMesh::deg_to_rad(44.0))
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
Kernel::FaceFaceIter FaceFaceIter
Circulator.
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
bool is_zero(const T &_a, Real _eps)
Kernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Circulator.
void calc_sector_normal(HalfedgeHandle _in_heh, Normal &_sector_normal) const
PolyMeshT< Kernel > This
Self type. Used to specify iterators/circulators.
VertexHandle new_vertex_dirty(const Point &_p)
Add 2D texture coordinates (vertices, halfedges)
Scalar calc_sector_area(HalfedgeHandle _in_heh) const
void update_vertex_normals()
Update normal vectors for all vertices.
Kernel::VertexEdgeIter VertexEdgeIter
Circulator.
void calc_vertex_normal_fast(VertexHandle _vh, Normal &_n) const
void update_face_normals()
Update normal vectors for all faces.
Kernel::Edge Edge
Edge type.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
void calc_vertex_normal_loop(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Kernel::TexCoord3D TexCoord3D
TexCoord3D type.
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Kernel::Scalar Scalar
Scalar type.
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
LHS mesh_cast(PolyMeshT< KERNEL > &rhs)
Cast a mesh with different but identical traits into each other.
void update_normal(HalfedgeHandle _heh, const double _feature_angle=0.8)
Update normal for halfedge _heh.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
void calc_vertex_normal_correct(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Kernel::TexCoord1D TexCoord1D
TexCoord1D type.
void update_normals()
Compute normals for all primitives.
Add normals to mesh item (vertices/faces)
Kernel::FaceVertexIter FaceVertexIter
Circulator.
Kernel::ConstFaceFaceIter ConstFaceFaceIter
Circulator.
VertexHandle add_vertex_dirty(const Point &_p)
Alias for new_vertex_dirty().
Scalar calc_sector_angle(HalfedgeHandle _in_heh) const
VertexHandle new_vertex(const Point &_p)
Adds a new vertex initialized to a custom position.
void calc_edge_vector(EdgeHandle _eh, Normal &_edge_vec) const
Scalar calc_dihedral_angle_fast(EdgeHandle _eh) const
Scalar calc_dihedral_angle_fast(HalfedgeHandle _heh) const
Kernel::FaceHalfedgeIter FaceHalfedgeIter
Circulator.
Add 3D texture coordinates (vertices, halfedges)
void split(FaceHandle _fh, const Point &_p)
Face split (= 1-to-n split)
void update_normal(VertexHandle _vh)
Update normal for vertex _vh.
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Kernel::Halfedge Halfedge
Halfedge type.
Scalar calc_edge_length(HalfedgeHandle _heh) const
bool is_estimated_feature_edge(HalfedgeHandle _heh, const double _feature_angle) const
T angle(T _cos_angle, T _sin_angle)
T sane_aarg(T _aarg)
Trigonometry/angles - related.
Kernel::Normal Normal
Normal type.
void calc_sector_vectors(HalfedgeHandle _in_heh, Normal &_vec0, Normal &_vec1) const
virtual Normal calc_face_normal(FaceHandle _fh) const
Normal calc_edge_vector(HalfedgeHandle _heh) const