Commit 621b3549 authored by Yumin Yuan's avatar Yumin Yuan
Browse files

Use set instead of vector as MeshSet container for op

parent 58c83196
......@@ -107,20 +107,28 @@ bool MeshItem::setValue(const smtk::mesh::MeshSet& val)
}
this->m_meshValues.clear();
this->m_meshValues.push_back(val);
this->m_meshValues.insert(val);
return true;
}
//----------------------------------------------------------------------------
bool MeshItem::appendValue(const smtk::mesh::MeshSet& val)
{
smtk::mesh::MeshList meshes;
meshes.push_back(val);
smtk::mesh::MeshSets meshes;
meshes.insert(val);
return this->appendValues(meshes);
}
//----------------------------------------------------------------------------
bool MeshItem::appendValues(const smtk::mesh::MeshList& vals)
{
smtk::mesh::MeshSets meshes;
meshes.insert(vals.begin(), vals.end());
return this->appendValues(meshes);
}
//----------------------------------------------------------------------------
bool MeshItem::appendValues(const smtk::mesh::MeshSets& vals)
{
const MeshItemDefinition* def =
static_cast<const MeshItemDefinition *>(this->definition().get());
......@@ -131,8 +139,7 @@ bool MeshItem::appendValues(const smtk::mesh::MeshList& vals)
return false;
}
std::copy(vals.begin(),vals.end(),
std::back_inserter(this->m_meshValues));
this->m_meshValues.insert(vals.begin(), vals.end());
return true;
}
......@@ -144,24 +151,21 @@ void MeshItem::removeValue(const smtk::mesh::MeshSet& val)
static_cast<const MeshItemDefinition *>(this->definition().get());
if(!def->isExtensible())
return;
smtk::attribute::MeshItem::mesh_it it = std::find(m_meshValues.begin(),
m_meshValues.end(), val);
if(it != this->m_meshValues.end())
if(this->m_meshValues.find(val) != this->m_meshValues.end())
{
this->m_meshValues.erase(it);
this->m_meshValues.erase(val);
}
}
//----------------------------------------------------------------------------
bool MeshItem::hasValue(const smtk::mesh::MeshSet& val) const
{
smtk::mesh::MeshList::const_iterator it = std::find(m_meshValues.begin(),
m_meshValues.end(), val);
return it != this->m_meshValues.end();
return this->m_meshValues.find(val) != this->m_meshValues.end();
}
//----------------------------------------------------------------------------
const smtk::mesh::MeshList& MeshItem::values() const
const smtk::mesh::MeshSets& MeshItem::values() const
{
return this->m_meshValues;
}
......@@ -187,9 +191,7 @@ bool MeshItem::assign(ConstItemPtr &sourceItem, unsigned int options)
// Update values
this->reset();
this->m_meshValues.clear();
std::copy(sourceMeshItem->begin(),sourceMeshItem->end(),
std::back_inserter(this->m_meshValues));
this->m_meshValues.insert(sourceMeshItem->begin(),sourceMeshItem->end());
return Item::assign(sourceItem, options);
}
......
......@@ -28,8 +28,8 @@ namespace smtk {
class SMTKCORE_EXPORT MeshItem : public Item
{
public:
typedef smtk::mesh::MeshList::const_iterator const_mesh_it;
typedef smtk::mesh::MeshList::iterator mesh_it;
typedef smtk::mesh::MeshSets::const_iterator const_mesh_it;
typedef smtk::mesh::MeshSets::iterator mesh_it;
smtkTypeMacro(MeshItem);
virtual ~MeshItem();
......@@ -41,11 +41,12 @@ public:
bool setValue(const smtk::mesh::MeshSet& meshset);
bool appendValue(const smtk::mesh::MeshSet&);
bool appendValues(const smtk::mesh::MeshList&);
bool appendValues(const smtk::mesh::MeshSets&);
void removeValue(const smtk::mesh::MeshSet&);
bool hasValue(const smtk::mesh::MeshSet&) const;
std::size_t numberOfValues() const;
const smtk::mesh::MeshList& values() const;
const smtk::mesh::MeshSets& values() const;
virtual void reset();
// Assigns this item to be equivalent to another. Options are processed by derived item classes
// Returns true if success and false if a problem occured.
......@@ -60,7 +61,7 @@ protected:
MeshItem(Attribute *owningAttribute, int itemPosition);
MeshItem(Item *owningItem, int position, int subGroupPosition);
virtual bool setDefinition(smtk::attribute::ConstItemDefinitionPtr vdef);
smtk::mesh::MeshList m_meshValues;
smtk::mesh::MeshSets m_meshValues;
};
......
......@@ -158,7 +158,7 @@ smtk::model::OperatorResult SetProperty::operateInternal()
// check whether there are mesh entities's properties need to be changed
smtk::attribute::MeshItemPtr meshItem = this->findMesh("meshes");
smtk::mesh::MeshList modifiedMeshes;
smtk::mesh::MeshSets modifiedMeshes;
if(meshItem)
{
smtk::model::ManagerPtr modelmgr = this->manager();
......@@ -175,7 +175,7 @@ smtk::model::OperatorResult SetProperty::operateInternal()
nameItem->value(0), floatItem, c, *it);
SetMeshPropertyValue<Integer,IntegerList,IntegerData,IntItem>(
nameItem->value(0), integerItem, c, *it);
modifiedMeshes.push_back(*it);
modifiedMeshes.insert(*it);
}
}
......
......@@ -102,7 +102,7 @@ smtk::model::OperatorResult SetProperty::operateInternal()
// check whether there are mesh entities's properties need to be changed
smtk::attribute::MeshItemPtr meshItem = this->findMesh("meshes");
smtk::mesh::MeshList modifiedMeshes;
smtk::mesh::MeshSets modifiedMeshes;
if(meshItem)
{
smtk::attribute::MeshItem::const_mesh_it it;
......@@ -117,7 +117,7 @@ smtk::model::OperatorResult SetProperty::operateInternal()
nameItem->value(0), floatItem, c, *it);
SetMeshPropertyValue<Integer,IntegerList,IntegerData,IntItem>(
nameItem->value(0), integerItem, c, *it);
modifiedMeshes.push_back(*it);
modifiedMeshes.insert(*it);
}
}
......
Supports Markdown
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