52 #ifndef OPENMESH_POLYMESHT_HH 53 #define OPENMESH_POLYMESHT_HH 60 #include <OpenMesh/Core/Geometry/MathDefs.hh> 61 #include <OpenMesh/Core/Mesh/PolyConnectivity.hh> 62 #include <OpenMesh/Core/Mesh/FinalMeshItemsT.hh> 63 #include <OpenMesh/Core/Mesh/Tags.hh> 89 template <
class Kernel>
99 static constexpr
bool is_polymesh() {
return true; }
103 enum { IsPolyMesh = 1 };
104 enum { IsTriMesh = 0 };
109 typedef typename Kernel::Scalar
Scalar;
112 typedef typename Kernel::Point
Point;
128 typedef typename Kernel::Edge
Edge;
130 typedef typename Kernel::Face
Face;
137 typedef typename Kernel::HalfedgeHandle HalfedgeHandle;
138 typedef typename Kernel::EdgeHandle EdgeHandle;
139 typedef typename Kernel::FaceHandle FaceHandle;
143 typedef typename Kernel::VertexIter VertexIter;
144 typedef typename Kernel::HalfedgeIter HalfedgeIter;
145 typedef typename Kernel::EdgeIter EdgeIter;
146 typedef typename Kernel::FaceIter FaceIter;
148 typedef typename Kernel::ConstVertexIter ConstVertexIter;
149 typedef typename Kernel::ConstHalfedgeIter ConstHalfedgeIter;
150 typedef typename Kernel::ConstEdgeIter ConstEdgeIter;
151 typedef typename Kernel::ConstFaceIter ConstFaceIter;
187 explicit PolyMeshT(
const T& t) : Kernel(t) {}
202 {
return Kernel::new_vertex(); }
211 VertexHandle vh(Kernel::new_vertex());
212 this->set_point(vh, _p);
229 VertexHandle vh(Kernel::new_vertex_dirty());
230 this->set_point(vh, _p);
273 const Point& _p2)
const;
309 virtual Normal
calc_halfedge_normal(HalfedgeHandle _heh,
const double _feature_angle = 0.8)
const;
386 return this->point(this->to_vertex_handle(_heh)) -
387 this->point(this->from_vertex_handle(_heh));
391 Scalar calc_edge_length(EdgeHandle _eh)
const 392 {
return calc_edge_length(this->halfedge_handle(_eh,0)); }
397 {
return (Scalar)sqrt(calc_edge_sqr_length(_heh)); }
399 Scalar calc_edge_sqr_length(EdgeHandle _eh)
const 400 {
return calc_edge_sqr_length(this->halfedge_handle(_eh,0)); }
402 Scalar calc_edge_sqr_length(HalfedgeHandle _heh)
const 406 return sqrnorm(edge_vec);
413 VertexHandle vh0 = this->from_vertex_handle(_heh);
414 VertexHandle vh1 = this->to_vertex_handle(_heh);
415 return 0.5 * (this->point(vh0) + this->point(vh1));
444 Scalar denom = norm(v0)*norm(v1);
449 Scalar cos_a =
dot(v0 , v1) / denom;
450 if (this->is_boundary(_in_heh))
452 FaceHandle fh(this->face_handle(this->opposite_halfedge_handle(_in_heh)));
454 Scalar sign_a =
dot(
cross(v0, v1), f_n);
455 return angle(cos_a, sign_a);
489 _sector_normal =
cross(vec0, vec1);
497 Normal sector_normal;
499 return norm(sector_normal)/2;
507 assert(Kernel::has_face_normals());
509 if (this->is_boundary(this->edge_handle(_heh)))
513 const Normal& n0 = this->normal(this->face_handle(_heh));
514 const Normal& n1 = this->normal(this->face_handle(this->opposite_halfedge_handle(_heh)));
517 Scalar da_cos =
dot(n0, n1);
519 Scalar da_sin_sign =
dot(
cross(n0, n1), he);
520 return angle(da_cos, da_sin_sign);
529 Scalar calc_dihedral_angle(HalfedgeHandle _heh)
const 531 if (this->is_boundary(this->edge_handle(_heh)))
539 Scalar denom = norm(n0)*norm(n1);
544 Scalar da_cos =
dot(n0, n1)/denom;
546 Scalar da_sin_sign =
dot(
cross(n0, n1), he);
547 return angle(da_cos, da_sin_sign);
551 Scalar calc_dihedral_angle(EdgeHandle _eh)
const 552 {
return calc_dihedral_angle(this->halfedge_handle(_eh,0)); }
560 inline void split(FaceHandle _fh,
const Point& _p)
563 inline void split(FaceHandle _fh, VertexHandle _vh)
564 { Kernel::split(_fh, _vh); }
566 inline void split(EdgeHandle _eh,
const Point& _p)
569 inline void split(EdgeHandle _eh, VertexHandle _vh)
570 { Kernel::split_edge(_eh, _vh); }
575 Normal calc_face_normal_impl(FaceHandle,
PointIs3DTag)
const;
577 Normal calc_face_normal_impl(
const Point&,
const Point&,
const Point&,
PointIs3DTag)
const;
578 Normal calc_face_normal_impl(
const Point&,
const Point&,
const Point&,
PointIsNot3DTag)
const;
606 template<
typename LHS,
typename KERNEL>
611 template<
typename LHS,
typename KERNEL>
616 template<
typename LHS,
typename KERNEL>
621 template<
typename LHS,
typename KERNEL>
629 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_POLYMESH_C) 630 # define OPENMESH_POLYMESH_TEMPLATES 631 # include "PolyMeshT_impl.hh" 634 #endif // OPENMESH_POLYMESHT_HH defined virtual Normal calc_face_normal(FaceHandle _fh) const
void update_normal(HalfedgeHandle _heh, const double _feature_angle=0.8)
Update normal for halfedge _heh.
Kernel::Halfedge Halfedge
Halfedge type.
void calc_sector_normal(HalfedgeHandle _in_heh, Normal &_sector_normal) const
void calc_vertex_normal_loop(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
T sane_aarg(T _aarg)
Trigonometry/angles - related.
Add 1D texture coordinates (vertices, halfedges)
VertexHandle new_vertex_dirty(const Point &_p)
VertexHandle new_vertex()
Adds a new default-initialized vertex.
Kernel::VertexIHalfedgeIter VertexIHalfedgeIter
Circulator.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
Scalar calc_sector_area(HalfedgeHandle _in_heh) const
LHS mesh_cast(PolyMeshT< KERNEL > &rhs)
Cast a mesh with different but identical traits into each other.
Kernel::Point Point
Coordinate type.
static constexpr bool is_polymesh()
Determine whether this is a PolyMeshT or TriMeshT (This function does not check the per face vertex c...
osg::Vec3f cross(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Scalar calc_sector_angle(HalfedgeHandle _in_heh) const
Kernel::Color Color
Color type.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Scalar calc_edge_length(HalfedgeHandle _heh) const
void calc_sector_vectors(HalfedgeHandle _in_heh, Normal &_vec0, Normal &_vec1) const
Kernel::VertexEdgeIter VertexEdgeIter
Circulator.
Kernel::ConstFaceFaceIter ConstFaceFaceIter
Circulator.
Kernel::Face Face
Face type.
Kernel::Scalar Scalar
Scalar type.
void calc_face_centroid(FaceHandle _fh, Point &_pt) const
calculates the average of the vertices defining _fh
void update_normal(VertexHandle _vh)
Update normal for vertex _vh.
Normal calc_edge_vector(HalfedgeHandle _heh) const
VertexHandle new_vertex(const Point &_p)
Adds a new vertex initialized to a custom position.
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
Point calc_edge_midpoint(HalfedgeHandle _heh) const
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Kernel::FaceVertexIter FaceVertexIter
Circulator.
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
PolyMeshT< Kernel > This
Self type. Used to specify iterators/circulators.
Add colors to mesh item (vertices/faces/edges)
Scalar calc_dihedral_angle_fast(HalfedgeHandle _heh) const
Kernel::TexCoord1D TexCoord1D
TexCoord1D type.
VertexHandle add_vertex_dirty(const Point &_p)
Alias for new_vertex_dirty().
Normal calc_edge_vector(EdgeHandle _eh) const
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
void update_vertex_normals()
Update normal vectors for all vertices.
Add 3D texture coordinates (vertices, halfedges)
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
T angle(T _cos_angle, T _sin_angle)
static constexpr bool is_trimesh()
Determine whether this is a PolyMeshT or TriMeshT (This function does not check the per face vertex c...
Kernel::FaceEdgeIter FaceEdgeIter
Circulator.
void update_normal(FaceHandle _fh)
Update normal for face _fh.
void calc_vertex_normal_correct(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Kernel::Normal Normal
Normal type.
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::FaceFaceIter FaceFaceIter
Circulator.
Add 2D texture coordinates (vertices, halfedges)
void update_halfedge_normals(const double _feature_angle=0.8)
Update normal vectors for all halfedges.
Kernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Circulator.
bool is_estimated_feature_edge(HalfedgeHandle _heh, const double _feature_angle) const
void calc_edge_vector(EdgeHandle _eh, Normal &_edge_vec) const
Connectivity tag indicating that the tagged mesh has polygon connectivity.
Point calc_edge_midpoint(EdgeHandle _eh) const
Kernel::TexCoord3D TexCoord3D
TexCoord3D type.
Kernel::FaceHalfedgeIter FaceHalfedgeIter
Circulator.
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
void update_face_normals()
Update normal vectors for all faces.
Scalar calc_dihedral_angle_fast(EdgeHandle _eh) const
virtual Normal calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle=0.8) const
Calculate halfedge normal for one specific halfedge.
Kernel::Vertex Vertex
Vertex type.
Normal calc_vertex_normal(VertexHandle _vh) const
Calculate vertex normal for one specific vertex.
void split(FaceHandle _fh, const Point &_p)
Face split (= 1-to-n split)
Kernel::ConstVertexEdgeIter ConstVertexEdgeIter
Circulator.
Kernel::ConstVertexVertexIter ConstVertexVertexIter
Circulator.
Kernel::ConstFaceEdgeIter ConstFaceEdgeIter
Circulator.
Kernel::Edge Edge
Edge type.
void update_normals()
Compute normals for all primitives.
void calc_edge_vector(HalfedgeHandle _heh, Normal &_edge_vec) const
void calc_vertex_normal_fast(VertexHandle _vh, Normal &_n) const