Commit 5e7493b3 authored by Christian Mattes's avatar Christian Mattes

Altered PolyMesh template to work with Eigen's Vectors

parent 8396dcea
Pipeline #6782 failed with stage
in 14 minutes and 47 seconds
......@@ -144,13 +144,13 @@ PolyMeshT<Kernel>::calc_face_normal_impl(FaceHandle _fh, PointIs3DTag) const
n[2] += static_cast<typename Normal::value_type>(a[0] * b[1]);
}
const typename vector_traits<Normal>::value_type norm = n.length();
const typename vector_traits<Normal>::value_type length = norm(n);
// The expression ((n *= (1.0/norm)),n) is used because the OpenSG
// vector class does not return self after component-wise
// self-multiplication with a scalar!!!
return (norm != typename vector_traits<Normal>::value_type(0))
? ((n *= (typename vector_traits<Normal>::value_type(1)/norm)), n)
return (length != typename vector_traits<Normal>::value_type(0))
? ((n *= (typename vector_traits<Normal>::value_type(1)/length)), n)
: Normal(0, 0, 0);
}
......@@ -194,20 +194,22 @@ calc_face_normal_impl(const Point& _p0,
Normal p1p2(vector_cast<Normal>(_p2)); p1p2 -= vector_cast<Normal>(_p1);
Normal n = cross(p1p2, p1p0);
typename vector_traits<Normal>::value_type norm = n.length();
typename vector_traits<Normal>::value_type length = norm(n);
// The expression ((n *= (1.0/norm)),n) is used because the OpenSG
// vector class does not return self after component-wise
// self-multiplication with a scalar!!!
return (norm != typename vector_traits<Normal>::value_type(0)) ? ((n *= (typename vector_traits<Normal>::value_type(1)/norm)),n) : Normal(0,0,0);
return (length != typename vector_traits<Normal>::value_type(0))
? ((n *= (typename vector_traits<Normal>::value_type(1)/length)),n)
: Normal(0,0,0);
#else
Point p1p0 = _p0; p1p0 -= _p1;
Point p1p2 = _p2; p1p2 -= _p1;
Normal n = vector_cast<Normal>(cross(p1p2, p1p0));
typename vector_traits<Normal>::value_type norm = n.length();
typename vector_traits<Normal>::value_type length = norm(n);
return (norm != 0.0) ? n *= (1.0/norm) : Normal(0,0,0);
return (length != 0.0) ? n *= (1.0/length) : Normal(0,0,0);
#endif
}
......@@ -331,7 +333,7 @@ calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle) const
for(unsigned int i=0; i<fhs.size(); ++i)
n += Kernel::normal(fhs[i]);
return n.normalize();
return normalize(n);
}
}
......@@ -378,8 +380,8 @@ calc_vertex_normal(VertexHandle _vh) const
Normal n;
calc_vertex_normal_fast(_vh,n);
Scalar norm = n.length();
if (norm != 0.0) n *= (Scalar(1.0)/norm);
Scalar length = norm(n);
if (length != 0.0) n *= (Scalar(1.0)/length);
return n;
}
......@@ -389,7 +391,7 @@ template <class Kernel>
void PolyMeshT<Kernel>::
calc_vertex_normal_fast(VertexHandle _vh, Normal& _n) const
{
_n.vectorize(0.0);
vectorize(_n, 0.0);
for (ConstVertexFaceIter vf_it = this->cvf_iter(_vh); vf_it.is_valid(); ++vf_it)
_n += this->normal(*vf_it);
}
......
......@@ -406,7 +406,7 @@ public:
{
Normal edge_vec;
calc_edge_vector(_heh, edge_vec);
return edge_vec.sqrnorm();
return sqrnorm(edge_vec);
}
/** Calculates the midpoint of the halfedge _heh, defined by the positions of
......@@ -444,7 +444,7 @@ public:
{
Normal v0, v1;
calc_sector_vectors(_in_heh, v0, v1);
Scalar denom = v0.norm()*v1.norm();
Scalar denom = length(v0)*length(v1);
if ( denom == Scalar(0))
{
return 0;
......@@ -470,7 +470,7 @@ public:
Normal in_vec, out_vec;
calc_edge_vector(_in_heh, in_vec);
calc_edge_vector(next_halfedge_handle(_in_heh), out_vec);
Scalar denom = in_vec.norm()*out_vec.norm();
Scalar denom = length(in_vec)*length(out_vec);
if (is_zero(denom))
{
_cos_a = 1;
......@@ -479,7 +479,7 @@ public:
else
{
_cos_a = dot(in_vec, out_vec)/denom;
_sin_a = cross(in_vec, out_vec).norm()/denom;
_sin_a = length(cross(in_vec, out_vec))/denom;
}
}
*/
......@@ -499,7 +499,7 @@ public:
{
Normal sector_normal;
calc_sector_normal(_in_heh, sector_normal);
return sector_normal.norm()/2;
return length(sector_normal)/2;
}
/** calculates the dihedral angle on the halfedge _heh
......@@ -539,7 +539,7 @@ public:
calc_sector_normal(_heh, n0);
calc_sector_normal(this->opposite_halfedge_handle(_heh), n1);
calc_edge_vector(_heh, he);
Scalar denom = n0.norm()*n1.norm();
Scalar denom = length(n0)*length(n1);
if (denom == Scalar(0))
{
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment