Merge branch 'TemplateProgrammingImprovements' into 'master'
Template programming improvements See merge request OpenMesh/OpenMesh!241
This commit is contained in:
@@ -271,14 +271,33 @@ public:
|
|||||||
/** Calculate normal vector for face (_p0, _p1, _p2). */
|
/** Calculate normal vector for face (_p0, _p1, _p2). */
|
||||||
Normal calc_face_normal(const Point& _p0, const Point& _p1,
|
Normal calc_face_normal(const Point& _p0, const Point& _p1,
|
||||||
const Point& _p2) const;
|
const Point& _p2) const;
|
||||||
|
|
||||||
|
/// same as calc_face_normal
|
||||||
|
Normal calc_normal(FaceHandle _fh) const;
|
||||||
|
|
||||||
/// calculates the average of the vertices defining _fh
|
/// calculates the average of the vertices defining _fh
|
||||||
void calc_face_centroid(FaceHandle _fh, Point& _pt) const {
|
void calc_face_centroid(FaceHandle _fh, Point& _pt) const {
|
||||||
_pt = calc_face_centroid(_fh);
|
_pt = calc_face_centroid(_fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes and returns the average of the vertices defining _gh
|
/// Computes and returns the average of the vertices defining _fh
|
||||||
Point calc_face_centroid(FaceHandle _fh) const;
|
Point calc_face_centroid(FaceHandle _fh) const;
|
||||||
|
|
||||||
|
/// Computes and returns the average of the vertices defining _fh (same as calc_face_centroid)
|
||||||
|
Point calc_centroid(FaceHandle _fh) const;
|
||||||
|
|
||||||
|
/// Computes and returns the average of the vertices defining _eh (same as calc_edge_midpoint)
|
||||||
|
Point calc_centroid(EdgeHandle _eh) const;
|
||||||
|
|
||||||
|
/// Computes and returns the average of the vertices defining _heh (same as calc_edge_midpoint for edge of halfedge)
|
||||||
|
Point calc_centroid(HalfedgeHandle _heh) const;
|
||||||
|
|
||||||
|
/// Returns the point of _vh
|
||||||
|
Point calc_centroid(VertexHandle _vh) const;
|
||||||
|
|
||||||
|
/// Computes and returns the average of the vertices defining the mesh
|
||||||
|
Point calc_centroid(MeshHandle _mh) const;
|
||||||
|
|
||||||
/// Update normal for halfedge _heh
|
/// Update normal for halfedge _heh
|
||||||
void update_normal(HalfedgeHandle _heh, const double _feature_angle = 0.8)
|
void update_normal(HalfedgeHandle _heh, const double _feature_angle = 0.8)
|
||||||
{ this->set_normal(_heh, calc_halfedge_normal(_heh,_feature_angle)); }
|
{ this->set_normal(_heh, calc_halfedge_normal(_heh,_feature_angle)); }
|
||||||
@@ -308,6 +327,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual Normal calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle = 0.8) const;
|
virtual Normal calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle = 0.8) const;
|
||||||
|
|
||||||
|
/// same as calc_halfedge_normal
|
||||||
|
Normal calc_normal(HalfedgeHandle, const double _feature_angle = 0.8) const;
|
||||||
|
|
||||||
/** identifies feature edges w.r.t. the minimal dihedral angle for feature edges (in radians) */
|
/** identifies feature edges w.r.t. the minimal dihedral angle for feature edges (in radians) */
|
||||||
/** and the status feature tag */
|
/** and the status feature tag */
|
||||||
@@ -353,6 +374,8 @@ public:
|
|||||||
void calc_vertex_normal_correct(VertexHandle _vh, Normal& _n) const;
|
void calc_vertex_normal_correct(VertexHandle _vh, Normal& _n) const;
|
||||||
void calc_vertex_normal_loop(VertexHandle _vh, Normal& _n) const;
|
void calc_vertex_normal_loop(VertexHandle _vh, Normal& _n) const;
|
||||||
|
|
||||||
|
/// same as calc_vertex_normal_correct
|
||||||
|
Normal calc_normal(VertexHandle _vh) const;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
@@ -422,6 +445,15 @@ public:
|
|||||||
return calc_edge_midpoint(this->halfedge_handle(_eh, 0));
|
return calc_edge_midpoint(this->halfedge_handle(_eh, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// calculated and returns the average of the two vertex normals
|
||||||
|
Normal calc_normal(EdgeHandle _eh) const
|
||||||
|
{
|
||||||
|
HalfedgeHandle _heh = this->halfedge_handle(_eh, 0);
|
||||||
|
VertexHandle vh0 = this->from_vertex_handle(_heh);
|
||||||
|
VertexHandle vh1 = this->to_vertex_handle(_heh);
|
||||||
|
return 0.5 * (this->calc_normal(vh0) + this->calc_normal(vh1));
|
||||||
|
}
|
||||||
|
|
||||||
/** defines a consistent representation of a sector geometry:
|
/** defines a consistent representation of a sector geometry:
|
||||||
the halfedge _in_heh defines the sector orientation
|
the halfedge _in_heh defines the sector orientation
|
||||||
the vertex pointed by _in_heh defines the sector center
|
the vertex pointed by _in_heh defines the sector center
|
||||||
|
|||||||
@@ -181,6 +181,14 @@ calc_face_normal(const Point& _p0,
|
|||||||
>::Result());
|
>::Result());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Kernel>
|
||||||
|
typename PolyMeshT<Kernel>::Normal
|
||||||
|
PolyMeshT<Kernel>::
|
||||||
|
calc_normal(FaceHandle _fh) const
|
||||||
|
{
|
||||||
|
return calc_face_normal(_fh);
|
||||||
|
}
|
||||||
|
|
||||||
template <class Kernel>
|
template <class Kernel>
|
||||||
typename PolyMeshT<Kernel>::Normal
|
typename PolyMeshT<Kernel>::Normal
|
||||||
PolyMeshT<Kernel>::
|
PolyMeshT<Kernel>::
|
||||||
@@ -250,8 +258,58 @@ calc_face_centroid(FaceHandle _fh) const
|
|||||||
_pt /= valence;
|
_pt /= valence;
|
||||||
return _pt;
|
return _pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template<class Kernel>
|
||||||
|
typename PolyMeshT<Kernel>::Point
|
||||||
|
PolyMeshT<Kernel>::
|
||||||
|
calc_centroid(FaceHandle _fh) const
|
||||||
|
{
|
||||||
|
return calc_face_centroid(_fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template<class Kernel>
|
||||||
|
typename PolyMeshT<Kernel>::Point
|
||||||
|
PolyMeshT<Kernel>::
|
||||||
|
calc_centroid(EdgeHandle _eh) const
|
||||||
|
{
|
||||||
|
return this->calc_edge_midpoint(_eh);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template<class Kernel>
|
||||||
|
typename PolyMeshT<Kernel>::Point
|
||||||
|
PolyMeshT<Kernel>::
|
||||||
|
calc_centroid(HalfedgeHandle _heh) const
|
||||||
|
{
|
||||||
|
return this->calc_edge_midpoint(this->edge_handle(_heh));
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template<class Kernel>
|
||||||
|
typename PolyMeshT<Kernel>::Point
|
||||||
|
PolyMeshT<Kernel>::
|
||||||
|
calc_centroid(VertexHandle _vh) const
|
||||||
|
{
|
||||||
|
return this->point(_vh);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template<class Kernel>
|
||||||
|
typename PolyMeshT<Kernel>::Point
|
||||||
|
PolyMeshT<Kernel>::
|
||||||
|
calc_centroid(MeshHandle /*_mh*/) const
|
||||||
|
{
|
||||||
|
return this->vertices().avg(getPointsProperty(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template <class Kernel>
|
template <class Kernel>
|
||||||
void
|
void
|
||||||
@@ -354,6 +412,18 @@ calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle) const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
template <class Kernel>
|
||||||
|
typename PolyMeshT<Kernel>::Normal
|
||||||
|
PolyMeshT<Kernel>::
|
||||||
|
calc_normal(HalfedgeHandle _heh, const double _feature_angle) const
|
||||||
|
{
|
||||||
|
return calc_halfedge_normal(_heh, _feature_angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
template <class Kernel>
|
template <class Kernel>
|
||||||
bool
|
bool
|
||||||
PolyMeshT<Kernel>::
|
PolyMeshT<Kernel>::
|
||||||
@@ -435,6 +505,9 @@ calc_vertex_normal_correct(VertexHandle _vh, Normal& _n) const
|
|||||||
in_he_vec = out_he_vec;
|
in_he_vec = out_he_vec;
|
||||||
in_he_vec *= -1;//change the orientation
|
in_he_vec *= -1;//change the orientation
|
||||||
}
|
}
|
||||||
|
Scalar length = norm(_n);
|
||||||
|
if (length != 0.0)
|
||||||
|
_n *= (Scalar(1.0)/length);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -459,6 +532,17 @@ calc_vertex_normal_loop(VertexHandle _vh, Normal& _n) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template<class Kernel>
|
||||||
|
typename PolyMeshT<Kernel>::Normal
|
||||||
|
PolyMeshT<Kernel>::
|
||||||
|
calc_normal(VertexHandle _vh) const
|
||||||
|
{
|
||||||
|
Normal n;
|
||||||
|
calc_vertex_normal_correct(_vh, n);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template <class Kernel>
|
template <class Kernel>
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user