From f9a1cc930c2a53b25bd60ec040a2cc9b3815c9e7 Mon Sep 17 00:00:00 2001 From: Janis Born Date: Fri, 28 Jul 2017 08:43:13 +0200 Subject: [PATCH 1/4] make is_polymesh / is_trimesh methods constexpr and add a ConnectivityTag typedef to help with tag dispatching --- src/OpenMesh/Core/Mesh/PolyMeshT.hh | 8 +++-- src/OpenMesh/Core/Mesh/Tags.hh | 54 +++++++++++++++++++++++++++++ src/OpenMesh/Core/Mesh/TriMeshT.hh | 8 +++-- 3 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 src/OpenMesh/Core/Mesh/Tags.hh diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index 0554161e..40b772cf 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.hh @@ -65,6 +65,7 @@ #include #include #include +#include #include @@ -100,11 +101,12 @@ public: //--- item types --- //@{ - /// Determine whether this is a PolyMeshT or TriMeshT ( This function does not check the per face vertex count! It only checks if the datatype is PolyMeshT or TriMeshT ) + /// Determine whether this is a PolyMeshT or TriMeshT (This function does not check the per face vertex count! It only checks if the datatype is PolyMeshT or TriMeshT) + static constexpr bool is_polymesh() { return true; } + static constexpr bool is_trimesh() { return false; } + using ConnectivityTag = TriConnectivityTag; enum { IsPolyMesh = 1 }; enum { IsTriMesh = 0 }; - static bool is_polymesh() { return true; } - static bool is_trimesh() { return false; } //@} /// \name Mesh Items diff --git a/src/OpenMesh/Core/Mesh/Tags.hh b/src/OpenMesh/Core/Mesh/Tags.hh new file mode 100644 index 00000000..605922b0 --- /dev/null +++ b/src/OpenMesh/Core/Mesh/Tags.hh @@ -0,0 +1,54 @@ +/* ========================================================================= * + * * + * OpenMesh * + * Copyright (c) 2001-2015, RWTH-Aachen University * + * Department of Computer Graphics and Multimedia * + * All rights reserved. * + * www.openmesh.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenMesh. * + *---------------------------------------------------------------------------* + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. Neither the name of the copyright holder nor the names of its * + * contributors may be used to endorse or promote products derived from * + * this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= */ + +#ifndef OPENMESH_TAGS_HH +#define OPENMESH_TAGS_HH + +namespace OpenMesh { + +/// Connectivity tag indicating that the tagged mesh has polygon connectivity. +struct PolyConnectivityTag {}; +/// Connectivity tag indicating that the tagged mesh has triangle connectivity. +struct TriConnectivityTag {}; + +} // namespace OpenMesh + +#endif diff --git a/src/OpenMesh/Core/Mesh/TriMeshT.hh b/src/OpenMesh/Core/Mesh/TriMeshT.hh index 6ff32f3c..bd2621c8 100644 --- a/src/OpenMesh/Core/Mesh/TriMeshT.hh +++ b/src/OpenMesh/Core/Mesh/TriMeshT.hh @@ -63,6 +63,7 @@ #include #include +#include #include @@ -103,11 +104,12 @@ public: typedef PolyMeshT PolyMesh; //@{ - /// Determine whether this is a PolyMeshT or TriMeshT ( This function does not check the per face vertex count! It only checks if the datatype is PolyMeshT or TriMeshT ) + /// Determine whether this is a PolyMeshT or TriMeshT (This function does not check the per face vertex count! It only checks if the datatype is PolyMeshT or TriMeshT) + static constexpr bool is_polymesh() { return false; } + static constexpr bool is_trimesh() { return true; } + using ConnectivityTag = TriConnectivityTag; enum { IsPolyMesh = 0 }; enum { IsTriMesh = 1 }; - static bool is_polymesh() { return false; } - static bool is_trimesh() { return true; } //@} //--- items --- From c4fdb6a264cc0fd22c356f08f3f56e217cc77118 Mon Sep 17 00:00:00 2001 From: Janis Born Date: Mon, 31 Jul 2017 10:32:11 +0200 Subject: [PATCH 2/4] use correct ConnectivityTag typedef for PolyMeshT --- src/OpenMesh/Core/Mesh/PolyMeshT.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index 40b772cf..c4e89dac 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.hh @@ -104,7 +104,7 @@ public: /// Determine whether this is a PolyMeshT or TriMeshT (This function does not check the per face vertex count! It only checks if the datatype is PolyMeshT or TriMeshT) static constexpr bool is_polymesh() { return true; } static constexpr bool is_trimesh() { return false; } - using ConnectivityTag = TriConnectivityTag; + using ConnectivityTag = PolyConnectivityTag; enum { IsPolyMesh = 1 }; enum { IsTriMesh = 0 }; //@} From 38efdce5f5b3515642188729446426725928496e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 15 Jan 2019 16:12:51 +0100 Subject: [PATCH 3/4] Some cleanup --- Doc/changelog.docu | 1 + src/OpenMesh/Core/Mesh/Tags.hh | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/changelog.docu b/Doc/changelog.docu index c6ed2916..00fbc7f5 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -18,6 +18,7 @@
  • TriConnectivity: Added two functions split_edge and split_edge_copy to mask the PolyConnectivity functions of the same name (Prevents creation of valence 2 vertices on trimeshes)
  • PolyConnectivity: Fixed PolyConnectivity is_collapse_ok, missing some configurations (Thanks to Simon Flöry for the patch)
  • +
  • Connectivity type is now set at compile time
