delete node positions at node removal

This commit is contained in:
eap 2011-01-18 10:47:49 +00:00
parent 0c1947cfe5
commit 6e58f2fb40
2 changed files with 43 additions and 37 deletions

View File

@ -223,10 +223,6 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID)
SMDS_MeshNode * node = myNodePool->getNew();
node->init(ID, myMeshId, 0, x, y, z);
//rnv: Set SMDS_SpacePosition for node if need
if( node->GetPosition()->GetTypeOfPosition() != SMDS_TOP_3DSPACE)
node->SetPosition(SMDS_SpacePosition::originSpacePosition());
if (ID >= myNodes.size())
{
myNodes.resize(ID+SMDS_Mesh::chunkSize, 0);
@ -2395,6 +2391,7 @@ SMDS_Mesh::~SMDS_Mesh()
while (itn->more())
{
const SMDS_MeshNode *node = itn->next();
((SMDS_MeshNode*)node)->SetPosition(SMDS_SpacePosition::originSpacePosition());
myNodeIDFactory->ReleaseID(node->GetID(), node->getVtkId());
}
}
@ -2493,6 +2490,7 @@ void SMDS_Mesh::Clear()
while (itn->more())
{
SMDS_MeshNode *node = (SMDS_MeshNode*)(itn->next());
node->SetPosition(SMDS_SpacePosition::originSpacePosition());
myNodePool->destroy(node);
}
myNodes.clear();
@ -3129,7 +3127,10 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
myNodeIDFactory->ReleaseID((*it)->GetID(), (*it)->getVtkId());
removedNodes.push_back((*it));
if (const SMDS_MeshNode* vtkElem = dynamic_cast<const SMDS_MeshNode*>(*it))
{
((SMDS_MeshNode*)vtkElem)->SetPosition(SMDS_SpacePosition::originSpacePosition());
myNodePool->destroy((SMDS_MeshNode*) vtkElem);
}
else
delete (*it);
it++;
@ -3159,6 +3160,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem)
if (!itFe->more()) { // free node
myNodes[elemId] = 0;
myInfo.myNbNodes--;
((SMDS_MeshNode*) n)->SetPosition(SMDS_SpacePosition::originSpacePosition());
myNodePool->destroy(static_cast<SMDS_MeshNode*>(todest));
myNodeIDFactory->ReleaseID(elemId, vtkId);
}

View File

@ -78,6 +78,8 @@ void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, do
SMDS_MeshNode::~SMDS_MeshNode()
{
nbNodes--;
if ( myPosition && myPosition != SMDS_SpacePosition::originSpacePosition() )
delete myPosition, myPosition = 0;
}
//=======================================================================
@ -111,6 +113,8 @@ void SMDS_MeshNode::Print(ostream & OS) const
void SMDS_MeshNode::SetPosition(const SMDS_PositionPtr& aPos)
{
if ( myPosition && myPosition != aPos )
delete myPosition;
myPosition = aPos;
}