// This source code is property of the Computer Graphics and Visualization // chair of the TU Dresden. Do not distribute! // Copyright (C) CGV TU Dresden - All Rights Reserved #include "SurfaceArea.h" #include struct SimpleFace { std::vector he_handles; bool is_triangulated() { if (he_handles.size() != 3) { return false; } return true; } }; struct Triangle { Triangle(std::vector vpoints) { if (vpoints.size() != 3) { abort(); } for (int i = 0; i < 3; i++) { points[i] = vpoints[i]; } } OpenMesh::Vec3f points[3]; }; struct Triangles { Triangles(std::vector simple_faces, const HEMesh& m) { for (auto simple_face: simple_faces) { std::vector points = face_points(simple_face, m); triangles.emplace_back(points); } } std::vector face_points(SimpleFace& simple_face, const HEMesh& m) { std::vector points; for (auto he : simple_face.he_handles) { OpenMesh::VertexHandle vertex_handle = m.from_vertex_handle(he); points.emplace_back(m.point(vertex_handle)); } return points; } float surface_area() { return 0.0f; } std::vector triangles; }; bool gather_faces(const HEMesh& m, std::vector& simple_faces) { auto faces = m.all_faces(); for (auto face_handle : faces) { HEMesh::ConstFaceHalfedgeIter fh_it = m.cfh_iter(face_handle); SimpleFace simple_face; for (; fh_it.is_valid(); ++fh_it) { simple_face.he_handles.emplace_back(*fh_it); } if (!simple_face.is_triangulated()) { return false; } simple_faces.emplace_back(simple_face); } return true; } float ComputeSurfaceArea(const HEMesh& _m) { float area = 0; /* Task 2.2.2 */ std::cout << "Area computation is not implemented." << std::endl; // copy mesh for mutability HEMesh private_mesh = _m; std::vector simple_faces; if (!gather_faces(private_mesh, simple_faces)) { simple_faces.clear(); private_mesh.triangulate(); if (!gather_faces(private_mesh, simple_faces)) { abort(); } } /* std::cout << "face count: " << simple_faces.size() << std::endl; for (auto sf : simple_faces) { std::cout << "half edge count: " << sf.he_handles.size() << std::endl; std::vector 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; }