int vtkId = cell->getVtkId();
if (vtkId == -1)
vtkId = myElementIDFactory->SetInVtkGrid(element);
-
-// if (ID >= myCellIdSmdsToVtk.size()) // --- resize local vector
-// {
-// MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << ID << " --> " << ID + SMDS_Mesh::chunkSize);
-// myCellIdSmdsToVtk.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1
-// }
-//
-// myCellIdSmdsToVtk[ID] = vtkId;
-// //MESSAGE("smds:" << ID << " vtk:" << vtkId );
if (vtkId >= myCellIdVtkToSmds.size()) // --- resize local vector
{
{
int elemId = elem->GetID();
int vtkId = elem->getVtkId();
- //MESSAGE("SMDS_Mesh::RemoveFreeElement " << elemId);
+ //MESSAGE("RemoveFreeElement " << elemId);
SMDSAbs_ElementType aType = elem->GetType();
SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem);
if (aType == SMDSAbs_Node) {
}
// Regular elements
+ // TODO not all the possible cases are solved. Find something more generic?
switch ( nbNodes ) {
case 2: ///////////////////////////////////// EDGE
isOk = false; break;
//MESSAGE("Change regular element or polygon " << elemId);
SMDSAbs_ElementType etyp = elem->GetType();
uniqueNodes.resize(nbUniqueNodes);
- aMesh->RemoveElement(elem);
- SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false, elemId);
+ SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false);
if (newElem)
{
myLastCreatedElems.Append(newElem);
if ( aShapeId )
aMesh->SetMeshElementOnShape( newElem, aShapeId );
}
+ aMesh->RemoveElement(elem);
}
}
else {
} // loop on elements
- // Remove equal nodes and bad elements
+ // Remove bad elements, then equal nodes (order important)
- Remove( rmNodeIds, true );
Remove( rmElemIds, false );
+ Remove( rmNodeIds, true );
}
const SMDS_PositionPtr Pos1 = n1->GetPosition();
const SMDS_PositionPtr Pos2 = n2->GetPosition();
- bool onGeom = true;
- if ((Pos1->GetTypeOfPosition() != SMDS_TOP_FACE) &&
- (Pos1->GetTypeOfPosition() != SMDS_TOP_EDGE))
- onGeom = false;
- if ((Pos2->GetTypeOfPosition() != SMDS_TOP_FACE) &&
- (Pos2->GetTypeOfPosition() != SMDS_TOP_EDGE))
- onGeom = false;
-
TopoDS_Edge E; double u [2];
TopoDS_Face F; gp_XY uv[2];
bool uvOK[2] = { false, false };
- if (onGeom) {
if( myShape.IsNull() )
{
if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE ) {
}
}
}
- } // onGeom
// 3d variant
double x = ( n1->X() + n2->X() )/2.;
double z = ( n1->Z() + n2->Z() )/2.;
n12 = meshDS->AddNode(x,y,z);
- if (onGeom) {
if ( !F.IsNull() )
{
gp_XY UV = ( uv[0] + uv[1] ) / 2.;
{
meshDS->SetNodeInVolume(n12, myShapeID);
}
- } // onGeom
myTLinkNodeMap.insert( make_pair( link, n12 ));
return n12;
{
if (!IsComplexSubmesh())
{
+ //MESSAGE("in " << myIndex << " AddElement "<< ME->GetID());
int idInSubShape = ME->getIdInShape();
if (idInSubShape != -1)
{
//=======================================================================
bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted)
{
- // MESSAGE("--------------------------------------> RemoveElement " << isElemDeleted);
+ if (!ME)
+ {
+ MESSAGE("-----------------> Remove Null Element " << isElemDeleted);
+ return false;
+ }
+ //MESSAGE("-----------------> RemoveElement "<< ME->GetID() << " " << isElemDeleted);
if (!IsComplexSubmesh())
{
- if (!isElemDeleted) // alive element has valid ID and can be found
+ // if (!isElemDeleted) // alive element has valid ID and can be found
+ // {
+ int idInSubShape = ME->getIdInShape();
+ //MESSAGE("in "<< myIndex << " RemoveElement " << ME->GetID() << " " << idInSubShape << " " << myUnusedIdElements);
+ SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
+ elem->setShapeId(0);
+ elem->setIdInShape(-1);
+ if ((idInSubShape >= 0) && (idInSubShape < myElements.size()))
{
- int idInSubShape = ME->getIdInShape();
- //MESSAGE("SMESHDS_SubMesh::RemoveElement " << idInSubShape << " " << ME->GetID() << " " << myUnusedIdElements);
- assert(idInSubShape >= 0);
- assert(idInSubShape < myElements.size());
- SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
- elem->setShapeId(0);
- elem->setIdInShape(-1);
myElements[idInSubShape] = 0; // this vector entry is no more used
myUnusedIdElements++;
return true;
}
- //MESSAGE("Try to remove an already deleted element from a submesh ");
return false;
+ // }
}
MESSAGE("Try to remove an element from a complex submesh ");
return false;
node->setShapeId(myIndex);
node->setIdInShape(myNodes.size());
myNodes.push_back(N);
+ //MESSAGE("in "<< myIndex << " AddNode " << node->GetID());
}
//MESSAGE("try to add node in a complex submesh " << N->GetID());
}
{
if (!IsComplexSubmesh())
{
- if (!isNodeDeleted) // alive node has valid ID and can be found
+ // if (!isNodeDeleted) // alive node has valid ID and can be found
+ // {
+ int idInSubShape = N->getIdInShape();
+ int shapeId = N->getshapeId();
+ //MESSAGE("in "<< myIndex << " RemoveNode " << shapeId << " " << idInSubShape << " " << N->GetID());
+ SMDS_MeshNode* node = (SMDS_MeshNode*) (N);
+ node->setShapeId(0);
+ node->setIdInShape(-1);
+ if ((idInSubShape >= 0) && (idInSubShape < myNodes.size()))
{
- int idInSubShape = N->getIdInShape();
- int shapeId = N->getshapeId();
- MESSAGE("SMESHDS_SubMesh::RemoveNode " << shapeId << " " << idInSubShape << " " << N->GetID());
- //assert(idInSubShape >= 0);
- //assert(idInSubShape < myNodes.size());
- SMDS_MeshNode* node = (SMDS_MeshNode*) (N);
- node->setShapeId(0);
- node->setIdInShape(-1);
myNodes[idInSubShape] = 0; // this vector entry is no more used
myUnusedIdNodes++;
return true;
}
- //MESSAGE("Try to remove an already deleted node from a submesh");
return false;
+ // }
}
MESSAGE("Try to remove a node from a complex submesh");
return false;
void SMESHDS_SubMesh::compactList()
{
- MESSAGE("compactList old: nodes " << myNodes.size() << " elements " << myElements.size());
+ //MESSAGE("compactList old: nodes " << myNodes.size() << " elements " << myElements.size());
+ //stringstream a;
+ //stringstream b;
+ //stringstream c;
+ //stringstream d;
+
std::vector<const SMDS_MeshElement*> newElems;
newElems.clear();
for (int i = 0; i < myElements.size(); i++)
SMDS_MeshElement* elem = (SMDS_MeshElement*)myElements[i];
elem->setIdInShape(newElems.size());
newElems.push_back(elem);
+ //a << elem->GetID() << " ";
+ //b << elem->GetID() << " ";
}
+ //else
+ // a << "_ ";
myElements.swap(newElems);
myUnusedIdElements = 0;
+ //MESSAGE("in " << myIndex << " oldElems " << a.str());
+ //MESSAGE("in " << myIndex << " newElems " << b.str());
std::vector<const SMDS_MeshNode*> newNodes;
newNodes.clear();
SMDS_MeshNode* node = (SMDS_MeshNode*)myNodes[i];
node->setIdInShape(newNodes.size());
newNodes.push_back(node);
+ //c << node->GetID() << " ";
+ //d << node->GetID() << " ";
}
+ //else
+ // c << "_ ";
myNodes.swap(newNodes);
myUnusedIdNodes = 0;
+ //MESSAGE("in " << myIndex << " oldNodes " << c.str());
+ //MESSAGE("in " << myIndex << " newNodes " << d.str());
//MESSAGE("compactList new: nodes " << myNodes.size() << " elements " << myElements.size());
}