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>
89template <
class Kernel>
101 static constexpr bool is_trimesh() {
return false; }
102 using ConnectivityTag = PolyConnectivityTag;
103 enum { IsPolyMesh = 1 };
104 enum { IsTriMesh = 0 };
112 typedef typename Kernel::Point
Point;
116 typedef typename Kernel::Color
Color;
128 typedef typename Kernel::Edge
Edge;
130 typedef typename Kernel::Face
Face;
208 template<
typename SH,
209 typename=
typename std::enable_if<std::is_base_of<SmartBaseHandle, SH>::value>::type>
230 this->set_point(vh, _p);
248 this->set_point(vh, _p);
293 const Point& _p2)
const;
429 return this->point(this->to_vertex_handle(_heh)) -
430 this->point(this->from_vertex_handle(_heh));
449 return sqrnorm(edge_vec);
458 return 0.5 * (this->point(vh0) + this->point(vh1));
490 Scalar denom = norm(v0)*norm(v1);
496 if (this->is_boundary(_in_heh))
498 FaceHandle fh(this->face_handle(this->opposite_halfedge_handle(_in_heh)));
501 return angle(cos_a, sign_a);
535 _sector_normal = cross(vec0, vec1);
545 return norm(sector_normal)/2;
553 assert(Kernel::has_face_normals());
555 if (this->is_boundary(this->edge_handle(_heh)))
559 const Normal& n0 = this->normal(this->face_handle(_heh));
560 const Normal& n1 = this->normal(this->face_handle(this->opposite_halfedge_handle(_heh)));
565 Scalar da_sin_sign =
dot(cross(n0, n1), he);
566 return angle(da_cos, da_sin_sign);
577 if (this->is_boundary(this->edge_handle(_heh)))
585 Scalar denom = norm(n0)*norm(n1);
592 Scalar da_sin_sign =
dot(cross(n0, n1), he);
593 return angle(da_cos, da_sin_sign);
610 { Kernel::split(_fh, _vh); }
616 { Kernel::split_edge(_eh, _vh); }
652template<
typename LHS,
typename KERNEL>
657template<
typename LHS,
typename KERNEL>
659 return MeshCast<LHS, PolyMeshT<KERNEL>*>::cast(rhs);
662template<
typename LHS,
typename KERNEL>
663const LHS
mesh_cast(
const PolyMeshT<KERNEL> &rhs) {
664 return MeshCast<LHS, const PolyMeshT<KERNEL>&>::cast(rhs);
667template<
typename LHS,
typename KERNEL>
668const LHS
mesh_cast(
const PolyMeshT<KERNEL> *rhs) {
669 return MeshCast<LHS, const PolyMeshT<KERNEL>*>::cast(rhs);
675#if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_POLYMESH_C)
676# define OPENMESH_POLYMESH_TEMPLATES
677# include "PolyMeshT_impl.hh"
Kernel::Vertex Vertex
Vertex type.
Kernel::FaceEdgeIter FaceEdgeIter
Circulator.
void calc_face_centroid(FaceHandle _fh, Point &_pt) const
calculates the average of the vertices defining _fh
Kernel::ConstFaceIter ConstFaceIter
Scalar type.
SH make_smart(SH const &sh) const
Return the passed smart handle. This allows for code using make_smart(h) to keep compiling when h's t...
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
auto make_smart(H const &h) const -> typename SmartHandle< H >::type const
Create a smart handle from a regular handle.
Kernel::Scalar Scalar
Scalar type.
Kernel::ConstVertexVertexIter ConstVertexVertexIter
Circulator.
void calc_edge_vector(HalfedgeHandle _heh, Normal &_edge_vec) const
SmartVertexHandle new_vertex(const Point _p)
Adds a new vertex initialized to a custom position.
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
Kernel::EdgeHandle EdgeHandle
Scalar type.
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
Kernel::Halfedge Halfedge
Halfedge type.
void calc_vertex_normal_fast(VertexHandle _vh, Normal &_n) const
void calc_vertex_normal_correct(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Scalar calc_dihedral_angle(EdgeHandle _eh) const
Compute normals for all primitives.
static constexpr bool is_polymesh()
Determine whether this is a PolyMeshT or TriMeshT (This function does not check the per face vertex c...
Kernel::FaceIter FaceIter
Scalar type.
Kernel::Normal Normal
Normal type.
Kernel::FaceVertexIter FaceVertexIter
Circulator.
Point calc_edge_midpoint(EdgeHandle _eh) const
SmartVertexHandle new_vertex()
Adds a new default-initialized vertex.
Kernel::VertexIHalfedgeIter VertexIHalfedgeIter
Circulator.
void split(FaceHandle _fh, VertexHandle _vh)
Compute normals for all primitives.
PolyMeshT(const T &t)
Circulator.
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
Scalar calc_sector_area(HalfedgeHandle _in_heh) const
void update_face_normals()
Update normal vectors for all faces.
void update_halfedge_normals(const double _feature_angle=0.8)
Update normal vectors for all halfedges.
unsigned int find_feature_edges(Scalar _angle_tresh=OpenMesh::deg_to_rad(44.0))
virtual Normal calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle=0.8) const
Calculate halfedge normal for one specific halfedge.
Scalar calc_sector_angle(HalfedgeHandle _in_heh) const
Kernel::ConstFaceEdgeIter ConstFaceEdgeIter
Circulator.
Kernel::TexCoord3D TexCoord3D
TexCoord3D type.
void update_normals()
Compute normals for all primitives.
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Point calc_centroid(FaceHandle _fh) const
Computes and returns the average of the vertices defining _fh (same as calc_face_centroid)
Kernel::VertexEdgeIter VertexEdgeIter
Circulator.
Scalar calc_dihedral_angle(HalfedgeHandle _heh) const
Compute normals for all primitives.
Kernel::Face Face
Face type.
Kernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Circulator.
virtual Normal calc_face_normal(FaceHandle _fh) const
Scalar calc_edge_length(EdgeHandle _eh) const
Compute normals for all primitives.
Kernel::ConstHalfedgeIter ConstHalfedgeIter
Scalar type.
void update_normal(VertexHandle _vh)
Update normal for vertex _vh.
Normal calc_face_normal_impl(FaceHandle, PointIs3DTag) const
Compute normals for all primitives.
void calc_sector_vectors(HalfedgeHandle _in_heh, Normal &_vec0, Normal &_vec1) const
SmartVertexHandle add_vertex_dirty(const Point _p)
Alias for new_vertex_dirty().
Kernel::FaceFaceIter FaceFaceIter
Circulator.
bool is_estimated_feature_edge(HalfedgeHandle _heh, const double _feature_angle) const
Normal calc_edge_vector(EdgeHandle _eh) const
virtual ~PolyMeshT()
Circulator.
Kernel::ConstVertexEdgeIter ConstVertexEdgeIter
Circulator.
Scalar calc_edge_sqr_length(HalfedgeHandle _heh) const
Compute normals for all primitives.
SmartVertexHandle add_vertex(const Point _p)
void calc_edge_vector(EdgeHandle _eh, Normal &_edge_vec) const
Kernel::Edge Edge
Edge type.
Kernel::FaceHandle FaceHandle
Scalar type.
void update_normal(FaceHandle _fh)
Update normal for face _fh.
Scalar calc_dihedral_angle_fast(EdgeHandle _eh) const
void calc_vertex_normal_loop(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
void split(EdgeHandle _eh, const Point &_p)
Compute normals for all primitives.
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Kernel::EdgeIter EdgeIter
Scalar type.
void update_normal(HalfedgeHandle _heh, const double _feature_angle=0.8)
Update normal for halfedge _heh.
Kernel::ConstEdgeIter ConstEdgeIter
Scalar type.
Kernel::ConstVertexIter ConstVertexIter
Scalar type.
void update_vertex_normals()
Update normal vectors for all vertices.
void calc_sector_normal(HalfedgeHandle _in_heh, Normal &_sector_normal) const
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Normal calc_edge_vector(HalfedgeHandle _heh) const
Scalar calc_edge_sqr_length(EdgeHandle _eh) const
Compute normals for all primitives.
Point calc_edge_midpoint(HalfedgeHandle _heh) const
Kernel::VertexVertexIter VertexVertexIter
Circulator.
void split(EdgeHandle _eh, VertexHandle _vh)
Compute normals for all primitives.
Kernel::HalfedgeIter HalfedgeIter
Scalar type.
Scalar calc_edge_length(HalfedgeHandle _heh) const
Kernel::FaceHalfedgeIter FaceHalfedgeIter
Circulator.
Kernel::Point Point
Coordinate type.
PolyMeshT< Kernel > This
Self type. Used to specify iterators/circulators.
Kernel::ConstFaceFaceIter ConstFaceFaceIter
Circulator.
void split(FaceHandle _fh, const Point &_p)
Face split (= 1-to-n split)
Kernel::Color Color
Color type.
Kernel::TexCoord1D TexCoord1D
TexCoord1D type.
Normal calc_normal(FaceHandle _fh) const
same as calc_face_normal
Kernel::VertexIter VertexIter
Scalar type.
SmartVertexHandle new_vertex_dirty(const Point _p)
Scalar calc_dihedral_angle_fast(HalfedgeHandle _heh) const
Normal calc_vertex_normal(VertexHandle _vh) const
Calculate vertex normal for one specific vertex.
SmartVertexHandle make_smart(VertexHandle _vh, const PolyConnectivity *_mesh)
Creats a SmartVertexHandle from a VertexHandle and a Mesh.
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
T angle(T _cos_angle, T _sin_angle)
LHS mesh_cast(PolyMeshT< KERNEL > &rhs)
Cast a mesh with different but identical traits into each other.
T sane_aarg(T _aarg)
Trigonometry/angles - related.
Handle for a edge entity.
Handle for a face entity.
Handle for a halfedge entity.
Cast a mesh with different but identical traits into each other.
Handle type for meshes to simplify some template programming.
Smart version of VertexHandle contains a pointer to the corresponding mesh and allows easier access t...
Handle for a vertex entity.