From 651e8cf966bca253a974d420a67b613a3acf0787 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 22 Oct 2019 10:08:22 +0200 Subject: [PATCH 1/5] add default trait that uses double precision --- src/OpenMesh/Core/Mesh/Traits.hh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/OpenMesh/Core/Mesh/Traits.hh b/src/OpenMesh/Core/Mesh/Traits.hh index d6db2d3e..5768286a 100644 --- a/src/OpenMesh/Core/Mesh/Traits.hh +++ b/src/OpenMesh/Core/Mesh/Traits.hh @@ -152,6 +152,24 @@ struct DefaultTraits FaceAttributes(0); }; +/** \class DefaultTraitsDouble Traits.hh + + Version of Default Traits that uses double precision for points and + normals as well as floating point vectors for colors + + \see The Mesh docu section on \ref mesh_type. + \see Traits.hh for a list of macros for traits classes. +*/ +struct DefaultTraitsDouble : public DefaultTraits +{ + /// Use double precision points + typedef OpenMesh::Vec3d Point; + /// Use double precision Normals + typedef OpenMesh::Vec3d Normal; + /// Use RGBA Color + typedef OpenMesh::Vec4f Color; +}; + //== CLASS DEFINITION ========================================================= From a15f247a6fd8d4534b664924f029cc2a61463146 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 22 Oct 2019 10:08:40 +0200 Subject: [PATCH 2/5] add default mesh types using default doublet traits --- src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh | 66 +++++++++++++++++++++++ src/OpenMesh/Core/Mesh/DefaultTriMesh.hh | 66 +++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh create mode 100644 src/OpenMesh/Core/Mesh/DefaultTriMesh.hh diff --git a/src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh b/src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh new file mode 100644 index 00000000..59e31ee3 --- /dev/null +++ b/src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh @@ -0,0 +1,66 @@ +/* ========================================================================= * + * * + * OpenMesh * + * Copyright (c) 2001-2019, 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_DEFAULTTRIMESH_HH +#define OPENMESH_DEFAULTTRIMESH_HH + + +//== INCLUDES ================================================================= + +#include +#include + +//== NAMESPACES =============================================================== + +namespace OpenMesh { + +//== TYPEDEFS ================================================================= + +typedef PolyMesh_ArrayKernelT PolyMesh; + +//============================================================================= +} // namespace OpenMesh +//============================================================================= + +//============================================================================= +#endif // OPENMESH_DEFAULTTRIMESH_HH defined +//============================================================================= diff --git a/src/OpenMesh/Core/Mesh/DefaultTriMesh.hh b/src/OpenMesh/Core/Mesh/DefaultTriMesh.hh new file mode 100644 index 00000000..94fb4039 --- /dev/null +++ b/src/OpenMesh/Core/Mesh/DefaultTriMesh.hh @@ -0,0 +1,66 @@ +/* ========================================================================= * + * * + * OpenMesh * + * Copyright (c) 2001-2019, 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_DEFAULTTRIMESH_HH +#define OPENMESH_DEFAULTTRIMESH_HH + + +//== INCLUDES ================================================================= + +#include +#include + +//== NAMESPACES =============================================================== + +namespace OpenMesh { + +//== TYPEDEFS ================================================================= + +typedef TriMesh_ArrayKernelT TriMesh; + +//============================================================================= +} // namespace OpenMesh +//============================================================================= + +//============================================================================= +#endif // OPENMESH_DEFAULTTRIMESH_HH defined +//============================================================================= From 2343577636174a1e603bc2f4f7d91ebc9c5aaacb Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 22 Oct 2019 10:17:12 +0200 Subject: [PATCH 3/5] add unittests for default double vec type --- CI/Windows.bat | 4 ++++ CI/ci-linux.sh | 31 ++++++++++++++++++++++++++----- CI/ci-mac.sh | 31 ++++++++++++++++++++++++++----- src/Unittests/CMakeLists.txt | 22 +++++++++++++++++++--- 4 files changed, 75 insertions(+), 13 deletions(-) diff --git a/CI/Windows.bat b/CI/Windows.bat index d4f44307..36f18285 100644 --- a/CI/Windows.bat +++ b/CI/Windows.bat @@ -119,6 +119,8 @@ unittests.exe --gtest_output=xml unittests_customvec.exe --gtest_output=xml +unittests_doublevec.exe --gtest_output=xml + cd .. cd .. @@ -147,6 +149,8 @@ unittests.exe --gtest_output=xml unittests_customvec.exe --gtest_output=xml +unittests_doublevec.exe --gtest_output=xml + IF %errorlevel% NEQ 0 exit /b %errorlevel% cd .. diff --git a/CI/ci-linux.sh b/CI/ci-linux.sh index fe75b847..468a7872 100755 --- a/CI/ci-linux.sh +++ b/CI/ci-linux.sh @@ -87,6 +87,8 @@ make $MAKE_OPTIONS #build the unit tests make $MAKE_OPTIONS unittests +cd Unittests + echo -e "${OUTPUT}" echo "" echo "======================================================================" @@ -94,8 +96,6 @@ echo "Running unittests Release version with vectorchecks enabled" echo "======================================================================" echo -e "${NC}" -cd Unittests - #execute tests ./unittests --gtest_color=yes --gtest_output=xml @@ -106,8 +106,19 @@ echo "Running unittests Release version with custom vector type" echo "======================================================================" echo -e "${NC}" +#execute tests ./unittests_customvec --gtest_color=yes --gtest_output=xml +echo -e "${OUTPUT}" +echo "" +echo "======================================================================" +echo "Running unittests Release version with double vector type" +echo "======================================================================" +echo -e "${NC}" + +#execute tests +./unittests_doublevec --gtest_color=yes --gtest_output=xml + cd .. cd .. @@ -133,6 +144,8 @@ make $MAKE_OPTIONS #build the unit tests make $MAKE_OPTIONS unittests +cd Unittests + echo -e "${OUTPUT}" echo "" echo "======================================================================" @@ -140,9 +153,6 @@ echo "Running unittests Debug version with vectorchecks enabled" echo "======================================================================" echo -e "${NC}" - -cd Unittests - #execute tests ./unittests --gtest_color=yes --gtest_output=xml @@ -153,7 +163,18 @@ echo "Running unittests Debug version with custom vector type" echo "======================================================================" echo -e "${NC}" +#execute tests ./unittests_customvec --gtest_color=yes --gtest_output=xml +echo -e "${OUTPUT}" +echo "" +echo "======================================================================" +echo "Running unittests Debug version with double vector type" +echo "======================================================================" +echo -e "${NC}" + +#execute tests +./unittests_doublevec --gtest_color=yes --gtest_output=xml + cd .. cd .. diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index c3d454cd..493214b2 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -69,6 +69,8 @@ make #build the unit tests make unittests +cd Unittests + echo -e "${OUTPUT}" echo "" echo "======================================================================" @@ -76,8 +78,6 @@ echo "Running unittests Release version with vectorchecks enabled" echo "======================================================================" echo -e "${NC}" -cd Unittests - #execute tests ./unittests --gtest_color=yes --gtest_output=xml @@ -88,8 +88,19 @@ echo "Running unittests Release version with minimal vector type" echo "======================================================================" echo -e "${NC}" +#execute tests ./unittests_customvec --gtest_color=yes --gtest_output=xml +echo -e "${OUTPUT}" +echo "" +echo "======================================================================" +echo "Running unittests Release version with double vector type" +echo "======================================================================" +echo -e "${NC}" + +#execute tests +./unittests_doublevec --gtest_color=yes --gtest_output=xml + cd .. cd .. @@ -115,6 +126,8 @@ make #build the unit tests make unittests +cd Unittests + echo -e "${OUTPUT}" echo "" echo "======================================================================" @@ -122,9 +135,6 @@ echo "Running unittests Debug version with vectorchecks enabled" echo "======================================================================" echo -e "${NC}" - -cd Unittests - #execute tests ./unittests --gtest_color=yes --gtest_output=xml @@ -135,8 +145,19 @@ echo "Running unittests Debug version with minimal vector type" echo "======================================================================" echo -e "${NC}" +#execute tests ./unittests_customvec --gtest_color=yes --gtest_output=xml +echo -e "${OUTPUT}" +echo "" +echo "======================================================================" +echo "Running unittests Debug version with double vector type" +echo "======================================================================" +echo -e "${NC}" + +#execute tests +./unittests_doublevec --gtest_color=yes --gtest_output=xml + cd .. cd .. diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index 7173ddde..e11060cf 100644 --- a/src/Unittests/CMakeLists.txt +++ b/src/Unittests/CMakeLists.txt @@ -41,20 +41,25 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) # Create unittest executable acg_add_executable(unittests ${UNITTEST_SRC}) acg_add_executable(unittests_customvec ${UNITTEST_SRC}) + acg_add_executable(unittests_doublevec ${UNITTEST_SRC}) target_compile_definitions(unittests_customvec PRIVATE TEST_CUSTOM_TRAITS) + target_compile_definitions(unittests_doublevec PRIVATE TEST_DOUBLE_TRAITS) # For the unittest we don't want the install rpath as set by acg_add_executable - set_target_properties ( unittests PROPERTIES BUILD_WITH_INSTALL_RPATH 0 ) + set_target_properties ( unittests PROPERTIES BUILD_WITH_INSTALL_RPATH 0 ) set_target_properties ( unittests_customvec PROPERTIES BUILD_WITH_INSTALL_RPATH 0 ) + set_target_properties ( unittests_doublevec PROPERTIES BUILD_WITH_INSTALL_RPATH 0 ) # Set output directory to ${BINARY_DIR}/Unittests set (OUTPUT_DIR "${CMAKE_BINARY_DIR}/Unittests") - set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR}) + set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR}) set_target_properties(unittests_customvec PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR}) + set_target_properties(unittests_doublevec PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR}) foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${CONFIG} UPCONFIG) set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${UPCONFIG} ${OUTPUT_DIR}) set_target_properties(unittests_customvec PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${UPCONFIG} ${OUTPUT_DIR}) + set_target_properties(unittests_doublevec PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${UPCONFIG} ${OUTPUT_DIR}) endforeach() @@ -62,6 +67,7 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) # Link against all necessary libraries target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread) target_link_libraries(unittests_customvec OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread) + target_link_libraries(unittests_doublevec OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread) @@ -71,8 +77,9 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) add_definitions( -DOPENMESHDLL ) endif() - target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) + target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) target_link_libraries(unittests_customvec OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) + target_link_libraries(unittests_doublevec OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) endif() @@ -81,10 +88,12 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) # Set compiler flags set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long") set_target_properties(unittests_customvec PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long") + set_target_properties(unittests_doublevec PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long") else() # Set compiler flags set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" ) set_target_properties(unittests_customvec PROPERTIES COMPILE_FLAGS "" ) + set_target_properties(unittests_doublevec PROPERTIES COMPILE_FLAGS "" ) endif() if ( OPENMESH_BUILD_SHARED ) @@ -103,14 +112,21 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) "$" "${CMAKE_BINARY_DIR}/Unittests/$" COMMENT "Copying OpenMesh targets to unittests directory") + add_custom_command(TARGET unittests_doublevec POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + "$" + "${CMAKE_BINARY_DIR}/Unittests/$" + COMMENT "Copying OpenMesh targets to unittests directory") endforeach(TAR) endif() acg_copy_after_build(unittests ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/) acg_copy_after_build(unittests_customvec ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/) + acg_copy_after_build(unittests_doublevec ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/) add_test(NAME AllTestsIn_OpenMesh_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests") add_test(NAME AllTestsIn_OpenMesh_tests_with_minimal_vector WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests_customvec") + add_test(NAME AllTestsIn_OpenMesh_tests_with_double_vector WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests_doublevec") else(GTEST_FOUND) message(STATUS "Google testing framework was not found, unittests disabled.") From ef65cf870d473b49e1c81bf55060fbc509faddfd Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 22 Oct 2019 10:37:35 +0200 Subject: [PATCH 4/5] fix copy paste error --- src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh b/src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh index 59e31ee3..56bdda9d 100644 --- a/src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh +++ b/src/OpenMesh/Core/Mesh/DefaultPolyMesh.hh @@ -40,8 +40,8 @@ * ========================================================================= */ -#ifndef OPENMESH_DEFAULTTRIMESH_HH -#define OPENMESH_DEFAULTTRIMESH_HH +#ifndef OPENMESH_DEFAULTPOLYMESH_HH +#define OPENMESH_DEFAULTPOLYMESH_HH //== INCLUDES ================================================================= @@ -62,5 +62,5 @@ typedef PolyMesh_ArrayKernelT PolyMesh; //============================================================================= //============================================================================= -#endif // OPENMESH_DEFAULTTRIMESH_HH defined +#endif // OPENMESH_DEFAULTPOLYMESH_HH defined //============================================================================= From 627a9b770eaf05664c135b1fb38edbad1cc15610 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 22 Oct 2019 15:39:10 +0200 Subject: [PATCH 5/5] add default mesh types to changelog --- Doc/changelog.docu | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/changelog.docu b/Doc/changelog.docu index 60ec3095..ff45eb22 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -11,12 +11,14 @@ Core
  • Property System: Get rid of the OM_FORCE_STATIC_CAST defines. We use the type ids to check if the cast is valid or not. This will add more type safety.
  • +
  • Default Traits: Added DefaultTraitsDouble as a version of the default traits that uses double precision for positions and normals as well as float for colors.
  • +
  • Default Mesh Types: Added typdefs for a Triangle Mesh and a PolyMesh which use DefaultTraitsDouble and can be used as default mesh type be the user.
Tools
    -
  • Subdivider: Fixed crash in Loop subdivider
  • +
  • Subdivider: Fixed crash in Loop subdivider
  • Subdivider: Fixed crash in ModifiedButterfly subdivider