Commit b18b96f8 authored by Mike Kremer's avatar Mike Kremer

Fixed normal computation algorithm.

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@204 66977474-1d4b-4f09-8fe9-267525286df2
parent a17e0665
......@@ -127,11 +127,7 @@ void NormalAttrib<GeomKernelT>::compute_face_normal(const FaceHandle& _fh) {
return;
}
// Always try to compute the outside normals
HalfFaceHandle hfh = kernel_.is_boundary(kernel_.halfface_handle(_fh, 0)) ?
kernel_.halfface_handle(_fh, 0) : kernel_.halfface_handle(_fh, 1);
std::vector<HalfEdgeHandle> halfedges = kernel_.halfface(hfh).halfedges();
const std::vector<HalfEdgeHandle>& halfedges = kernel_.face(_fh).halfedges();
std::vector<HalfEdgeHandle>::const_iterator he_it = halfedges.begin();
typename GeomKernelT::PointT p1 = kernel_.vertex(kernel_.halfedge(*he_it).from_vertex());
......@@ -139,7 +135,7 @@ void NormalAttrib<GeomKernelT>::compute_face_normal(const FaceHandle& _fh) {
++he_it;
typename GeomKernelT::PointT p3 = kernel_.vertex(kernel_.halfedge(*he_it).to_vertex());
typename GeomKernelT::PointT n = (p1 - p2) % (p3 - p2);
typename GeomKernelT::PointT n = (p2 - p1) % (p3 - p2);
n.normalize();
f_normals_[_fh.idx()] = n;
......
......@@ -548,23 +548,23 @@ TEST_F(PolyhedralMeshBase, VolumeMeshNormals) {
normals.update_face_normals();
// Should be negative z-axis
// Should be positive z-axis
Vec3d n = normals[FaceHandle(0)];
EXPECT_DOUBLE_EQ(-n_z[0], n[0]);
EXPECT_DOUBLE_EQ(-n_z[1], n[1]);
EXPECT_DOUBLE_EQ(-n_z[2], n[2]);
EXPECT_DOUBLE_EQ(n_z[0], n[0]);
EXPECT_DOUBLE_EQ(n_z[1], n[1]);
EXPECT_DOUBLE_EQ(n_z[2], n[2]);
// Should be positive x-axis
// Should be negative x-axis
n = normals[FaceHandle(2)];
EXPECT_DOUBLE_EQ(n_x[0], n[0]);
EXPECT_DOUBLE_EQ(n_x[1], n[1]);
EXPECT_DOUBLE_EQ(n_x[2], n[2]);
EXPECT_DOUBLE_EQ(-n_x[0], n[0]);
EXPECT_DOUBLE_EQ(-n_x[1], n[1]);
EXPECT_DOUBLE_EQ(-n_x[2], n[2]);
// Should be positive y-axis
// Should be negative y-axis
n = normals[FaceHandle(4)];
EXPECT_DOUBLE_EQ(n_y[0], n[0]);
EXPECT_DOUBLE_EQ(n_y[1], n[1]);
EXPECT_DOUBLE_EQ(n_y[2], n[2]);
EXPECT_DOUBLE_EQ(-n_y[0], n[0]);
EXPECT_DOUBLE_EQ(-n_y[1], n[1]);
EXPECT_DOUBLE_EQ(-n_y[2], n[2]);
// Should be positive y-axis
n = normals[FaceHandle(5)];
......
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