From 5e7493b3a930e0acf6f72f1439ebb8ac24cde6ff Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Thu, 12 Apr 2018 11:11:55 +0200 Subject: [PATCH 01/17] Altered PolyMesh template to work with Eigen's Vectors --- src/OpenMesh/Core/Mesh/PolyMeshT.cc | 24 +++++++++++++----------- src/OpenMesh/Core/Mesh/PolyMeshT.hh | 12 ++++++------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.cc b/src/OpenMesh/Core/Mesh/PolyMeshT.cc index 827306dc..bb88a68b 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.cc +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.cc @@ -144,13 +144,13 @@ PolyMeshT::calc_face_normal_impl(FaceHandle _fh, PointIs3DTag) const n[2] += static_cast(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 } @@ -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); } diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index b29ea40e..3aaa2279 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 = length(v0)*length(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 = length(in_vec)*length(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 = length(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 length(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 = length(n0)*length(n1); if (denom == Scalar(0)) { return 0; From 57e2e0743271328ddb76fc7cca95f730e0806e45 Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Thu, 12 Apr 2018 11:30:12 +0200 Subject: [PATCH 02/17] Implemented necessary free functions for OpenMesh Vectors --- src/OpenMesh/Core/Geometry/Vector11T.hh | 28 +++++++++++++++++++++++++ src/OpenMesh/Core/Mesh/PolyMeshT.hh | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index c9d918ba..c820008d 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -718,6 +718,34 @@ 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(); +} + + //== TYPEDEFS ================================================================= /** 1-byte signed vector */ diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index 3aaa2279..90def28f 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.hh @@ -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 = length(n0)*length(n1); + Scalar denom = norm(n0)*norm(n1); if (denom == Scalar(0)) { return 0; From 377562d11a6ab666d3ce0c5ea1b9e272a771a483 Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Thu, 12 Apr 2018 15:16:50 +0200 Subject: [PATCH 03/17] Fixed last occurences of non-free-function usage (at least as far as covered by the tests). --- src/OpenMesh/Core/Geometry/Vector11T.hh | 13 +++++++++++++ src/OpenMesh/Core/Mesh/PolyMeshT.cc | 10 +++++----- src/OpenMesh/Core/Mesh/TriMeshT.hh | 6 +++--- src/OpenMesh/Core/Utils/vector_cast.hh | 1 - .../Tools/Smoother/JacobiLaplaceSmootherT.cc | 2 +- src/OpenMesh/Tools/Smoother/SmootherT.cc | 6 +++--- .../Tools/Subdivider/Uniform/CatmullClarkT.cc | 2 +- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index c820008d..b9113a6a 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -745,6 +745,19 @@ 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 bb88a68b..64fc9914 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.cc +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.cc @@ -139,9 +139,9 @@ 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 length = norm(n); @@ -228,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) { @@ -401,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/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 { From 5a2f426d8c0700c82637e1fcbc8a823892a5f07e Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Thu, 12 Apr 2018 15:18:11 +0200 Subject: [PATCH 04/17] Unittests now use the Point/Normal types related to the mesh type, instead of relying on them being OpenMesh vectors. --- .../unittests_normal_calculations.cc | 6 +-- src/Unittests/unittests_trimesh_others.cc | 3 +- src/Unittests/unittests_tutorials.cc | 38 +++++++++---------- src/Unittests/unittests_vdpm.cc | 2 +- 4 files changed, 25 insertions(+), 24 deletions(-) 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..e7fb2d20 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..0dd69201 100644 --- a/src/Unittests/unittests_tutorials.cc +++ b/src/Unittests/unittests_tutorials.cc @@ -622,14 +622,14 @@ TEST_F(OpenMeshTutorials, deleting_geometry_elements) { MyMeshWithStatus::VertexHandle vhandle[8]; MyMeshWithStatus::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; @@ -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); From f12ca3fefe142e5a34085c4cee363d2e93b74fd9 Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Thu, 12 Apr 2018 15:19:53 +0200 Subject: [PATCH 05/17] Added a minimal vector type that makes the OpenMesh tests pass. --- src/Unittests/CMakeLists.txt | 17 +- src/Unittests/unittests_common.hh | 5 + .../unittests_common_customtraits.hh | 145 ++++++++++++++++++ 3 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 src/Unittests/unittests_common_customtraits.hh diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index a6ea5e7b..a8b02724 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 ${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,9 +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 "-g -pedantic -Wno-long-long") endif() @@ -80,10 +89,16 @@ 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") 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..a53f724d --- /dev/null +++ b/src/Unittests/unittests_common_customtraits.hh @@ -0,0 +1,145 @@ +#ifndef UNITTESTS_COMMON_DUMMYTRAITS +#define UNITTESTS_COMMON_DUMMYTRAITS +#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 + template ::type, + typename = typename std::enable_if< + are_convertible_to::value>::type> + constexpr Vec(T v, Ts... vs) + : data{{static_cast(v), static_cast(vs)...}} { + static_assert(sizeof...(Ts)+1 == DIM, + "Invalid number of components specified in constructor."); + static_assert(are_convertible_to::value, + "Not all components are convertible to Scalar."); + } + + constexpr Vec() = default; + constexpr 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 From 4eab053275e3b11f0b46d9df9b7869eb07be553e Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Thu, 12 Apr 2018 16:07:41 +0200 Subject: [PATCH 06/17] Added free functions for non-C++11 Vectors --- src/OpenMesh/Core/Geometry/VectorT.hh | 39 ++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Geometry/VectorT.hh b/src/OpenMesh/Core/Geometry/VectorT.hh index d8c8f2b1..be8610f3 100644 --- a/src/OpenMesh/Core/Geometry/VectorT.hh +++ b/src/OpenMesh/Core/Geometry/VectorT.hh @@ -264,7 +264,6 @@ dot(const VectorT& _v1, const VectorT& _v2) { return (_v1 | _v2); } - /// \relates OpenMesh::VectorT /// symmetric version of the cross product template @@ -273,8 +272,46 @@ cross(const VectorT& _v1, const VectorT& _v2) { return (_v1 % _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 ================================================================= From dc4243f928b2a686d4f6f4ca5a9c199b01f36d09 Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Thu, 12 Apr 2018 17:53:54 +0200 Subject: [PATCH 07/17] Now builds on VS 2013 --- src/Unittests/CMakeLists.txt | 3 +-- .../unittests_common_customtraits.hh | 22 +++++++------------ src/Unittests/unittests_trimesh_others.cc | 2 +- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index a8b02724..3843175f 100644 --- a/src/Unittests/CMakeLists.txt +++ b/src/Unittests/CMakeLists.txt @@ -74,8 +74,7 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) else() # Set compiler flags set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" ) - set_target_properties(unittests_customvec PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long") - + set_target_properties(unittests_customvec PROPERTIES COMPILE_FLAGS "" ) endif() if ( OPENMESH_BUILD_SHARED ) diff --git a/src/Unittests/unittests_common_customtraits.hh b/src/Unittests/unittests_common_customtraits.hh index a53f724d..bb3ec8f8 100644 --- a/src/Unittests/unittests_common_customtraits.hh +++ b/src/Unittests/unittests_common_customtraits.hh @@ -2,6 +2,7 @@ #define UNITTESTS_COMMON_DUMMYTRAITS #include #include +#include namespace Custom { @@ -10,20 +11,13 @@ namespace Custom { template class Vec { public: // Constructor with DIM components - template ::type, - typename = typename std::enable_if< - are_convertible_to::value>::type> - constexpr Vec(T v, Ts... vs) - : data{{static_cast(v), static_cast(vs)...}} { - static_assert(sizeof...(Ts)+1 == DIM, - "Invalid number of components specified in constructor."); - static_assert(are_convertible_to::value, - "Not all components are convertible to Scalar."); - } - - constexpr Vec() = default; - constexpr Vec(Vec const &) = default; + 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]; } diff --git a/src/Unittests/unittests_trimesh_others.cc b/src/Unittests/unittests_trimesh_others.cc index e7fb2d20..5a771021 100644 --- a/src/Unittests/unittests_trimesh_others.cc +++ b/src/Unittests/unittests_trimesh_others.cc @@ -165,7 +165,7 @@ TEST_F(OpenMeshOthers, CalcDihedralAngre ) { // Modify point 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); + * static_cast::value_type>(0.5); mesh_.point(vhandle[2]) = tmp; double difference = fabs( 1.36944 - mesh_.calc_dihedral_angle(eh) ); From 7bb868b2bef21598645b0aa8cb9e49a9683b238e Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Mon, 16 Apr 2018 13:15:45 +0200 Subject: [PATCH 08/17] Replaced usage of length() by norm() to avoid forcing both to be implemented --- src/OpenMesh/Core/Mesh/PolyMeshT.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index 90def28f..31796fb8 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.hh @@ -444,7 +444,7 @@ public: { Normal v0, v1; calc_sector_vectors(_in_heh, v0, v1); - Scalar denom = length(v0)*length(v1); + 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 = length(in_vec)*length(out_vec); + 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 = length(cross(in_vec, out_vec))/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 length(sector_normal)/2; + return norm(sector_normal)/2; } /** calculates the dihedral angle on the halfedge _heh From da002408f9048ea2db5ec9b77d90b5e28b35cb11 Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Mon, 16 Apr 2018 13:18:57 +0200 Subject: [PATCH 09/17] Corrected point type in unittest --- src/Unittests/unittests_tutorials.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Unittests/unittests_tutorials.cc b/src/Unittests/unittests_tutorials.cc index 0dd69201..6ec4b36a 100644 --- a/src/Unittests/unittests_tutorials.cc +++ b/src/Unittests/unittests_tutorials.cc @@ -622,14 +622,14 @@ TEST_F(OpenMeshTutorials, deleting_geometry_elements) { MyMeshWithStatus::VertexHandle vhandle[8]; MyMeshWithStatus::FaceHandle fhandle[6]; - 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)); + vhandle[0] = mesh.add_vertex(MyMeshWithStatus::Point(-1, -1, 1)); + vhandle[1] = mesh.add_vertex(MyMeshWithStatus::Point( 1, -1, 1)); + vhandle[2] = mesh.add_vertex(MyMeshWithStatus::Point( 1, 1, 1)); + vhandle[3] = mesh.add_vertex(MyMeshWithStatus::Point(-1, 1, 1)); + vhandle[4] = mesh.add_vertex(MyMeshWithStatus::Point(-1, -1, -1)); + vhandle[5] = mesh.add_vertex(MyMeshWithStatus::Point( 1, -1, -1)); + vhandle[6] = mesh.add_vertex(MyMeshWithStatus::Point( 1, 1, -1)); + vhandle[7] = mesh.add_vertex(MyMeshWithStatus::Point(-1, 1, -1)); // generate (quadrilateral) faces std::vector tmp_face_vhandles; From 74350f54de749c14d466bbb6e75c77fe0342107b Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Mon, 16 Apr 2018 13:21:54 +0200 Subject: [PATCH 10/17] Proper spacing between methods --- src/OpenMesh/Core/Geometry/VectorT.hh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/OpenMesh/Core/Geometry/VectorT.hh b/src/OpenMesh/Core/Geometry/VectorT.hh index be8610f3..3384332a 100644 --- a/src/OpenMesh/Core/Geometry/VectorT.hh +++ b/src/OpenMesh/Core/Geometry/VectorT.hh @@ -264,6 +264,7 @@ dot(const VectorT& _v1, const VectorT& _v2) { return (_v1 | _v2); } + /// \relates OpenMesh::VectorT /// symmetric version of the cross product template @@ -272,6 +273,7 @@ cross(const VectorT& _v1, const VectorT& _v2) { return (_v1 % _v2); } + /// \relates OpenMesh::VectorT /// non-member norm template @@ -279,12 +281,15 @@ 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 @@ -292,6 +297,7 @@ VectorT& vectorize(VectorT& _v, OtherScalar const& _va return _v.vectorize(_val); } + /// \relates OpenMesh::VectorT /// non-member normalize template @@ -299,6 +305,7 @@ VectorT& normalize(VectorT& _v) { return _v.normalize(); } + /// \relates OpenMesh::VectorT /// non-member maximize template @@ -306,6 +313,7 @@ VectorT& maximize(VectorT& _v1, VectorT& return _v1.maximize(_v2); } + /// \relates OpenMesh::VectorT /// non-member minimize template @@ -313,6 +321,7 @@ VectorT& minimize(VectorT& _v1, VectorT& return _v1.minimize(_v2); } + //== TYPEDEFS ================================================================= /** 1-byte signed vector */ From f1a565e0b6a7b110b2a6b52470ff3df29087669f Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Mon, 16 Apr 2018 13:24:57 +0200 Subject: [PATCH 11/17] Now running unittests for custom vectors in CI --- CI/Windows.bat | 4 ++++ CI/ci-linux.sh | 4 ++++ CI/ci-mac.sh | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/CI/Windows.bat b/CI/Windows.bat index b5402dd2..22eca890 100644 --- a/CI/Windows.bat +++ b/CI/Windows.bat @@ -103,6 +103,8 @@ cd unittests unittests.exe --gtest_output=xml +unittests_customvec.exe --gtest_output=xml + cd .. cd .. @@ -129,6 +131,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..1fd5da31 100755 --- a/CI/ci-linux.sh +++ b/CI/ci-linux.sh @@ -96,6 +96,8 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +./unittests_customvec --gtest_color=yes --gtest_output=xml + cd .. cd .. @@ -134,5 +136,7 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +./unittests_customvec --gtest_color=yes --gtest_output=xml + cd .. cd .. diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index a804012d..3ceb48f3 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -78,6 +78,8 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +./unittests_customvec --gtest_color=yes --gtest_output=xml + cd .. cd .. @@ -116,6 +118,8 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +./unittests_customvec --gtest_color=yes --gtest_output=xml + cd .. cd .. From 2884ef83eb33c6acfb3809f3c8f0a1a94f2b5d3f Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Mon, 16 Apr 2018 13:32:14 +0200 Subject: [PATCH 12/17] Fixed wrong mesh type used in unittest --- src/Unittests/unittests_tutorials.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Unittests/unittests_tutorials.cc b/src/Unittests/unittests_tutorials.cc index 6ec4b36a..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(MyMeshWithStatus::Point(-1, -1, 1)); - vhandle[1] = mesh.add_vertex(MyMeshWithStatus::Point( 1, -1, 1)); - vhandle[2] = mesh.add_vertex(MyMeshWithStatus::Point( 1, 1, 1)); - vhandle[3] = mesh.add_vertex(MyMeshWithStatus::Point(-1, 1, 1)); - vhandle[4] = mesh.add_vertex(MyMeshWithStatus::Point(-1, -1, -1)); - vhandle[5] = mesh.add_vertex(MyMeshWithStatus::Point( 1, -1, -1)); - vhandle[6] = mesh.add_vertex(MyMeshWithStatus::Point( 1, 1, -1)); - vhandle[7] = mesh.add_vertex(MyMeshWithStatus::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]); From ad767006c5d714aa67cede3ecd10ba9b6f67de02 Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Mon, 16 Apr 2018 13:43:27 +0200 Subject: [PATCH 13/17] CI output now mentions when the minimal vector type is used. --- CI/ci-linux.sh | 14 ++++++++++++++ CI/ci-mac.sh | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/CI/ci-linux.sh b/CI/ci-linux.sh index 1fd5da31..b3d28017 100755 --- a/CI/ci-linux.sh +++ b/CI/ci-linux.sh @@ -96,6 +96,13 @@ 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 .. @@ -136,6 +143,13 @@ 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 .. diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index 3ceb48f3..5b7ecd94 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -78,6 +78,13 @@ 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 .. @@ -118,6 +125,13 @@ 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 .. From 77555753e34a049feb5446c966743de9dfef2abd Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Mon, 16 Apr 2018 16:18:59 +0200 Subject: [PATCH 14/17] Made customvec tests known to CMake --- src/Unittests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index 3843175f..037a207a 100644 --- a/src/Unittests/CMakeLists.txt +++ b/src/Unittests/CMakeLists.txt @@ -100,6 +100,7 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) 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.") From b72efdf8835cfe149d56d442ba54c48603d99aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 18 Apr 2018 10:49:28 +0200 Subject: [PATCH 15/17] Show directory content for unittests --- CI/Windows.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CI/Windows.bat b/CI/Windows.bat index 22eca890..826d83f0 100644 --- a/CI/Windows.bat +++ b/CI/Windows.bat @@ -129,6 +129,8 @@ IF "%SHARED%" == "TRUE" ( cd unittests +dir + unittests.exe --gtest_output=xml unittests_customvec.exe --gtest_output=xml From a01811fce9266bf3ad6a07fc4997ba4d63789733 Mon Sep 17 00:00:00 2001 From: schultz Date: Wed, 18 Apr 2018 12:24:21 +0200 Subject: [PATCH 16/17] fix RUNTIME_OUTPUT_DIRECTORY was not set properly in CMake for unittests_customvec --- src/Unittests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index 037a207a..ab128f5e 100644 --- a/src/Unittests/CMakeLists.txt +++ b/src/Unittests/CMakeLists.txt @@ -44,7 +44,7 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) 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 ${OUTPUT_DIR}) + set_target_properties(unittests_customvec PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${UPCONFIG} ${OUTPUT_DIR}) endforeach() From 2312a9e437d1c2fd2a529251162f25fbe3874d2a Mon Sep 17 00:00:00 2001 From: Christian Mattes Date: Wed, 18 Apr 2018 12:35:23 +0200 Subject: [PATCH 17/17] Removed ci-cppcheck.sh ci-doc.sh ci-linux.sh ci-mac.sh Windows.bat command used for debugging CI --- CI/Windows.bat | 2 -- 1 file changed, 2 deletions(-) diff --git a/CI/Windows.bat b/CI/Windows.bat index 826d83f0..22eca890 100644 --- a/CI/Windows.bat +++ b/CI/Windows.bat @@ -129,8 +129,6 @@ IF "%SHARED%" == "TRUE" ( cd unittests -dir - unittests.exe --gtest_output=xml unittests_customvec.exe --gtest_output=xml