52#ifndef OPENMESH_POLYMESHT_HH
53#define OPENMESH_POLYMESHT_HH
59#include <OpenMesh/Core/System/config.h>
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;
202 {
return make_smart(Kernel::new_vertex(),
this); }
213 this->set_point(vh, _p);
231 this->set_point(vh, _p);
276 const Point& _p2)
const;
412 return this->point(this->to_vertex_handle(_heh)) -
413 this->point(this->from_vertex_handle(_heh));
441 return 0.5 * (this->point(vh0) + this->point(vh1));
479 if (this->is_boundary(_in_heh))
481 FaceHandle fh(this->face_handle(this->opposite_halfedge_handle(_in_heh)));
484 return angle(cos_a, sign_a);
518 _sector_normal = cross(vec0, vec1);
528 return norm(sector_normal)/2;
536 assert(Kernel::has_face_normals());
538 if (this->is_boundary(this->edge_handle(_heh)))
542 const Normal& n0 = this->normal(this->face_handle(_heh));
543 const Normal& n1 = this->normal(this->face_handle(this->opposite_halfedge_handle(_heh)));
548 Scalar da_sin_sign =
dot(cross(n0, n1), he);
549 return angle(da_cos, da_sin_sign);
560 if (this->is_boundary(this->edge_handle(_heh)))
575 Scalar da_sin_sign =
dot(cross(n0, n1), he);
576 return angle(da_cos, da_sin_sign);
593 { Kernel::split(_fh, _vh); }
599 { Kernel::split_edge(_eh, _vh); }
602 struct PointIs3DTag {};
603 struct PointIsNot3DTag {};
635template<
typename LHS,
typename KERNEL>
640template<
typename LHS,
typename KERNEL>
642 return MeshCast<LHS, PolyMeshT<KERNEL>*>::cast(rhs);
645template<
typename LHS,
typename KERNEL>
650template<
typename LHS,
typename KERNEL>
658#if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_POLYMESH_C)
659# define OPENMESH_POLYMESH_TEMPLATES
660# include "PolyMeshT_impl.hh"
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:59
SmartVertexHandle make_smart(VertexHandle _vh, const PolyConnectivity *_mesh)
Creats a SmartVertexHandle from a VertexHandle and a Mesh.
Definition SmartHandles.hh:265
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition VectorAdapter.hh:176
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:140
LHS mesh_cast(PolyMeshT< KERNEL > &rhs)
Cast a mesh with different but identical traits into each other.
Definition PolyMeshT.hh:636
T sane_aarg(T _aarg)
Trigonometry/angles - related.
Definition MathDefs.hh:122
Scalar sqrnorm(const VectorT< Scalar, DIM > &_v)
non-member sqrnorm
Definition Vector11T.hh:756
Scalar norm(const VectorT< Scalar, DIM > &_v)
non-member norm
Definition Vector11T.hh:749
Cast a mesh with different but identical traits into each other.
Definition FinalMeshItemsT.hh:178
Handle type for meshes to simplify some template programming.
Definition Handles.hh:149
Base type for a polygonal mesh.
Definition PolyMeshT.hh:91
AttribKernel::Vertex Vertex
Definition PolyMeshT.hh:124
AttribKernel::FaceEdgeIter FaceEdgeIter
Definition PolyMeshT.hh:169
void calc_face_centroid(FaceHandle _fh, Point &_pt) const
calculates the average of the vertices defining _fh
Definition PolyMeshT.hh:282
AttribKernel::ConstFaceIter ConstFaceIter
Definition PolyMeshT.hh:151
AttribKernel::VertexHandle VertexHandle
Definition PolyMeshT.hh:136
AttribKernel::Scalar Scalar
Definition PolyMeshT.hh:110
AttribKernel::ConstVertexVertexIter ConstVertexVertexIter
Definition PolyMeshT.hh:172
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:403
SmartVertexHandle new_vertex(const Point _p)
Adds a new vertex initialized to a custom position.
Definition PolyMeshT.hh:210
AttribKernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Definition PolyMeshT.hh:178
AttribKernel::EdgeHandle EdgeHandle
Definition PolyMeshT.hh:138
AttribKernel::VertexFaceIter VertexFaceIter
Definition PolyMeshT.hh:166
AttribKernel::ConstFaceVertexIter ConstFaceVertexIter
Definition PolyMeshT.hh:177
AttribKernel::Halfedge Halfedge
Definition PolyMeshT.hh:126
void calc_vertex_normal_fast(VertexHandle _vh, Normal &_n) const
Different methods for calculation of the normal at _vh:
Definition PolyMeshT_impl.hh:497
void calc_vertex_normal_correct(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Definition PolyMeshT_impl.hh:507
Point calc_centroid(EdgeHandle _eh) const
Computes and returns the average of the vertices defining _eh (same as calc_edge_midpoint)
Definition PolyMeshT_impl.hh:277
PolyMeshT()
Circulator.
Definition PolyMeshT.hh:185
Scalar calc_dihedral_angle(EdgeHandle _eh) const
Compute normals for all primitives.
Definition PolyMeshT.hh:580
static constexpr bool is_polymesh()
Determine whether this is a PolyMeshT or TriMeshT (This function does not check the per face vertex c...
Definition PolyMeshT.hh:100
AttribKernel::FaceIter FaceIter
Definition PolyMeshT.hh:146
AttribKernel::Normal Normal
Definition PolyMeshT.hh:114
AttribKernel::FaceVertexIter FaceVertexIter
Definition PolyMeshT.hh:167
Point calc_edge_midpoint(EdgeHandle _eh) const
Calculates the midpoint of the edge _eh, defined by the positions of the two incident vertices.
Definition PolyMeshT.hh:446
SmartVertexHandle new_vertex()
Uses default copy and assignment operator.
Definition PolyMeshT.hh:201
Normal calc_face_normal(const Point &_p0, const Point &_p1, const Point &_p2) const
Calculate normal vector for face (_p0, _p1, _p2).
Definition PolyMeshT_impl.hh:173
AttribKernel::VertexIHalfedgeIter VertexIHalfedgeIter
Definition PolyMeshT.hh:164
void split(FaceHandle _fh, VertexHandle _vh)
Compute normals for all primitives.
Definition PolyMeshT.hh:592
Point calc_face_centroid(FaceHandle _fh) const
Computes and returns the average of the vertices defining _fh.
Definition PolyMeshT_impl.hh:249
PolyMeshT(const T &t)
Circulator.
Definition PolyMeshT.hh:187
AttribKernel::TexCoord2D TexCoord2D
Definition PolyMeshT.hh:120
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:524
void update_face_normals()
Update normal vectors for all faces.
Definition PolyMeshT_impl.hh:335
void update_halfedge_normals(const double _feature_angle=0.8)
Update normal vectors for all halfedges.
Definition PolyMeshT_impl.hh:350
Normal calc_normal(EdgeHandle _eh) const
calculated and returns the average of the two vertex normals
Definition PolyMeshT_impl.hh:430
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_impl.hh:74
virtual Normal calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle=0.8) const
Calculate halfedge normal for one specific halfedge.
Definition PolyMeshT_impl.hh:365
Scalar calc_sector_angle(HalfedgeHandle _in_heh) const
calculates the sector angle.
Definition PolyMeshT.hh:469
AttribKernel::ConstFaceEdgeIter ConstFaceEdgeIter
Definition PolyMeshT.hh:179
AttribKernel::TexCoord3D TexCoord3D
Definition PolyMeshT.hh:122
void update_normals()
Compute normals for all primitives.
Definition PolyMeshT_impl.hh:317
AttribKernel::ConstVertexFaceIter ConstVertexFaceIter
Definition PolyMeshT.hh:176
AttribKernel::VertexOHalfedgeIter VertexOHalfedgeIter
Definition PolyMeshT.hh:163
Point calc_centroid(MeshHandle _mh) const
Computes and returns the average of the vertices defining the mesh.
Definition PolyMeshT_impl.hh:307
Point calc_centroid(FaceHandle _fh) const
Computes and returns the average of the vertices defining _fh (same as calc_face_centroid)
Definition PolyMeshT_impl.hh:267
Point calc_centroid(VertexHandle _vh) const
Returns the point of _vh.
Definition PolyMeshT_impl.hh:297
AttribKernel::VertexEdgeIter VertexEdgeIter
Definition PolyMeshT.hh:165
Scalar calc_dihedral_angle(HalfedgeHandle _heh) const
Compute normals for all primitives.
Definition PolyMeshT.hh:558
AttribKernel::Face Face
Definition PolyMeshT.hh:130
AttribKernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Definition PolyMeshT.hh:174
virtual Normal calc_face_normal(FaceHandle _fh) const
Calculate normal vector for face _fh.
Definition PolyMeshT_impl.hh:97
Point calc_centroid(HalfedgeHandle _heh) const
Computes and returns the average of the vertices defining _heh (same as calc_edge_midpoint for edge o...
Definition PolyMeshT_impl.hh:287
Scalar calc_edge_length(EdgeHandle _eh) const
Compute normals for all primitives.
Definition PolyMeshT.hh:417
AttribKernel::ConstHalfedgeIter ConstHalfedgeIter
Definition PolyMeshT.hh:149
Normal calc_normal(HalfedgeHandle, const double _feature_angle=0.8) const
same as calc_halfedge_normal
Definition PolyMeshT_impl.hh:418
void update_normal(VertexHandle _vh)
Update normal for vertex _vh.
Definition PolyMeshT.hh:341
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:458
SmartVertexHandle add_vertex_dirty(const Point _p)
Alias for new_vertex_dirty().
Definition PolyMeshT.hh:242
AttribKernel::FaceFaceIter FaceFaceIter
Definition PolyMeshT.hh:170
bool is_estimated_feature_edge(HalfedgeHandle _heh, const double _feature_angle) const
identifies feature edges w.r.t.
Definition PolyMeshT_impl.hh:452
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:396
virtual ~PolyMeshT()
Circulator.
Definition PolyMeshT.hh:188
AttribKernel::ConstVertexEdgeIter ConstVertexEdgeIter
Definition PolyMeshT.hh:175
Scalar calc_edge_sqr_length(HalfedgeHandle _heh) const
Compute normals for all primitives.
Definition PolyMeshT.hh:428
SmartVertexHandle add_vertex(const Point _p)
Alias for new_vertex(const Point&).
Definition PolyMeshT.hh:238
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:389
AttribKernel::Edge Edge
Definition PolyMeshT.hh:128
AttribKernel::FaceHandle FaceHandle
Definition PolyMeshT.hh:139
void update_normal(FaceHandle _fh)
Update normal for face _fh.
Definition PolyMeshT.hh:261
Scalar calc_dihedral_angle_fast(EdgeHandle _eh) const
calculates the dihedral angle on the edge _eh
Definition PolyMeshT.hh:554
void calc_vertex_normal_loop(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
Definition PolyMeshT_impl.hh:538
void split(EdgeHandle _eh, const Point &_p)
Compute normals for all primitives.
Definition PolyMeshT.hh:595
AttribKernel::HalfedgeHandle HalfedgeHandle
Definition PolyMeshT.hh:137
AttribKernel::EdgeIter EdgeIter
Definition PolyMeshT.hh:145
void update_normal(HalfedgeHandle _heh, const double _feature_angle=0.8)
Update normal for halfedge _heh.
Definition PolyMeshT.hh:305
AttribKernel::ConstEdgeIter ConstEdgeIter
Definition PolyMeshT.hh:150
AttribKernel::ConstVertexIter ConstVertexIter
Definition PolyMeshT.hh:148
void update_vertex_normals()
Update normal vectors for all vertices.
Definition PolyMeshT_impl.hh:572
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:514
AttribKernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Definition PolyMeshT.hh:173
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:410
Scalar calc_edge_sqr_length(EdgeHandle _eh) const
Compute normals for all primitives.
Definition PolyMeshT.hh:425
Point calc_edge_midpoint(HalfedgeHandle _heh) const
Calculates the midpoint of the halfedge _heh, defined by the positions of the two incident vertices.
Definition PolyMeshT.hh:437
AttribKernel::VertexVertexIter VertexVertexIter
Definition PolyMeshT.hh:162
void split(EdgeHandle _eh, VertexHandle _vh)
Compute normals for all primitives.
Definition PolyMeshT.hh:598
AttribKernel::HalfedgeIter HalfedgeIter
Definition PolyMeshT.hh:144
Normal calc_normal(VertexHandle _vh) const
same as calc_vertex_normal_correct
Definition PolyMeshT_impl.hh:560
Scalar calc_edge_length(HalfedgeHandle _heh) const
Calculates the length of the edge _heh.
Definition PolyMeshT.hh:422
AttribKernel::FaceHalfedgeIter FaceHalfedgeIter
Definition PolyMeshT.hh:168
AttribKernel::Point Point
Definition PolyMeshT.hh:112
PolyMeshT< AttribKernel > This
Definition PolyMeshT.hh:95
AttribKernel::ConstFaceFaceIter ConstFaceFaceIter
Definition PolyMeshT.hh:180
void split(FaceHandle _fh, const Point &_p)
Face split (= 1-to-n split)
Definition PolyMeshT.hh:589
AttribKernel::Color Color
Definition PolyMeshT.hh:116
AttribKernel::TexCoord1D TexCoord1D
Definition PolyMeshT.hh:118
Normal calc_normal(FaceHandle _fh) const
same as calc_face_normal
Definition PolyMeshT_impl.hh:187
AttribKernel::VertexIter VertexIter
Definition PolyMeshT.hh:143
SmartVertexHandle 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
Scalar calc_dihedral_angle_fast(HalfedgeHandle _heh) const
calculates the dihedral angle on the halfedge _heh
Definition PolyMeshT.hh:533
Normal calc_vertex_normal(VertexHandle _vh) const
Calculate vertex normal for one specific vertex.
Definition PolyMeshT_impl.hh:483
Smart version of VertexHandle contains a pointer to the corresponding mesh and allows easier access t...
Definition SmartHandles.hh:110