Surface area (missing h)

This commit is contained in:
hodasemi 2019-01-05 17:03:55 +01:00
parent f396f96f41
commit 3240f005c7

View file

@ -52,7 +52,36 @@ struct Triangles {
return points; return points;
} }
float surface_area() { return 0.0f; } float surface_area() {
float surface_area = 0.0f;
for (Triangle& triangle : triangles) {
OpenMesh::Vec3f p1 = triangle.points[0];
OpenMesh::Vec3f p2 = triangle.points[1];
OpenMesh::Vec3f p3 = triangle.points[2];
/*
3
/ | \
/ |h \
/ | \
1 -------------- 2
g
surface area = (g * h) / 2;
*/
OpenMesh::Vec3f g_vec = p1 - p2;
float g = g_vec.length();
float h = 0.0f;
surface_area += (g * h) / 2;
}
return surface_area;
}
std::vector<Triangle> triangles; std::vector<Triangle> triangles;
}; };
@ -99,24 +128,9 @@ float ComputeSurfaceArea(const HEMesh& _m)
} }
} }
/* Triangles triangles(simple_faces, private_mesh);
std::cout << "face count: " << simple_faces.size() << std::endl;
for (auto sf : simple_faces) { area = triangles.surface_area();
std::cout << "half edge count: " << sf.he_handles.size() << std::endl;
std::vector<OpenMesh::VertexHandle> vertex_handles;
for (auto he: sf.he_handles) {
vertex_handles.emplace_back(m.to_vertex_handle(he));
vertex_handles.emplace_back(m.from_vertex_handle(he));
}
for (auto vh: vertex_handles) {
std::cout << "vertex handle id: " << vh.idx() << std::endl;
}
}
*/
return area; return area;
} }