IO diff --git a/src/OpenMesh/Core/Mesh/Tags.hh b/src/OpenMesh/Core/Mesh/Tags.hh index 605922b0..ba3d9a96 100644 --- a/src/OpenMesh/Core/Mesh/Tags.hh +++ b/src/OpenMesh/Core/Mesh/Tags.hh @@ -39,8 +39,7 @@ * * * ========================================================================= */ -#ifndef OPENMESH_TAGS_HH -#define OPENMESH_TAGS_HH +#pragma once namespace OpenMesh { @@ -51,4 +50,3 @@ struct TriConnectivityTag {}; } // namespace OpenMesh -#endif From cfd2fdb1601cbbf67d658677b1a12fb34578e068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 15 Jan 2019 16:13:05 +0100 Subject: [PATCH 4/4] Added unittest to check mesh type --- src/Unittests/unittests_mesh_type.cc | 67 ++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/Unittests/unittests_mesh_type.cc diff --git a/src/Unittests/unittests_mesh_type.cc b/src/Unittests/unittests_mesh_type.cc new file mode 100644 index 00000000..309567d0 --- /dev/null +++ b/src/Unittests/unittests_mesh_type.cc @@ -0,0 +1,67 @@ +#include + +#include + + +namespace { + + +class OpenMeshTypeTest_Poly : public OpenMeshBasePoly { + + protected: + + // This function is called before each test is run + virtual void SetUp() { + + // Do some initial stuff with the member data here... + } + + // This function is called after all tests are through + virtual void TearDown() { + + // Do some final stuff with the member data here... + } +}; + +class OpenMeshTypeTest_Triangle : public OpenMeshBase { + + protected: + + // This function is called before each test is run + virtual void SetUp() { + + // Do some initial stuff with the member data here... + } + + // This function is called after all tests are through + virtual void TearDown() { + + // Do some final stuff with the member data here... + } + +}; + + +/* + * ==================================================================== + * Define tests below + * ==================================================================== + */ + +TEST_F(OpenMeshTypeTest_Triangle, testTypeFunctions) { + + + EXPECT_TRUE(mesh_.is_trimesh()) << "Type Error!"; + EXPECT_FALSE(mesh_.is_polymesh()) << "Type Error!"; +} + + +TEST_F(OpenMeshTypeTest_Poly, testTypeFunctions) { + + + EXPECT_FALSE(mesh_.is_trimesh()) << "Type Error!"; + EXPECT_TRUE(mesh_.is_polymesh()) << "Type Error!"; +} + + +}