Surface area (missing h)
This commit is contained in:
parent
f396f96f41
commit
3240f005c7
1 changed files with 32 additions and 18 deletions
|
@ -52,7 +52,36 @@ struct Triangles {
|
|||
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;
|
||||
};
|
||||
|
@ -99,24 +128,9 @@ float ComputeSurfaceArea(const HEMesh& _m)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
std::cout << "face count: " << simple_faces.size() << std::endl;
|
||||
Triangles triangles(simple_faces, private_mesh);
|
||||
|
||||
for (auto sf : simple_faces) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
area = triangles.surface_area();
|
||||
|
||||
return area;
|
||||
}
|
Loading…
Reference in a new issue