From 344d73123610c5fa0478d3bb4d47bb8f49cf5653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 13 Feb 2017 09:54:04 +0100 Subject: [PATCH 1/3] Lower cppcheck warning count --- OpenFlipper/CI/ci-cppcheck.sh | 2 +- Type-OpenVolumeMesh/libs/OpenVolumeMesh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenFlipper/CI/ci-cppcheck.sh b/OpenFlipper/CI/ci-cppcheck.sh index 0fe9c03c5..ff0521d4e 100755 --- a/OpenFlipper/CI/ci-cppcheck.sh +++ b/OpenFlipper/CI/ci-cppcheck.sh @@ -59,7 +59,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_ERROR=136 +MAX_ERROR=105 if [ $COUNT -gt $MAX_ERROR ]; then echo -e ${WARNING} diff --git a/Type-OpenVolumeMesh/libs/OpenVolumeMesh b/Type-OpenVolumeMesh/libs/OpenVolumeMesh index b5039f0f2..a45f4a3d3 160000 --- a/Type-OpenVolumeMesh/libs/OpenVolumeMesh +++ b/Type-OpenVolumeMesh/libs/OpenVolumeMesh @@ -1 +1 @@ -Subproject commit b5039f0f28f1cea68e0eb4420ed8e37ad8ab6307 +Subproject commit a45f4a3d3da9d7b5b812bb5b57555be3f8836e10 -- GitLab From 92567329642ecc55d160d028f9197a57fa6106b4 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Mon, 13 Feb 2017 11:21:48 +0100 Subject: [PATCH 2/3] fixes for OVM Handle constructor explicitness --- .../OpenVolumeMesh/OVMPropertyVisualizerT.cc | 2 +- .../Plugin-FileOVM/FileOpenVolumeMeshT.cc | 32 ++-- .../Plugin-FileVTK/FileVTK.cc | 148 +++++++++--------- 3 files changed, 91 insertions(+), 91 deletions(-) diff --git a/Plugin-PropertyVis/OpenVolumeMesh/OVMPropertyVisualizerT.cc b/Plugin-PropertyVis/OpenVolumeMesh/OVMPropertyVisualizerT.cc index 101fca008..5791bdae0 100644 --- a/Plugin-PropertyVis/OpenVolumeMesh/OVMPropertyVisualizerT.cc +++ b/Plugin-PropertyVis/OpenVolumeMesh/OVMPropertyVisualizerT.cc @@ -177,7 +177,7 @@ unsigned int OVMPropertyVisualizer::getClosestHalffaceId(unsigned int _fa template unsigned int OVMPropertyVisualizer::getClosestHalfedgeId(unsigned int _face, ACG::Vec3d& _hitPoint) { - unsigned int halfface = getClosestHalffaceId(_face, _hitPoint); + OpenVolumeMesh::HalfFaceHandle halfface = OpenVolumeMesh::HalfFaceHandle(getClosestHalffaceId(_face, _hitPoint)); OpenVolumeMesh::OpenVolumeMeshFace face = mesh->halfface(halfface); diff --git a/PluginCollection-FilePlugins/Plugin-FileOVM/FileOpenVolumeMeshT.cc b/PluginCollection-FilePlugins/Plugin-FileOVM/FileOpenVolumeMeshT.cc index 3de762c9b..d09cbc48d 100644 --- a/PluginCollection-FilePlugins/Plugin-FileOVM/FileOpenVolumeMeshT.cc +++ b/PluginCollection-FilePlugins/Plugin-FileOVM/FileOpenVolumeMeshT.cc @@ -121,16 +121,16 @@ void FileOpenVolumeMeshPlugin::loadMesh(const char* _filename, MeshT& _mesh, boo for (int f = 0; f < nf; ++f) { int nfv; iff >> nfv; - std::vector vids; + std::vector vhs; for (int v = 0; v < nfv; ++v) { int i; iff >> i; - vids.push_back(i); + vhs.push_back(OpenVolumeMesh::VertexHandle(i)); } int pos_cell, neg_cell; iff >> pos_cell; iff >> neg_cell; - _mesh.add_face(vids); + _mesh.add_face(vhs); } } else { @@ -144,7 +144,7 @@ void FileOpenVolumeMeshPlugin::loadMesh(const char* _filename, MeshT& _mesh, boo for (int he = 0; he < nfhe; ++he) { int i; iff >> i; - hes.push_back(i); + hes.push_back(OpenVolumeMesh::HalfEdgeHandle(i)); } _mesh.add_face(hes, _topCheck); @@ -168,23 +168,23 @@ void FileOpenVolumeMeshPlugin::loadMesh(const char* _filename, MeshT& _mesh, boo int ncf; iff >> ncf; - std::vector< int > faceids; + std::vector< OpenVolumeMesh::FaceHandle > faces; for( int f = 0; f < ncf; ++f) { int fidx; iff >> fidx; - faceids.push_back(fidx); + faces.push_back(OpenVolumeMesh::FaceHandle(fidx)); } // Get right halffaces // First determine the barycenter of the polyhedron ACG::Vec3d c(0.0, 0.0, 0.0); - unsigned int num_faces = faceids.size(); - for(std::vector::const_iterator it = faceids.begin(); - it != faceids.end(); ++it) { + unsigned int num_faces = faces.size(); + for(auto fh : faces) + { - std::vector hes = _mesh.face(*it).halfedges(); + std::vector hes = _mesh.face(fh).halfedges(); unsigned int val = hes.size(); ACG::Vec3d f_mid(0.0, 0.0, 0.0); for(std::vector::const_iterator p_it = hes.begin(); @@ -197,11 +197,11 @@ void FileOpenVolumeMeshPlugin::loadMesh(const char* _filename, MeshT& _mesh, boo // Now determine all halffaces // Test whether their normals point into the polyhedron std::vector hfhandles; - for(std::vector::const_iterator it = faceids.begin(); - it != faceids.end(); ++it) { + for(auto fh : faces) + { // Get face's mid-point - std::vector hes = _mesh.face(*it).halfedges(); + std::vector hes = _mesh.face(fh).halfedges(); unsigned int val = hes.size(); ACG::Vec3d f_mid(0.0, 0.0, 0.0); for(std::vector::const_iterator p_it = hes.begin(); @@ -217,8 +217,8 @@ void FileOpenVolumeMeshPlugin::loadMesh(const char* _filename, MeshT& _mesh, boo ACG::Vec3d n = (p0 - p1) % (p2 - p1); n.normalize(); - if(((c - f_mid) | n) >= 0.0) hfhandles.push_back(_mesh.halfface_handle(*it, 0)); - else hfhandles.push_back(_mesh.halfface_handle(*it, 1)); + if(((c - f_mid) | n) >= 0.0) hfhandles.push_back(_mesh.halfface_handle(fh, 0)); + else hfhandles.push_back(_mesh.halfface_handle(fh, 1)); } if(hfhandles.size() > 3) { @@ -248,7 +248,7 @@ void FileOpenVolumeMeshPlugin::loadMesh(const char* _filename, MeshT& _mesh, boo for (int hf = 0; hf < nhf; ++hf) { int i; iff >> i; - hfs.push_back(i); + hfs.push_back(OpenVolumeMesh::HalfFaceHandle(i)); } // Implement hex mesh shit diff --git a/PluginCollection-FilePlugins/Plugin-FileVTK/FileVTK.cc b/PluginCollection-FilePlugins/Plugin-FileVTK/FileVTK.cc index ff42d522f..928d322d9 100644 --- a/PluginCollection-FilePlugins/Plugin-FileVTK/FileVTK.cc +++ b/PluginCollection-FilePlugins/Plugin-FileVTK/FileVTK.cc @@ -516,21 +516,21 @@ int FileVTKPlugin::addTetraCellToOpenVolumeMesh(MeshT _mesh, std::vector > faces; faces.push_back(std::vector()); - faces[0].push_back(_indices[0]); - faces[0].push_back(_indices[1]); - faces[0].push_back(_indices[2]); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); faces.push_back(std::vector()); - faces[1].push_back(_indices[0]); - faces[1].push_back(_indices[3]); - faces[1].push_back(_indices[1]); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); faces.push_back(std::vector()); - faces[2].push_back(_indices[1]); - faces[2].push_back(_indices[3]); - faces[2].push_back(_indices[2]); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); faces.push_back(std::vector()); - faces[3].push_back(_indices[0]); - faces[3].push_back(_indices[2]); - faces[3].push_back(_indices[3]); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); std::vector halffacehandles; for (unsigned int i = 0; i < faces.size(); i++) @@ -556,35 +556,35 @@ int FileVTKPlugin::addHexaCellToOpenVolumeMesh(MeshT _mesh, std::vector std::vector< std::vector > faces; faces.push_back(std::vector()); - faces[0].push_back(_indices[0]); - faces[0].push_back(_indices[1]); - faces[0].push_back(_indices[2]); - faces[0].push_back(_indices[3]); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); faces.push_back(std::vector()); - faces[1].push_back(_indices[0]); - faces[1].push_back(_indices[4]); - faces[1].push_back(_indices[5]); - faces[1].push_back(_indices[1]); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[5])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); faces.push_back(std::vector()); - faces[2].push_back(_indices[0]); - faces[2].push_back(_indices[3]); - faces[2].push_back(_indices[7]); - faces[2].push_back(_indices[4]); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[7])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); faces.push_back(std::vector()); - faces[3].push_back(_indices[1]); - faces[3].push_back(_indices[5]); - faces[3].push_back(_indices[6]); - faces[3].push_back(_indices[2]); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[5])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[6])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); faces.push_back(std::vector()); - faces[4].push_back(_indices[2]); - faces[4].push_back(_indices[6]); - faces[4].push_back(_indices[7]); - faces[4].push_back(_indices[3]); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[6])); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[7])); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); faces.push_back(std::vector()); - faces[5].push_back(_indices[4]); - faces[5].push_back(_indices[7]); - faces[5].push_back(_indices[6]); - faces[5].push_back(_indices[5]); + faces[5].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); + faces[5].push_back(OpenVolumeMesh::VertexHandle(_indices[7])); + faces[5].push_back(OpenVolumeMesh::VertexHandle(_indices[6])); + faces[5].push_back(OpenVolumeMesh::VertexHandle(_indices[5])); std::vector halffacehandles; for (unsigned int i = 0; i < faces.size(); i++) @@ -609,28 +609,28 @@ int FileVTKPlugin::addWedgeCellToOpenVolumeMesh(MeshT _mesh, std::vector > faces; faces.push_back(std::vector()); - faces[0].push_back(_indices[0]); - faces[0].push_back(_indices[1]); - faces[0].push_back(_indices[4]); - faces[0].push_back(_indices[3]); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); faces.push_back(std::vector()); - faces[1].push_back(_indices[0]); - faces[1].push_back(_indices[2]); - faces[1].push_back(_indices[1]); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); faces.push_back(std::vector()); - faces[2].push_back(_indices[3]); - faces[2].push_back(_indices[4]); - faces[2].push_back(_indices[5]); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[5])); faces.push_back(std::vector()); - faces[3].push_back(_indices[0]); - faces[3].push_back(_indices[3]); - faces[3].push_back(_indices[5]); - faces[3].push_back(_indices[2]); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[5])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); faces.push_back(std::vector()); - faces[4].push_back(_indices[1]); - faces[4].push_back(_indices[2]); - faces[4].push_back(_indices[5]); - faces[4].push_back(_indices[4]); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[5])); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); std::vector halffacehandles; for (unsigned int i = 0; i < faces.size(); i++) @@ -655,26 +655,26 @@ int FileVTKPlugin::addPyramidCellToOpenVolumeMesh(MeshT _mesh, std::vector > faces; faces.push_back(std::vector()); - faces[0].push_back(_indices[0]); - faces[0].push_back(_indices[1]); - faces[0].push_back(_indices[2]); - faces[0].push_back(_indices[3]); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); + faces[0].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); faces.push_back(std::vector()); - faces[1].push_back(_indices[0]); - faces[1].push_back(_indices[4]); - faces[1].push_back(_indices[1]); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); + faces[1].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); faces.push_back(std::vector()); - faces[2].push_back(_indices[0]); - faces[2].push_back(_indices[3]); - faces[2].push_back(_indices[4]); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[0])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); + faces[2].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); faces.push_back(std::vector()); - faces[3].push_back(_indices[2]); - faces[3].push_back(_indices[4]); - faces[3].push_back(_indices[3]); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); + faces[3].push_back(OpenVolumeMesh::VertexHandle(_indices[3])); faces.push_back(std::vector()); - faces[4].push_back(_indices[1]); - faces[4].push_back(_indices[4]); - faces[4].push_back(_indices[2]); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[1])); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[4])); + faces[4].push_back(OpenVolumeMesh::VertexHandle(_indices[2])); std::vector halffacehandles; for (unsigned int i = 0; i < faces.size(); i++) @@ -706,7 +706,7 @@ int FileVTKPlugin::addFaceToOpenVolumeMesh(MeshT*& _mesh, std::vector _ halffacehandle = _mesh->halfface(face); if (halffacehandle == -1) // face didn't exist { - OpenVolumeMesh::FaceHandle fh = _mesh->add_face(face).idx(); + OpenVolumeMesh::FaceHandle fh = _mesh->add_face(face); halffacehandle = _mesh->halfface_handle(fh, 0); } return halffacehandle.idx(); @@ -724,7 +724,7 @@ int FileVTKPlugin::addFaceToOpenVolumeMesh(MeshT*& _mesh, quint32 _index1, quint halffacehandle = _mesh->halfface(face); if (halffacehandle == -1) // face didn't exist { - OpenVolumeMesh::FaceHandle fh = _mesh->add_face(face).idx(); + OpenVolumeMesh::FaceHandle fh = _mesh->add_face(face); halffacehandle = _mesh->halfface_handle(fh, 0); } return halffacehandle.idx(); @@ -745,9 +745,9 @@ void FileVTKPlugin::addFaceNormalToOpenVolumeMesh(MeshT _mesh, quint32 _index, O OpenVolumeMesh::HalfFaceHandle hfh = OpenVolumeMesh::HalfFaceHandle(_index); OpenVolumeMesh::FaceHandle fh = _mesh->face_handle(hfh); if (hfh == _mesh->halfface_handle(fh, 0)) - faceNormals[_mesh->face_handle(_index)] = _normal; + faceNormals[fh] = _normal; else - faceNormals[_mesh->face_handle(_index)] = -_normal; + faceNormals[fh] = -_normal; } -- GitLab From ba304cba0701e882454b681b470d7981b0ee12a4 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Mon, 13 Feb 2017 11:27:42 +0100 Subject: [PATCH 3/3] make Cells (flat shaded) the default draw mode for OpenVolumeMeshes loaded from vtk files --- .../Plugin-FileVTK/FileVTK.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/PluginCollection-FilePlugins/Plugin-FileVTK/FileVTK.cc b/PluginCollection-FilePlugins/Plugin-FileVTK/FileVTK.cc index 928d322d9..96a686c1c 100644 --- a/PluginCollection-FilePlugins/Plugin-FileVTK/FileVTK.cc +++ b/PluginCollection-FilePlugins/Plugin-FileVTK/FileVTK.cc @@ -1595,7 +1595,8 @@ int FileVTKPlugin::loadObject(QString _filename) { return -1; } - BaseObject* baseObj = 0; + BaseObjectData* baseObj = 0; + bool is_OpenVolumeMesh = false; if ( (forceTriangleMesh_) || (bestType == BMT_TriMesh) ){ @@ -1660,6 +1661,7 @@ int FileVTKPlugin::loadObject(QString _filename) { else if (bestType == BMT_PolyhedralMesh) { // add a Polyhedral mesh + is_OpenVolumeMesh = true; int id = -1; emit addEmptyObject(DATA_POLYHEDRAL_MESH, id); @@ -1689,6 +1691,7 @@ int FileVTKPlugin::loadObject(QString _filename) { else if (bestType == BMT_HexahedralMesh) { // add a hexahedral mesh + is_OpenVolumeMesh = true; int id = -1; emit addEmptyObject(DATA_HEXAHEDRAL_MESH, id); @@ -1717,6 +1720,7 @@ int FileVTKPlugin::loadObject(QString _filename) { else if (bestType == BMT_TetrahedralMesh) { // add a tetrahedral mesh + is_OpenVolumeMesh = true; int id = -1; emit addEmptyObject(DATA_TETRAHEDRAL_MESH, id); @@ -1747,6 +1751,11 @@ int FileVTKPlugin::loadObject(QString _filename) { baseObj->setFromFileName(_filename); baseObj->setName(baseObj->filename()); + if (is_OpenVolumeMesh) + { + // Go into solid flat shaded mode + baseObj->setObjectDrawMode(ACG::SceneGraph::DrawModes::getDrawMode("Cells (flat shaded)")); + } emit updatedObject(baseObj->id(), UPDATE_ALL); -- GitLab