diff --git a/src/OpenMesh/Core/Mesh/AttribKernelT.hh b/src/OpenMesh/Core/Mesh/AttribKernelT.hh index ca1e55ef..c0d52a8f 100644 --- a/src/OpenMesh/Core/Mesh/AttribKernelT.hh +++ b/src/OpenMesh/Core/Mesh/AttribKernelT.hh @@ -744,48 +744,34 @@ private: { //mesh has no points? } - if(this->get_property_handle(vertex_normals_, - "v:normals")) - refcount_vnormals_ = 1; - if(this->get_property_handle(vertex_colors_, - "v:colors")) - refcount_vcolors_ = 1; - if(this->get_property_handle(vertex_texcoords1D_, - "v:texcoords1D")) - refcount_vtexcoords1D_ = 1; - if(this->get_property_handle(vertex_texcoords2D_, - "v:texcoords2D")) - refcount_vtexcoords2D_ = 1; - if(this->get_property_handle(vertex_texcoords3D_, - "v:texcoords3D")) - refcount_vtexcoords3D_ = 1; - if(this->get_property_handle(halfedge_texcoords1D_, - "h:texcoords1D")) - refcount_htexcoords1D_ = 1; - if(this->get_property_handle(halfedge_texcoords2D_, - "h:texcoords2D")) - refcount_htexcoords2D_ = 1; - if(this->get_property_handle(halfedge_texcoords3D_, - "h:texcoords3D")) - refcount_htexcoords3D_ = 1; - if(this->get_property_handle(halfedge_normals_, - "h:normals")) - refcount_henormals_ = 1; - if(this->get_property_handle(halfedge_colors_, - "h:colors")) - refcount_hecolors_ = 1; - if(this->get_property_handle(edge_colors_, - "e:colors")) - refcount_ecolors_ = 1; - if(this->get_property_handle(face_normals_, - "f:normals")) - refcount_fnormals_ = 1; - if(this->get_property_handle(face_colors_, - "f:colors")) - refcount_fcolors_ = 1; - if(this->get_property_handle(face_texture_index_, - "f:textureindex")) - refcount_ftextureIndex_ = 1; + refcount_vnormals_ = this->get_property_handle(vertex_normals_, + "v:normals") ? 1 : 0 ; + refcount_vcolors_ = this->get_property_handle(vertex_colors_, + "v:colors") ? 1 : 0 ; + refcount_vtexcoords1D_ = this->get_property_handle(vertex_texcoords1D_, + "v:texcoords1D") ? 1 : 0 ; + refcount_vtexcoords2D_ = this->get_property_handle(vertex_texcoords2D_, + "v:texcoords2D") ? 1 : 0 ; + refcount_vtexcoords3D_ = this->get_property_handle(vertex_texcoords3D_, + "v:texcoords3D") ? 1 : 0 ; + refcount_htexcoords1D_ = this->get_property_handle(halfedge_texcoords1D_, + "h:texcoords1D") ? 1 : 0 ; + refcount_htexcoords2D_ = this->get_property_handle(halfedge_texcoords2D_, + "h:texcoords2D") ? 1 : 0 ; + refcount_htexcoords3D_ = this->get_property_handle(halfedge_texcoords3D_, + "h:texcoords3D") ? 1 : 0 ; + refcount_henormals_ = this->get_property_handle(halfedge_normals_, + "h:normals") ? 1 : 0 ; + refcount_hecolors_ = this->get_property_handle(halfedge_colors_, + "h:colors") ? 1 : 0 ; + refcount_ecolors_ = this->get_property_handle(edge_colors_, + "e:colors") ? 1 : 0 ; + refcount_fnormals_ = this->get_property_handle(face_normals_, + "f:normals") ? 1 : 0 ; + refcount_fcolors_ = this->get_property_handle(face_colors_, + "f:colors") ? 1 : 0 ; + refcount_ftextureIndex_ = this->get_property_handle(face_texture_index_, + "f:textureindex") ? 1 : 0 ; } }; diff --git a/src/Unittests/unittests_property.cc b/src/Unittests/unittests_property.cc index 0a0a0a14..f9b0b45c 100644 --- a/src/Unittests/unittests_property.cc +++ b/src/Unittests/unittests_property.cc @@ -746,5 +746,111 @@ TEST_F(OpenMeshProperties, PropertyIterators ) { } +TEST_F(OpenMeshProperties, MeshAssignment ) { + + mesh_.clear(); + mesh_.add_vertex(Mesh::Point()); + + auto copy = mesh_; + + copy.request_vertex_status(); + copy.request_vertex_normals(); + copy.request_vertex_colors(); + copy.request_vertex_texcoords1D(); + copy.request_vertex_texcoords2D(); + copy.request_vertex_texcoords3D(); + copy.request_halfedge_status(); + copy.request_halfedge_texcoords1D(); + copy.request_halfedge_texcoords2D(); + copy.request_halfedge_texcoords3D(); + copy.request_edge_status(); + copy.request_edge_colors(); + copy.request_halfedge_normals(); + copy.request_halfedge_colors(); + copy.request_face_status(); + copy.request_face_normals(); + copy.request_face_colors(); + copy.request_face_texture_index(); + + EXPECT_TRUE(copy.has_vertex_status()); + EXPECT_TRUE(copy.has_vertex_normals()); + EXPECT_TRUE(copy.has_vertex_colors()); + EXPECT_TRUE(copy.has_vertex_texcoords1D()); + EXPECT_TRUE(copy.has_vertex_texcoords2D()); + EXPECT_TRUE(copy.has_vertex_texcoords3D()); + EXPECT_TRUE(copy.has_halfedge_status()); + EXPECT_TRUE(copy.has_halfedge_texcoords1D()); + EXPECT_TRUE(copy.has_halfedge_texcoords2D()); + EXPECT_TRUE(copy.has_halfedge_texcoords3D()); + EXPECT_TRUE(copy.has_edge_status()); + EXPECT_TRUE(copy.has_edge_colors()); + EXPECT_TRUE(copy.has_halfedge_normals()); + EXPECT_TRUE(copy.has_halfedge_colors()); + EXPECT_TRUE(copy.has_face_status()); + EXPECT_TRUE(copy.has_face_normals()); + EXPECT_TRUE(copy.has_face_colors()); + EXPECT_TRUE(copy.has_face_texture_index()); + + copy.assign(mesh_, true); + + EXPECT_FALSE(copy.has_vertex_status()); + EXPECT_FALSE(copy.has_vertex_normals()); + EXPECT_FALSE(copy.has_vertex_colors()); + EXPECT_FALSE(copy.has_vertex_texcoords1D()); + EXPECT_FALSE(copy.has_vertex_texcoords2D()); + EXPECT_FALSE(copy.has_vertex_texcoords3D()); + EXPECT_FALSE(copy.has_halfedge_status()); + EXPECT_FALSE(copy.has_halfedge_texcoords1D()); + EXPECT_FALSE(copy.has_halfedge_texcoords2D()); + EXPECT_FALSE(copy.has_halfedge_texcoords3D()); + EXPECT_FALSE(copy.has_edge_status()); + EXPECT_FALSE(copy.has_edge_colors()); + EXPECT_FALSE(copy.has_halfedge_normals()); + EXPECT_FALSE(copy.has_halfedge_colors()); + EXPECT_FALSE(copy.has_face_status()); + EXPECT_FALSE(copy.has_face_normals()); + EXPECT_FALSE(copy.has_face_colors()); + EXPECT_FALSE(copy.has_face_texture_index()); + + copy.request_vertex_status(); + copy.request_vertex_normals(); + copy.request_vertex_colors(); + copy.request_vertex_texcoords1D(); + copy.request_vertex_texcoords2D(); + copy.request_vertex_texcoords3D(); + copy.request_halfedge_status(); + copy.request_halfedge_texcoords1D(); + copy.request_halfedge_texcoords2D(); + copy.request_halfedge_texcoords3D(); + copy.request_edge_status(); + copy.request_edge_colors(); + copy.request_halfedge_normals(); + copy.request_halfedge_colors(); + copy.request_face_status(); + copy.request_face_normals(); + copy.request_face_colors(); + copy.request_face_texture_index(); + + EXPECT_TRUE(copy.has_vertex_status()) << "Mesh has no vertex status even though they have been requested"; + EXPECT_TRUE(copy.has_vertex_normals()) << "Mesh has no vertex normals even though they have been requested"; + EXPECT_TRUE(copy.has_vertex_colors()) << "Mesh has no vertex colors even though they have been requested"; + EXPECT_TRUE(copy.has_vertex_texcoords1D()) << "Mesh has no vertex texcoord1D even though they have been requested"; + EXPECT_TRUE(copy.has_vertex_texcoords2D()) << "Mesh has no vertex texcoord2D even though they have been requested"; + EXPECT_TRUE(copy.has_vertex_texcoords3D()) << "Mesh has no vertex texcoord3D even though they have been requested"; + EXPECT_TRUE(copy.has_halfedge_status()) << "Mesh has no halfedge status even though they have been requested"; + EXPECT_TRUE(copy.has_halfedge_texcoords1D()) << "Mesh has no halfedge texcoords1D even though they have been requested"; + EXPECT_TRUE(copy.has_halfedge_texcoords2D()) << "Mesh has no halfedge texcoords2D even though they have been requested"; + EXPECT_TRUE(copy.has_halfedge_texcoords3D()) << "Mesh has no halfedge texcoords3D even though they have been requested"; + EXPECT_TRUE(copy.has_edge_status()) << "Mesh has no edge status even though they have been requested"; + EXPECT_TRUE(copy.has_edge_colors()) << "Mesh has no edge colors even though they have been requested"; + EXPECT_TRUE(copy.has_halfedge_normals()) << "Mesh has no halfedge normals even though they have been requested"; + EXPECT_TRUE(copy.has_halfedge_colors()) << "Mesh has no halfedge colors even though they have been requested"; + EXPECT_TRUE(copy.has_face_status()) << "Mesh has no face status even though they have been requested"; + EXPECT_TRUE(copy.has_face_normals()) << "Mesh has no face normals even though they have been requested"; + EXPECT_TRUE(copy.has_face_colors()) << "Mesh has no face colors even though they have been requested"; + EXPECT_TRUE(copy.has_face_texture_index()) << "Mesh has no face texture index even though they have been requested"; + +} + }