// 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; } std::vector triangulate() { if (he_handles.size() == 3) { return std::vector(); } std::vector simple_faces; std::vector all_handles = he_handles; // replace internal handles std::vector new_handles(he_handles.begin(), he_handles.begin() + 2); he_handles = new_handles; } }; 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); if (simple_face.is_triangulated()) { triangles.emplace_back(points); } else { // triangulate std::vector triangles; std::vector split_indices; int current_split = 0; split_indices.emplace_back(current_split); int i = 0; while(1) { if (current_split) } // insert triangles (slow, but it works) for (Triangle triangle : triangles) { this->triangles.emplace_back(triangle); } } } } 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; }; float ComputeSurfaceArea(const HEMesh& m) { float area = 0; /* Task 2.2.2 */ std::cout << "Area computation is not implemented." << std::endl; auto faces = m.all_faces(); std::vector simple_faces; bool need_triangulation = false; 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()) { need_triangulation = true; break; } simple_faces.emplace_back(simple_face); } 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; }