Commit 054d1027 authored by Mike Kremer's avatar Mike Kremer

Added option to make property non-persistent. Added unit test on this.

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@110 66977474-1d4b-4f09-8fe9-267525286df2
parent a393ac8f
......@@ -148,19 +148,19 @@ public:
unsigned int n_mesh_props() const { return mesh_props_.size(); }
template<class T> void set_persistent(VertexPropertyT<T>& _prop);
template<class T> void set_persistent(VertexPropertyT<T>& _prop, bool _flag = true);
template<class T> void set_persistent(EdgePropertyT<T>& _prop);
template<class T> void set_persistent(EdgePropertyT<T>& _prop, bool _flag = true);
template<class T> void set_persistent(HalfEdgePropertyT<T>& _prop);
template<class T> void set_persistent(HalfEdgePropertyT<T>& _prop, bool _flag = true);
template<class T> void set_persistent(FacePropertyT<T>& _prop);
template<class T> void set_persistent(FacePropertyT<T>& _prop, bool _flag = true);
template<class T> void set_persistent(HalfFacePropertyT<T>& _prop);
template<class T> void set_persistent(HalfFacePropertyT<T>& _prop, bool _flag = true);
template<class T> void set_persistent(CellPropertyT<T>& _prop);
template<class T> void set_persistent(CellPropertyT<T>& _prop, bool _flag = true);
template<class T> void set_persistent(MeshPropertyT<T>& _prop);
template<class T> void set_persistent(MeshPropertyT<T>& _prop, bool _flag = true);
private:
......
......@@ -240,66 +240,157 @@ MeshPropertyT<T> ResourceManager::request_mesh_property(const std::string& _name
}
template<class T>
void ResourceManager::set_persistent(VertexPropertyT<T>& _prop) {
if(_prop.h_->persistent_) return;
_prop.h_->persistent_ = true;
VertexPropertyT<T>* prop = new VertexPropertyT<T>(_prop);
persistent_vprops_.push_back(prop);
void ResourceManager::set_persistent(VertexPropertyT<T>& _prop, bool _flag) {
if(_flag == _prop.h_->persistent_) return;
if(!_flag) {
for(std::vector<BaseProperty*>::iterator it = persistent_vprops_.begin();
it != persistent_vprops_.end(); ++it) {
if((*it)->name() == _prop.name()) {
_prop.h_->persistent_ = false;
delete (*it);
persistent_vprops_.erase(it);
break;
}
}
} else {
_prop.h_->persistent_ = true;
VertexPropertyT<T>* prop = new VertexPropertyT<T>(_prop);
persistent_vprops_.push_back(prop);
}
}
template<class T>
void ResourceManager::set_persistent(EdgePropertyT<T>& _prop) {
if(_prop.h_->persistent_) return;
_prop.h_->persistent_ = true;
EdgePropertyT<T>* prop = new EdgePropertyT<T>(_prop);
persistent_eprops_.push_back(prop);
void ResourceManager::set_persistent(EdgePropertyT<T>& _prop, bool _flag) {
if(_flag == _prop.h_->persistent_) return;
if(!_flag) {
for(std::vector<BaseProperty*>::iterator it = persistent_eprops_.begin();
it != persistent_eprops_.end(); ++it) {
if((*it)->name() == _prop.name()) {
_prop.h_->persistent_ = false;
delete (*it);
persistent_eprops_.erase(it);
break;
}
}
} else {
_prop.h_->persistent_ = true;
EdgePropertyT<T>* prop = new EdgePropertyT<T>(_prop);
persistent_eprops_.push_back(prop);
}
}
template<class T>
void ResourceManager::set_persistent(HalfEdgePropertyT<T>& _prop) {
if(_prop.h_->persistent_) return;
_prop.h_->persistent_ = true;
HalfEdgePropertyT<T>* prop = new HalfEdgePropertyT<T>(_prop);
persistent_heprops_.push_back(prop);
void ResourceManager::set_persistent(HalfEdgePropertyT<T>& _prop, bool _flag) {
if(_flag == _prop.h_->persistent_) return;
if(!_flag) {
for(std::vector<BaseProperty*>::iterator it = persistent_heprops_.begin();
it != persistent_heprops_.end(); ++it) {
if((*it)->name() == _prop.name()) {
_prop.h_->persistent_ = false;
delete (*it);
persistent_heprops_.erase(it);
break;
}
}
} else {
_prop.h_->persistent_ = true;
HalfEdgePropertyT<T>* prop = new HalfEdgePropertyT<T>(_prop);
persistent_heprops_.push_back(prop);
}
}
template<class T>
void ResourceManager::set_persistent(FacePropertyT<T>& _prop) {
if(_prop.h_->persistent_) return;
_prop.h_->persistent_ = true;
FacePropertyT<T>* prop = new FacePropertyT<T>(_prop);
persistent_fprops_.push_back(prop);
void ResourceManager::set_persistent(FacePropertyT<T>& _prop, bool _flag) {
if(_flag == _prop.h_->persistent_) return;
if(!_flag) {
for(std::vector<BaseProperty*>::iterator it = persistent_fprops_.begin();
it != persistent_fprops_.end(); ++it) {
if((*it)->name() == _prop.name()) {
_prop.h_->persistent_ = false;
delete (*it);
persistent_fprops_.erase(it);
break;
}
}
} else {
_prop.h_->persistent_ = true;
FacePropertyT<T>* prop = new FacePropertyT<T>(_prop);
persistent_fprops_.push_back(prop);
}
}
template<class T>
void ResourceManager::set_persistent(HalfFacePropertyT<T>& _prop) {
if(_prop.h_->persistent_) return;
_prop.h_->persistent_ = true;
HalfFacePropertyT<T>* prop = new HalfFacePropertyT<T>(_prop);
persistent_hfprops_.push_back(prop);
void ResourceManager::set_persistent(HalfFacePropertyT<T>& _prop, bool _flag) {
if(_flag == _prop.h_->persistent_) return;
if(!_flag) {
for(std::vector<BaseProperty*>::iterator it = persistent_hfprops_.begin();
it != persistent_hfprops_.end(); ++it) {
if((*it)->name() == _prop.name()) {
_prop.h_->persistent_ = false;
delete (*it);
persistent_hfprops_.erase(it);
break;
}
}
} else {
_prop.h_->persistent_ = true;
HalfFacePropertyT<T>* prop = new HalfFacePropertyT<T>(_prop);
persistent_hfprops_.push_back(prop);
}
}
template<class T>
void ResourceManager::set_persistent(CellPropertyT<T>& _prop) {
if(_prop.h_->persistent_) return;
_prop.h_->persistent_ = true;
CellPropertyT<T>* prop = new CellPropertyT<T>(_prop);
persistent_cprops_.push_back(prop);
void ResourceManager::set_persistent(CellPropertyT<T>& _prop, bool _flag) {
if(_flag == _prop.h_->persistent_) return;
if(!_flag) {
for(std::vector<BaseProperty*>::iterator it = persistent_cprops_.begin();
it != persistent_cprops_.end(); ++it) {
if((*it)->name() == _prop.name()) {
_prop.h_->persistent_ = false;
delete (*it);
persistent_cprops_.erase(it);
break;
}
}
} else {
_prop.h_->persistent_ = true;
CellPropertyT<T>* prop = new CellPropertyT<T>(_prop);
persistent_cprops_.push_back(prop);
}
}
template<class T>
void ResourceManager::set_persistent(MeshPropertyT<T>& _prop) {
if(_prop.h_->persistent_) return;
_prop.h_->persistent_ = true;
MeshPropertyT<T>* prop = new MeshPropertyT<T>(_prop);
persistent_mprops_.push_back(prop);
void ResourceManager::set_persistent(MeshPropertyT<T>& _prop, bool _flag) {
if(_flag == _prop.h_->persistent_) return;
if(!_flag) {
for(std::vector<BaseProperty*>::iterator it = persistent_mprops_.begin();
it != persistent_mprops_.end(); ++it) {
if((*it)->name() == _prop.name()) {
_prop.h_->persistent_ = false;
delete (*it);
persistent_mprops_.erase(it);
break;
}
}
} else {
_prop.h_->persistent_ = true;
MeshPropertyT<T>* prop = new MeshPropertyT<T>(_prop);
persistent_mprops_.push_back(prop);
}
}
} // Namespace OpenVolumeMesh
......@@ -85,6 +85,31 @@ TEST_F(HexahedralMeshBase, PropertySmartPointerPersistencyTest1) {
EXPECT_FLOAT_EQ(2.34f, v_prop2[11]);
}
TEST_F(HexahedralMeshBase, PropertySmartPointerPersistencyTest2) {
generateHexahedralMesh(mesh_);
for(int i = 0; i < 1; ++i) {
VertexPropertyT<float> v_prop = mesh_.request_vertex_property<float>("FloatVProp");
mesh_.set_persistent(v_prop);
}
EXPECT_EQ(1u, mesh_.n_vertex_props());
for(int i = 0; i < 1; ++i) {
VertexPropertyT<float> v_prop = mesh_.request_vertex_property<float>("FloatVProp");
EXPECT_EQ(1u, mesh_.n_vertex_props());
mesh_.set_persistent(v_prop, false);
}
EXPECT_EQ(0u, mesh_.n_vertex_props());
}
TEST_F(PolyhedralMeshBase, StatusTest) {
generatePolyhedralMesh(mesh_);
......
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