diff --git a/CI/Windows.bat b/CI/Windows.bat index 7e9d9d12..669c18de 100644 --- a/CI/Windows.bat +++ b/CI/Windows.bat @@ -117,6 +117,8 @@ cd unittests unittests.exe --gtest_output=xml +unittests_customvec.exe --gtest_output=xml + cd .. cd .. @@ -143,6 +145,8 @@ cd unittests unittests.exe --gtest_output=xml +unittests_customvec.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 84283cae..b3d28017 100755 --- a/CI/ci-linux.sh +++ b/CI/ci-linux.sh @@ -96,6 +96,15 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +echo -e "${OUTPUT}" +echo "" +echo "======================================================================" +echo "Running unittests Release version with custom vector type" +echo "======================================================================" +echo -e "${NC}" + +./unittests_customvec --gtest_color=yes --gtest_output=xml + cd .. cd .. @@ -134,5 +143,14 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +echo -e "${OUTPUT}" +echo "" +echo "======================================================================" +echo "Running unittests Debug version with custom vector type" +echo "======================================================================" +echo -e "${NC}" + +./unittests_customvec --gtest_color=yes --gtest_output=xml + cd .. cd .. diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index a804012d..5b7ecd94 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -78,6 +78,15 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +echo -e "${OUTPUT}" +echo "" +echo "======================================================================" +echo "Running unittests Release version with minimal vector type" +echo "======================================================================" +echo -e "${NC}" + +./unittests_customvec --gtest_color=yes --gtest_output=xml + cd .. cd .. @@ -116,6 +125,15 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +echo -e "${OUTPUT}" +echo "" +echo "======================================================================" +echo "Running unittests Debug version with minimal vector type" +echo "======================================================================" +echo -e "${NC}" + +./unittests_customvec --gtest_color=yes --gtest_output=xml + cd .. cd .. diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index c9d918ba..b9113a6a 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -718,6 +718,47 @@ noexcept(noexcept(_v1.swap(_v2))) { _v1.swap(_v2); } +/// \relates OpenMesh::VectorT +/// non-member norm +template +Scalar norm(const VectorT& _v) { + return _v.norm(); +} + +/// \relates OpenMesh::VectorT +/// non-member sqrnorm +template +Scalar sqrnorm(const VectorT& _v) { + return _v.sqrnorm(); +} +/// \relates OpenMesh::VectorT +/// non-member vectorize +template +VectorT& vectorize(VectorT& _v, OtherScalar const& _val) { + return _v.vectorize(_val); +} + +/// \relates OpenMesh::VectorT +/// non-member normalize +template +VectorT& normalize(VectorT& _v) { + return _v.normalize(); +} + +/// \relates OpenMesh::VectorT +/// non-member maximize +template +VectorT& maximize(VectorT& _v1, VectorT& _v2) { + return _v1.maximize(_v2); +} + +/// \relates OpenMesh::VectorT +/// non-member minimize +template +VectorT& minimize(VectorT& _v1, VectorT& _v2) { + return _v1.minimize(_v2); +} + //== TYPEDEFS ================================================================= /** 1-byte signed vector */ diff --git a/src/OpenMesh/Core/Geometry/VectorT.hh b/src/OpenMesh/Core/Geometry/VectorT.hh index d8c8f2b1..3384332a 100644 --- a/src/OpenMesh/Core/Geometry/VectorT.hh +++ b/src/OpenMesh/Core/Geometry/VectorT.hh @@ -274,6 +274,52 @@ cross(const VectorT& _v1, const VectorT& _v2) { } +/// \relates OpenMesh::VectorT +/// non-member norm +template +Scalar norm(const VectorT& _v) { + return _v.norm(); +} + + +/// \relates OpenMesh::VectorT +/// non-member sqrnorm +template +Scalar sqrnorm(const VectorT& _v) { + return _v.sqrnorm(); +} + + +/// \relates OpenMesh::VectorT +/// non-member vectorize +template +VectorT& vectorize(VectorT& _v, OtherScalar const& _val) { + return _v.vectorize(_val); +} + + +/// \relates OpenMesh::VectorT +/// non-member normalize +template +VectorT& normalize(VectorT& _v) { + return _v.normalize(); +} + + +/// \relates OpenMesh::VectorT +/// non-member maximize +template +VectorT& maximize(VectorT& _v1, VectorT& _v2) { + return _v1.maximize(_v2); +} + + +/// \relates OpenMesh::VectorT +/// non-member minimize +template +VectorT& minimize(VectorT& _v1, VectorT& _v2) { + return _v1.minimize(_v2); +} //== TYPEDEFS ================================================================= diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.cc b/src/OpenMesh/Core/Mesh/PolyMeshT.cc index 827306dc..64fc9914 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.cc +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.cc @@ -139,18 +139,18 @@ PolyMeshT::calc_face_normal_impl(FaceHandle _fh, PointIs3DTag) const // Due to traits, the value types of normals and points can be different. // Therefore we cast them here. - n[0] += static_cast(a[1] * b[2]); - n[1] += static_cast(a[2] * b[0]); - n[2] += static_cast(a[0] * b[1]); + n[0] += static_cast::value_type>(a[1] * b[2]); + n[1] += static_cast::value_type>(a[2] * b[0]); + n[2] += static_cast::value_type>(a[0] * b[1]); } - const typename vector_traits::value_type norm = n.length(); + const typename vector_traits::value_type length = norm(n); // The expression ((n *= (1.0/norm)),n) is used because the OpenSG // vector class does not return self after component-wise // self-multiplication with a scalar!!! - return (norm != typename vector_traits::value_type(0)) - ? ((n *= (typename vector_traits::value_type(1)/norm)), n) + return (length != typename vector_traits::value_type(0)) + ? ((n *= (typename vector_traits::value_type(1)/length)), n) : Normal(0, 0, 0); } @@ -194,20 +194,22 @@ calc_face_normal_impl(const Point& _p0, Normal p1p2(vector_cast(_p2)); p1p2 -= vector_cast(_p1); Normal n = cross(p1p2, p1p0); - typename vector_traits::value_type norm = n.length(); + typename vector_traits::value_type length = norm(n); // The expression ((n *= (1.0/norm)),n) is used because the OpenSG // vector class does not return self after component-wise // self-multiplication with a scalar!!! - return (norm != typename vector_traits::value_type(0)) ? ((n *= (typename vector_traits::value_type(1)/norm)),n) : Normal(0,0,0); + return (length != typename vector_traits::value_type(0)) + ? ((n *= (typename vector_traits::value_type(1)/length)),n) + : Normal(0,0,0); #else Point p1p0 = _p0; p1p0 -= _p1; Point p1p2 = _p2; p1p2 -= _p1; Normal n = vector_cast(cross(p1p2, p1p0)); - typename vector_traits::value_type norm = n.length(); + typename vector_traits::value_type length = norm(n); - return (norm != 0.0) ? n *= (1.0/norm) : Normal(0,0,0); + return (length != 0.0) ? n *= (1.0/length) : Normal(0,0,0); #endif } @@ -226,7 +228,7 @@ PolyMeshT:: calc_face_centroid(FaceHandle _fh) const { Point _pt; - _pt.vectorize(0); + vectorize(_pt, 0); Scalar valence = 0.0; for (ConstFaceVertexIter cfv_it = this->cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it, valence += 1.0) { @@ -331,7 +333,7 @@ calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle) const for(unsigned int i=0; i void PolyMeshT:: calc_vertex_normal_fast(VertexHandle _vh, Normal& _n) const { - _n.vectorize(0.0); + vectorize(_n, 0.0); for (ConstVertexFaceIter vf_it = this->cvf_iter(_vh); vf_it.is_valid(); ++vf_it) _n += this->normal(*vf_it); } @@ -399,7 +401,7 @@ template void PolyMeshT:: calc_vertex_normal_correct(VertexHandle _vh, Normal& _n) const { - _n.vectorize(0.0); + vectorize(_n, 0.0); ConstVertexIHalfedgeIter cvih_it = this->cvih_iter(_vh); if (! cvih_it.is_valid() ) {//don't crash on isolated vertices diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index b29ea40e..31796fb8 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.hh @@ -406,7 +406,7 @@ public: { Normal edge_vec; calc_edge_vector(_heh, edge_vec); - return edge_vec.sqrnorm(); + return sqrnorm(edge_vec); } /** Calculates the midpoint of the halfedge _heh, defined by the positions of @@ -444,7 +444,7 @@ public: { Normal v0, v1; calc_sector_vectors(_in_heh, v0, v1); - Scalar denom = v0.norm()*v1.norm(); + Scalar denom = norm(v0)*norm(v1); if ( denom == Scalar(0)) { return 0; @@ -470,7 +470,7 @@ public: Normal in_vec, out_vec; calc_edge_vector(_in_heh, in_vec); calc_edge_vector(next_halfedge_handle(_in_heh), out_vec); - Scalar denom = in_vec.norm()*out_vec.norm(); + Scalar denom = norm(in_vec)*norm(out_vec); if (is_zero(denom)) { _cos_a = 1; @@ -479,7 +479,7 @@ public: else { _cos_a = dot(in_vec, out_vec)/denom; - _sin_a = cross(in_vec, out_vec).norm()/denom; + _sin_a = norm(cross(in_vec, out_vec))/denom; } } */ @@ -499,7 +499,7 @@ public: { Normal sector_normal; calc_sector_normal(_in_heh, sector_normal); - return sector_normal.norm()/2; + return norm(sector_normal)/2; } /** calculates the dihedral angle on the halfedge _heh @@ -539,7 +539,7 @@ public: calc_sector_normal(_heh, n0); calc_sector_normal(this->opposite_halfedge_handle(_heh), n1); calc_edge_vector(_heh, he); - Scalar denom = n0.norm()*n1.norm(); + Scalar denom = norm(n0)*norm(n1); if (denom == Scalar(0)) { return 0; diff --git a/src/OpenMesh/Core/Mesh/TriMeshT.hh b/src/OpenMesh/Core/Mesh/TriMeshT.hh index 6ff32f3c..1865f30c 100644 --- a/src/OpenMesh/Core/Mesh/TriMeshT.hh +++ b/src/OpenMesh/Core/Mesh/TriMeshT.hh @@ -359,9 +359,9 @@ public: VertexHandle p2 = this->to_vertex_handle(he2); // Calculate midpoint coordinates - const Point new0 = (this->point(p0) + this->point(p2)) * static_cast< typename Point::value_type >(0.5); - const Point new1 = (this->point(p0) + this->point(p1)) * static_cast< typename Point::value_type >(0.5); - const Point new2 = (this->point(p1) + this->point(p2)) * static_cast< typename Point::value_type >(0.5); + const Point new0 = (this->point(p0) + this->point(p2)) * static_cast::value_type >(0.5); + const Point new1 = (this->point(p0) + this->point(p1)) * static_cast::value_type >(0.5); + const Point new2 = (this->point(p1) + this->point(p2)) * static_cast::value_type >(0.5); // Add vertices at midpoint coordinates VertexHandle v0 = this->add_vertex(new0); diff --git a/src/OpenMesh/Core/Utils/vector_cast.hh b/src/OpenMesh/Core/Utils/vector_cast.hh index 94f991a5..39fca197 100644 --- a/src/OpenMesh/Core/Utils/vector_cast.hh +++ b/src/OpenMesh/Core/Utils/vector_cast.hh @@ -95,7 +95,6 @@ inline void vector_cast( const src_t & /*_src*/, dst_t & /*_dst*/, GenProg::Int2 { } - template inline void vector_copy( const src_t &_src, dst_t &_dst, GenProg::Int2Type ) { diff --git a/src/OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.cc b/src/OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.cc index 62fa98c1..f038006f 100644 --- a/src/OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.cc +++ b/src/OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.cc @@ -181,7 +181,7 @@ compute_new_positions_C1() if (diag) uu *= static_cast(1.0) / diag; // damping - uu *= static_cast(0.25); + uu *= static_cast::value_type>(0.25); // store new position p = vector_cast(Base::mesh_.point(*v_it)); diff --git a/src/OpenMesh/Tools/Smoother/SmootherT.cc b/src/OpenMesh/Tools/Smoother/SmootherT.cc index 2bb44bd0..c727aeba 100644 --- a/src/OpenMesh/Tools/Smoother/SmootherT.cc +++ b/src/OpenMesh/Tools/Smoother/SmootherT.cc @@ -263,13 +263,13 @@ set_relative_local_error(Scalar _err) bb_min = bb_max = mesh_.point(*v_it); for (++v_it; v_it!=v_end; ++v_it) { - bb_min.minimize(mesh_.point(*v_it)); - bb_max.maximize(mesh_.point(*v_it)); + minimize(bb_min, mesh_.point(*v_it)); + maximize(bb_max, mesh_.point(*v_it)); } // abs. error = rel. error * bounding-diagonal - set_absolute_local_error(_err * (bb_max-bb_min).norm()); + set_absolute_local_error(norm(_err * (bb_max-bb_min))); } } diff --git a/src/OpenMesh/Tools/Subdivider/Uniform/CatmullClarkT.cc b/src/OpenMesh/Tools/Subdivider/Uniform/CatmullClarkT.cc index 712ddb51..1813c2fe 100644 --- a/src/OpenMesh/Tools/Subdivider/Uniform/CatmullClarkT.cc +++ b/src/OpenMesh/Tools/Subdivider/Uniform/CatmullClarkT.cc @@ -346,7 +346,7 @@ CatmullClarkT::update_vertex( MeshType& _m, const VertexHandl for ( ve_itr = _m.ve_iter( _vh); ve_itr.is_valid(); ++ve_itr) if ( _m.is_boundary( *ve_itr)) pos += _m.property( ep_pos_, *ve_itr); - pos /= static_cast(3.0); + pos /= static_cast::value_type>(3.0); } else // inner vertex { diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index a6ea5e7b..ab128f5e 100644 --- a/src/Unittests/CMakeLists.txt +++ b/src/Unittests/CMakeLists.txt @@ -30,22 +30,28 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) FILE(GLOB UNITTEST_SRC *.cc) # Create unittest executable acg_add_executable(unittests ${UNITTEST_SRC}) + acg_add_executable(unittests_customvec ${UNITTEST_SRC}) + target_compile_definitions(unittests_customvec PRIVATE TEST_CUSTOM_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 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_customvec 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}) endforeach() if ( NOT WIN32) # 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) @@ -56,6 +62,7 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) endif() target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) + target_link_libraries(unittests_customvec OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) endif() @@ -63,10 +70,11 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) if ( NOT WIN32 ) # 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") else() # Set compiler flags set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" ) - + set_target_properties(unittests_customvec PROPERTIES COMPILE_FLAGS "" ) endif() if ( OPENMESH_BUILD_SHARED ) @@ -80,12 +88,19 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) "$" "${CMAKE_BINARY_DIR}/Unittests/$" COMMENT "Copying OpenMesh targets to unittests directory") + add_custom_command(TARGET unittests_customvec 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/) 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") else(GTEST_FOUND) message(STATUS "Google testing framework was not found, unittests disabled.") diff --git a/src/Unittests/unittests_common.hh b/src/Unittests/unittests_common.hh index cbabb9cb..0d095701 100644 --- a/src/Unittests/unittests_common.hh +++ b/src/Unittests/unittests_common.hh @@ -7,8 +7,13 @@ #include #include +#ifdef TEST_CUSTOM_TRAITS +#include +#else struct CustomTraits : public OpenMesh::DefaultTraits { }; +#endif + typedef OpenMesh::TriMesh_ArrayKernelT Mesh; diff --git a/src/Unittests/unittests_common_customtraits.hh b/src/Unittests/unittests_common_customtraits.hh new file mode 100644 index 00000000..bb3ec8f8 --- /dev/null +++ b/src/Unittests/unittests_common_customtraits.hh @@ -0,0 +1,139 @@ +#ifndef UNITTESTS_COMMON_DUMMYTRAITS +#define UNITTESTS_COMMON_DUMMYTRAITS +#include +#include +#include + +namespace Custom { + +/// A Vector class with the absolute minimum of built-in methods to test the +/// interface expected from Vectors used in Traits +template class Vec { + public: + // Constructor with DIM components + Vec(float x) : data({ x }) {} + Vec(float x, float y) : data({ x, y }) {} + Vec(float x, float y, float z) : data({ x, y, z }) {} + Vec(float x, float y, float z, float w) : data({ x, y, z, w }) {} + + Vec() = default; + Vec(Vec const &) = default; + + float &operator[](int i) { return data[i]; } + float operator[](int i) const { return data[i]; } + + private: + std::array data; +}; + +template bool operator==(Vec const &lhs, Vec const &rhs) { + for (int i = 0; i < DIM; i++) + if (lhs[i] != rhs[i]) return false; + return true; +} + +template +Vec operator+(Vec const &lhs, Vec const &rhs) { + Vec result; + for (int i = 0; i < DIM; i++) + result[i] = lhs[i] + rhs[i]; + return result; +} + +template +Vec operator-(Vec const &lhs, Vec const &rhs) { + Vec result; + for (int i = 0; i < DIM; i++) + result[i] = lhs[i] - rhs[i]; + return result; +} + +template Vec operator*(Vec const &lhs, float rhs) { + Vec result; + for (int i = 0; i < DIM; i++) + result[i] = lhs[i] * rhs; + return result; +} + +template Vec operator*(float lhs, Vec const &rhs) { + return rhs * lhs; +} + +template Vec operator/(Vec const &lhs, float rhs) { + Vec result; + for (int i = 0; i < DIM; i++) + result[i] = lhs[i] / rhs; + return result; +} + +template Vec &operator+=(Vec &lhs, Vec const &rhs) { + return lhs = lhs + rhs; +} +template Vec &operator-=(Vec &lhs, Vec const &rhs) { + return lhs = lhs - rhs; +} +template Vec &operator*=(Vec &lhs, float rhs) { + return lhs = lhs * rhs; +} +template Vec &operator/=(Vec &lhs, float rhs) { + return lhs = lhs / rhs; +} + +template float norm(Vec const &v) { + float sum = 0.0f; + for (int i = 0; i < DIM; i++) + sum += v[i] * v[i]; + return std::sqrt(sum); +} + +template Vec &normalize(Vec &v) { return v /= norm(v); } +template Vec &vectorize(Vec &v, float val) { + for (int i = 0; i < DIM; i++) + v[i] = val; + return v; +} + +template Vec &minimize(Vec &v1, Vec const &v2) { + for (int i = 0; i < DIM; i++) + v1[i] = std::min(v1[i], v2[i]); + return v1; +} + +template Vec &maximize(Vec &v1, Vec const &v2) { + for (int i = 0; i < DIM; i++) + v1[i] = std::max(v1[i], v2[i]); + return v1; +} + +template float dot(Vec const &v1, Vec const &v2) { + float sum = 0.f; + for (int i = 0; i < DIM; i++) + sum += v1[i] * v2[i]; + return sum; +} + +inline Vec<3> cross(Vec<3> const &v1, Vec<3> const &v2) { + return {v1[1] * v2[2] - v1[2] * v2[1], // + v1[2] * v2[0] - v1[0] * v2[2], // + v1[0] * v2[1] - v1[1] * v2[0]}; +} +} + +namespace OpenMesh { +template struct vector_traits> { + using vector_type = Custom::Vec; + using value_type = float; + static const size_t size_ = DIM; + static size_t size() { return size_; } +}; +} + +struct CustomTraits : public OpenMesh::DefaultTraits { + typedef Custom::Vec<3> Point; + typedef Custom::Vec<3> Normal; + + typedef Custom::Vec<2> TexCoord2D; + typedef Custom::Vec<3> TexCoord3D; +}; + +#endif // UNITTESTS_COMMON_DUMMYTRAITS diff --git a/src/Unittests/unittests_normal_calculations.cc b/src/Unittests/unittests_normal_calculations.cc index 07342a67..30d350f0 100644 --- a/src/Unittests/unittests_normal_calculations.cc +++ b/src/Unittests/unittests_normal_calculations.cc @@ -247,7 +247,7 @@ TEST_F(OpenMeshNormals, NormalCalculations_calc_vertex_normal_fast) { mesh_.request_face_normals(); - OpenMesh::Vec3f normal; + Mesh::Normal normal; mesh_.calc_vertex_normal_fast(vhandle[2],normal); @@ -304,7 +304,7 @@ TEST_F(OpenMeshNormals, NormalCalculations_calc_vertex_normal_correct) { mesh_.request_halfedge_normals(); mesh_.request_face_normals(); - OpenMesh::Vec3f normal; + Mesh::Normal normal; mesh_.calc_vertex_normal_correct(vhandle[2],normal); @@ -361,7 +361,7 @@ TEST_F(OpenMeshNormals, NormalCalculations_calc_vertex_normal_loop) { mesh_.request_halfedge_normals(); mesh_.request_face_normals(); - OpenMesh::Vec3f normal; + Mesh::Normal normal; mesh_.calc_vertex_normal_loop(vhandle[2],normal); diff --git a/src/Unittests/unittests_trimesh_others.cc b/src/Unittests/unittests_trimesh_others.cc index a9aaebd1..5a771021 100644 --- a/src/Unittests/unittests_trimesh_others.cc +++ b/src/Unittests/unittests_trimesh_others.cc @@ -164,7 +164,8 @@ TEST_F(OpenMeshOthers, CalcDihedralAngre ) { EXPECT_EQ( 0.0 , mesh_.calc_dihedral_angle(eh) ) << "Wrong Dihedral angle!" << std::endl; // Modify point - Mesh::Point tmp = ( Mesh::Point(0.0, 0.0, -1.0) + Mesh::Point(1.0, 1.0, -1.0) ) * static_cast(0.5); + Mesh::Point tmp = ( Mesh::Point(0.0, 0.0, -1.0) + Mesh::Point(1.0, 1.0, -1.0) ) + * static_cast::value_type>(0.5); mesh_.point(vhandle[2]) = tmp; double difference = fabs( 1.36944 - mesh_.calc_dihedral_angle(eh) ); diff --git a/src/Unittests/unittests_tutorials.cc b/src/Unittests/unittests_tutorials.cc index 4a7ac5ba..768cf485 100644 --- a/src/Unittests/unittests_tutorials.cc +++ b/src/Unittests/unittests_tutorials.cc @@ -619,20 +619,20 @@ TEST_F(OpenMeshTutorials, deleting_geometry_elements) { mesh.request_vertex_status(); // generate vertices - MyMeshWithStatus::VertexHandle vhandle[8]; - MyMeshWithStatus::FaceHandle fhandle[6]; + Mesh::VertexHandle vhandle[8]; + Mesh::FaceHandle fhandle[6]; - vhandle[0] = mesh.add_vertex(MyMesh::Point(-1, -1, 1)); - vhandle[1] = mesh.add_vertex(MyMesh::Point( 1, -1, 1)); - vhandle[2] = mesh.add_vertex(MyMesh::Point( 1, 1, 1)); - vhandle[3] = mesh.add_vertex(MyMesh::Point(-1, 1, 1)); - vhandle[4] = mesh.add_vertex(MyMesh::Point(-1, -1, -1)); - vhandle[5] = mesh.add_vertex(MyMesh::Point( 1, -1, -1)); - vhandle[6] = mesh.add_vertex(MyMesh::Point( 1, 1, -1)); - vhandle[7] = mesh.add_vertex(MyMesh::Point(-1, 1, -1)); + vhandle[0] = mesh.add_vertex(Mesh::Point(-1, -1, 1)); + vhandle[1] = mesh.add_vertex(Mesh::Point( 1, -1, 1)); + vhandle[2] = mesh.add_vertex(Mesh::Point( 1, 1, 1)); + vhandle[3] = mesh.add_vertex(Mesh::Point(-1, 1, 1)); + vhandle[4] = mesh.add_vertex(Mesh::Point(-1, -1, -1)); + vhandle[5] = mesh.add_vertex(Mesh::Point( 1, -1, -1)); + vhandle[6] = mesh.add_vertex(Mesh::Point( 1, 1, -1)); + vhandle[7] = mesh.add_vertex(Mesh::Point(-1, 1, -1)); // generate (quadrilateral) faces - std::vector tmp_face_vhandles; + std::vector tmp_face_vhandles; tmp_face_vhandles.clear(); tmp_face_vhandles.push_back(vhandle[0]); tmp_face_vhandles.push_back(vhandle[1]); @@ -807,10 +807,10 @@ TEST_F(OpenMeshTutorials, flipping_edges) { Mesh mesh; // Add some vertices Mesh::VertexHandle vhandle[4]; - vhandle[0] = mesh.add_vertex(MyMesh::Point(0, 0, 0)); - vhandle[1] = mesh.add_vertex(MyMesh::Point(0, 1, 0)); - vhandle[2] = mesh.add_vertex(MyMesh::Point(1, 1, 0)); - vhandle[3] = mesh.add_vertex(MyMesh::Point(1, 0, 0)); + vhandle[0] = mesh.add_vertex(Mesh::Point(0, 0, 0)); + vhandle[1] = mesh.add_vertex(Mesh::Point(0, 1, 0)); + vhandle[2] = mesh.add_vertex(Mesh::Point(1, 1, 0)); + vhandle[3] = mesh.add_vertex(Mesh::Point(1, 0, 0)); // Add two faces std::vector face_vhandles; face_vhandles.push_back(vhandle[2]); @@ -846,13 +846,13 @@ TEST_F(OpenMeshTutorials, collapsing_edges) { mesh.request_edge_status(); // Add some vertices as in the illustration above PolyMesh::VertexHandle vhandle[7]; - vhandle[0] = mesh.add_vertex(MyMesh::Point(-1, 1, 0)); - vhandle[1] = mesh.add_vertex(MyMesh::Point(-1, 3, 0)); - vhandle[2] = mesh.add_vertex(MyMesh::Point(0, 0, 0)); - vhandle[3] = mesh.add_vertex(MyMesh::Point(0, 2, 0)); - vhandle[4] = mesh.add_vertex(MyMesh::Point(0, 4, 0)); - vhandle[5] = mesh.add_vertex(MyMesh::Point(1, 1, 0)); - vhandle[6] = mesh.add_vertex(MyMesh::Point(1, 3, 0)); + vhandle[0] = mesh.add_vertex(PolyMesh::Point(-1, 1, 0)); + vhandle[1] = mesh.add_vertex(PolyMesh::Point(-1, 3, 0)); + vhandle[2] = mesh.add_vertex(PolyMesh::Point(0, 0, 0)); + vhandle[3] = mesh.add_vertex(PolyMesh::Point(0, 2, 0)); + vhandle[4] = mesh.add_vertex(PolyMesh::Point(0, 4, 0)); + vhandle[5] = mesh.add_vertex(PolyMesh::Point(1, 1, 0)); + vhandle[6] = mesh.add_vertex(PolyMesh::Point(1, 3, 0)); // Add three quad faces std::vector face_vhandles; face_vhandles.push_back(vhandle[1]); diff --git a/src/Unittests/unittests_vdpm.cc b/src/Unittests/unittests_vdpm.cc index 46a8110d..f037ca58 100644 --- a/src/Unittests/unittests_vdpm.cc +++ b/src/Unittests/unittests_vdpm.cc @@ -185,7 +185,7 @@ LoadInfo open_progresult_mesh(const std::string& _filename) OpenMesh::IO::restore(ifs, vr, swap); PMInfo pminfo; - pminfo.p0 = p; + pminfo.p0 = OpenMesh::vector_cast(p); pminfo.v0 = result.mesh.add_vertex(p); pminfo.v1 = Mesh::VertexHandle(v1); pminfo.vl = Mesh::VertexHandle(vl);