-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESHDS : management of mesh data and SMESH document
using namespace std;
+
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+
SMESHDS_SubMesh::SMESHDS_SubMesh(SMESHDS_Mesh *parent, int index)
{
myParent = parent;
myUnusedIdElements = 0;
}
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+
+SMESHDS_SubMesh::~SMESHDS_SubMesh()
+{
+}
+
//=======================================================================
//function : AddElement
//purpose :
{
if (!IsComplexSubmesh())
{
+ if ( ME->GetType() == SMDSAbs_Node )
+ {
+ AddNode( static_cast< const SMDS_MeshNode* >( ME ));
+ return;
+ }
//MESSAGE("in " << myIndex << " AddElement "<< ME->GetID());
- int idInSubShape = ME->getIdInShape();
- if (idInSubShape != -1)
+ int oldShapeId = ME->getshapeId();
+ if ( oldShapeId > 0 )
{
- MESSAGE("add element in subshape already belonging to a subshape "
- << ME->GetID() << " " << ME->getIdInShape() << " " << ME->getshapeId());
- throw SALOME_Exception(LOCALIZED("add element in subshape already belonging to a subshape"));
+ if (oldShapeId != myIndex)
+ {
+ MESSAGE("add element in subshape already belonging to another subshape "
+ << ME->GetID() << " " << oldShapeId << " " << myIndex);
+ throw SALOME_Exception(LOCALIZED("add element in subshape already belonging to a subshape"));
+ }
+ else
+ {
+ int idInSubShape = ME->getIdInShape();
+ if (idInSubShape >= 0)
+ {
+ MESSAGE("add element in subshape already belonging to that subshape "
+ << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
+ // check if ok: do nothing if ok
+ if (idInSubShape >= myElements.size())
+ {
+ MESSAGE("out of bounds " << idInSubShape << " " << myElements.size());
+ throw SALOME_Exception(LOCALIZED("out of bounds"));
+ }
+ if (ME != myElements[idInSubShape])
+ {
+ MESSAGE("not the same element");
+ throw SALOME_Exception(LOCALIZED("not the same element"));
+ }
+ MESSAGE("already done, OK, nothing to do");
+ return;
+ }
+ }
}
+
SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
elem->setShapeId(myIndex);
elem->setIdInShape(myElements.size());
//MESSAGE("-----------------> RemoveElement "<< ME->GetID() << " " << isElemDeleted);
if (!IsComplexSubmesh())
{
- // if (!isElemDeleted) // alive element has valid ID and can be found
- // {
+ if ( ME->getshapeId() != myIndex )
+ return false;
int idInSubShape = ME->getIdInShape();
//MESSAGE("in "<< myIndex << " RemoveElement " << ME->GetID() << " " << idInSubShape << " " << myUnusedIdElements);
SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
int shapeId = N->getshapeId();
if ((shapeId > 0) && (idInSubShape >= 0))
{
- MESSAGE("========== AddNode already belonging to other subShape " << N->GetID());
+// MESSAGE("========== AddNode already belonging to other subShape " << N->GetID());
// OK for vertex nodes
- //this->getParent()->UnSetNodeOnShape(N);
+ throw SALOME_Exception(LOCALIZED("add node in subshape already belonging to a subshape"));
}
SMDS_MeshNode* node = (SMDS_MeshNode*)(N);
node->setShapeId(myIndex);
{
// if (!isNodeDeleted) // alive node has valid ID and can be found
// {
+ if ( N->getshapeId() != myIndex )
+ return false;
int idInSubShape = N->getIdInShape();
//int shapeId = N->getshapeId();
//MESSAGE("in "<< myIndex << " RemoveNode " << shapeId << " " << idInSubShape << " " << N->GetID());
return mySubMeshes.erase( theSubMesh );
}
+//=======================================================================
+//function : RemoveAllSubmeshes
+//purpose :
+//=======================================================================
+
+void SMESHDS_SubMesh::RemoveAllSubmeshes()
+{
+ mySubMeshes.clear();
+}
+
//=======================================================================
//function : ContainsSubMesh
//purpose :