Commit fb91dead authored by Max Lyon's avatar Max Lyon
Browse files

move propertymanager initial_value back to front to fix bool properties

parent 9b14efaa
......@@ -140,7 +140,7 @@ class PropertyManager {
* @see PropertyManager::getOrMakeProperty, PropertyManager::getProperty,
* PropertyManager::makeTemporaryProperty
*/
OM_DEPRECATED("Use the constructor without parameter 'existing' instead. Check for existance with hasProperty")
OM_DEPRECATED("Use the constructor without parameter 'existing' instead. Check for existance with hasProperty") // As long as this overload exists, initial value must be first parameter due to ambiguity for properties of type bool
PropertyManager(PolyConnectivity& mesh, const char *propname, bool existing) : mesh_(mesh), retain_(existing), name_(propname) {
if (existing) {
if (!mesh_.get_property_handle(prop_, propname)) {
......@@ -171,13 +171,13 @@ class PropertyManager {
* Constructor.
*
* Asks for a property with name propname and creates one if none exists. Lifetime is not managed.
* If the property is created it is initialized with \p initial_value
*
* @param initial_value If the proeprty is newly created, it will be initialized with intial_value.
* If the property already existed, nothing is changes.
* @param mesh The mesh on which to create the property.
* @param initial_value
* @param propname The name of the property.
*/
PropertyManager(PolyConnectivity& mesh, const char *propname, const Value& intial_value) : mesh_(mesh), retain_(true), name_(propname) {
PropertyManager(const Value& intial_value, PolyConnectivity& mesh, const char *propname) : mesh_(mesh), retain_(true), name_(propname) {
if (!mesh_.get_property_handle(prop_, propname)) {
mesh_.add_property(prop_, propname);
set_range(mesh_.all_elements<Handle>(), intial_value);
......@@ -199,11 +199,11 @@ class PropertyManager {
* Constructor.
*
* Create an anonymous property. Lifetime is managed.
* If the property is created it is initialized with \p initial_value
*
* @param initial_value The property will be initialized with intial_value.
* @param mesh The mesh on which to create the property.
*/
PropertyManager(PolyConnectivity& mesh, const Value& intial_value) : mesh_(mesh), retain_(false), name_("") {
PropertyManager(const Value& intial_value, PolyConnectivity& mesh) : mesh_(mesh), retain_(false), name_("") {
mesh_.add_property(prop_, name_);
set_range(mesh_.all_elements<Handle>(), intial_value);
}
......
......@@ -266,8 +266,8 @@ TEST_F(OpenMeshPropertyManager, property_copying_same_mesh) {
// unnamed to unnamed
{
auto prop1 = OpenMesh::VProp<int>(mesh_, 3);
auto prop2 = OpenMesh::VProp<int>(mesh_, 0);
auto prop1 = OpenMesh::VProp<int>(3, mesh_);
auto prop2 = OpenMesh::VProp<int>(0, mesh_);
EXPECT_EQ(prop1[OpenMesh::VertexHandle(0)], 3) << "Property not initialized correctly";
EXPECT_EQ(prop2[OpenMesh::VertexHandle(0)], 0) << "Property not initialized correctly";
......@@ -292,7 +292,7 @@ TEST_F(OpenMeshPropertyManager, property_copying_same_mesh) {
// unnamed to named
{
auto prop1 = OpenMesh::VProp<int>(mesh_);
auto prop2 = OpenMesh::VProp<int>(mesh_, "ids", 0);
auto prop2 = OpenMesh::VProp<int>(0, mesh_, "ids");
EXPECT_EQ(prop2[OpenMesh::VertexHandle(0)], 0) << "Property not initialized correctly";
for (auto vh : mesh_.vertices())
......@@ -385,6 +385,16 @@ TEST_F(OpenMeshPropertyManager, property_copying_same_mesh) {
auto prop3 = OpenMesh::VProp<int>(mesh_, "ids5");
EXPECT_EQ(prop3[OpenMesh::VertexHandle(0)], 42) << "Property not copied correctly";
}
{
auto prop1 = OpenMesh::MProp<int>(mesh_);
*prop1 = 43;
auto prop2 = prop1;
prop2 = prop1;
prop2 = std::move(prop1);
}
}
......@@ -530,8 +540,8 @@ TEST_F(OpenMeshPropertyManager, property_copying_different_mesh) {
// unnamed to unnamed
{
auto prop1 = OpenMesh::VProp<int>(mesh_, 3);
auto prop2 = OpenMesh::VProp<int>(copy, 0);
auto prop1 = OpenMesh::VProp<int>(3, mesh_);
auto prop2 = OpenMesh::VProp<int>(0, copy);
EXPECT_EQ(prop1[OpenMesh::VertexHandle(0)], 3) << "Property not initialized correctly";
EXPECT_EQ(prop2[OpenMesh::VertexHandle(0)], 0) << "Property not initialized correctly";
......@@ -557,7 +567,7 @@ TEST_F(OpenMeshPropertyManager, property_copying_different_mesh) {
// unnamed to named
{
auto prop1 = OpenMesh::VProp<int>(mesh_);
auto prop2 = OpenMesh::VProp<int>(copy, "ids", 0);
auto prop2 = OpenMesh::VProp<int>(0, copy, "ids");
EXPECT_EQ(prop2[OpenMesh::VertexHandle(0)], 0) << "Property not initialized correctly";
for (auto vh : mesh_.vertices())
......@@ -762,6 +772,9 @@ TEST_F(OpenMeshPropertyManager, property_moving_different_mesh) {
auto prop1 = OpenMesh::VProp<int>(mesh_, "ids5");
auto prop2 = OpenMesh::VProp<int>(copy, "ids5");
auto prop6 = OpenMesh::Prop<OpenMesh::VertexHandle, int>(mesh_);
prop6 = prop1;
for (auto vh : mesh_.vertices())
prop1[vh] = vh.idx()*2-13;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment