const SMDS_MeshNode * nodes[],
const int nbnodes)
{
- MESSAGE("SMESHDS_Mesh::ChangeElementNodes");
+ //MESSAGE("SMESHDS_Mesh::ChangeElementNodes");
if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
return false;
// Rm from sub-meshes
// Element should belong to only one sub-mesh
- map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
- for ( ; SubIt != theSubMeshes.end(); SubIt++ )
+ if ( !theSubMeshes.empty() )
{
- int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
- if ( size == 0 ) continue;
-
+ SMESHDS_Mesh* mesh = theSubMeshes.begin()->second->getParent();
list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
- while ( elIt != theElems.end() )
- {
- bool removed = false;
- if ( isNode )
- removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
- else
- removed = (*SubIt).second->RemoveElement( *elIt, deleted );
-
- if (removed)
- {
- elIt = theElems.erase( elIt );
- if ( theElems.empty() )
- return; // all elements are found and removed
- }
- else
- {
- elIt++ ;
- }
+ if ( isNode ) {
+ for ( ; elIt != theElems.end(); ++elIt )
+ if ( SMESHDS_SubMesh* sm = mesh->MeshElements( (*elIt)->getshapeId() ))
+ sm->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
+ }
+ else {
+ for ( ; elIt != theElems.end(); ++elIt )
+ if ( SMESHDS_SubMesh* sm = mesh->MeshElements( (*elIt)->getshapeId() ))
+ sm->RemoveElement( *elIt, deleted );
}
}
}
-
+
//=======================================================================
//function : RemoveNode
//purpose :
///////////////////////////////////////////////////////////////////////////////
/// Return the sub mesh by Id of shape it is linked to
///////////////////////////////////////////////////////////////////////////////
-SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
+SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index) const
{
TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
if (anIter != myShapeIndexToSubMesh.end())
//function : SubMeshIndices
//purpose :
//=======================================================================
-list<int> SMESHDS_Mesh::SubMeshIndices()
+list<int> SMESHDS_Mesh::SubMeshIndices() const
{
list<int> anIndices;
- std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
+ std::map<int,SMESHDS_SubMesh*>::const_iterator anIter = myShapeIndexToSubMesh.begin();
for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
anIndices.push_back((*anIter).first);
}
//function : HasMeshElements
//purpose :
//=======================================================================
-bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
+bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S) const
{
if (myShape.IsNull()) MESSAGE("myShape is NULL");
int Index = myIndexToShape.FindIndex(S);
myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds);
return true;
}
-
-/*! Create a volume (prism or hexahedron) by duplication of a face.
- * the nodes of the new face are already created.
- * @param vtkVolId vtk id of a volume containing the face, to get an orientation for the face.
- * @param localClonedNodeIds map old node id to new node id. The old nodes define the face in the volume.
- * @return ok if success.
- */
-bool SMESHDS_Mesh::extrudeVolumeFromFace(int vtkVolId, std::map<int,int>& localClonedNodeIds)
-{
- //MESSAGE("extrudeVolumeFromFace " << vtkVolId);
- vector<int> orderedNodes;
- orderedNodes.clear();
- map<int, int>::const_iterator it = localClonedNodeIds.begin();
- for (; it != localClonedNodeIds.end(); ++it)
- orderedNodes.push_back(it->first);
-
- int nbNodes = myGrid->getOrderedNodesOfFace(vtkVolId, orderedNodes);
- for (int i=0; i<nbNodes; i++)
- orderedNodes.push_back(localClonedNodeIds[orderedNodes[i]]);
- SMDS_MeshVolume *vol = this->AddVolumeFromVtkIds(orderedNodes);
-
- // TODO update subshape list of elements and nodes
- return vol;
-}