- set<const SMDS_MeshElement*>::iterator eIt = elems.begin();
- for ( ; eIt != elems.end(); eIt++ ) {
- const SMDS_MeshElement* elem = *eIt;
- //MESSAGE(" ---- inverse elem on node to remove " << elem->GetID());
- int nbNodes = elem->NbNodes();
- int aShapeId = FindShape( elem );
-
- set<const SMDS_MeshNode*> nodeSet;
- vector< const SMDS_MeshNode*> curNodes( nbNodes ), uniqueNodes( nbNodes );
- int iUnique = 0, iCur = 0, nbRepl = 0;
- vector<int> iRepl( nbNodes );
-
- // get new seq of nodes
- SMDS_ElemIteratorPtr itN = elem->nodesIterator();
- while ( itN->more() ) {
- const SMDS_MeshNode* n =
- static_cast<const SMDS_MeshNode*>( itN->next() );
-
- TNodeNodeMap::iterator nnIt = nodeNodeMap.find( n );
- if ( nnIt != nodeNodeMap.end() ) { // n sticks
- n = (*nnIt).second;
- // BUG 0020185: begin
- {
- bool stopRecur = false;
- set<const SMDS_MeshNode*> nodesRecur;
- nodesRecur.insert(n);
- while (!stopRecur) {
- TNodeNodeMap::iterator nnIt_i = nodeNodeMap.find( n );
- if ( nnIt_i != nodeNodeMap.end() ) { // n sticks
- n = (*nnIt_i).second;
- if (!nodesRecur.insert(n).second) {
- // error: recursive dependancy
- stopRecur = true;
- }
- }
- else
- stopRecur = true;
- }
- }
- // BUG 0020185: end
- }
- curNodes[ iCur ] = n;
- bool isUnique = nodeSet.insert( n ).second;
- if ( isUnique )
- uniqueNodes[ iUnique++ ] = n;
- else
- iRepl[ nbRepl++ ] = iCur;
- iCur++;
- }
-
- // Analyse element topology after replacement
-
- bool isOk = true;
- int nbUniqueNodes = nodeSet.size();
- //MESSAGE("nbNodes nbUniqueNodes " << nbNodes << " " << nbUniqueNodes);
- if ( nbNodes != nbUniqueNodes ) { // some nodes stick
- // Polygons and Polyhedral volumes
- if (elem->IsPoly()) {
-
- if (elem->GetType() == SMDSAbs_Face) {
- // Polygon
- vector<const SMDS_MeshNode *> face_nodes (nbNodes);
- int inode = 0;
- for (; inode < nbNodes; inode++) {
- face_nodes[inode] = curNodes[inode];
- }
-
- vector<const SMDS_MeshNode *> polygons_nodes;
- vector<int> quantities;
- int nbNew = SimplifyFace(face_nodes, polygons_nodes, quantities);
- if (nbNew > 0) {
- inode = 0;
- for (int iface = 0; iface < nbNew; iface++) {
- int nbNodes = quantities[iface];
- vector<const SMDS_MeshNode *> poly_nodes (nbNodes);
- for (int ii = 0; ii < nbNodes; ii++, inode++) {
- poly_nodes[ii] = polygons_nodes[inode];
- }
- SMDS_MeshElement* newElem = aMesh->AddPolygonalFace(poly_nodes);
- myLastCreatedElems.Append(newElem);
- if (aShapeId)
- aMesh->SetMeshElementOnShape(newElem, aShapeId);
- }
-
- MESSAGE("ChangeElementNodes MergeNodes Polygon");
- //aMesh->ChangeElementNodes(elem, &polygons_nodes[inode], quantities[nbNew - 1]);
- vector<const SMDS_MeshNode *> polynodes(polygons_nodes.begin()+inode,polygons_nodes.end());
- int quid =0;
- if (nbNew > 0) quid = nbNew - 1;
- vector<int> newquant(quantities.begin()+quid, quantities.end());
- const SMDS_MeshElement* newElem = 0;
- newElem = aMesh->AddPolyhedralVolume(polynodes, newquant);
- myLastCreatedElems.Append(newElem);
- if ( aShapeId && newElem )
- aMesh->SetMeshElementOnShape( newElem, aShapeId );
- rmElemIds.push_back(elem->GetID());
- }
- else {
- rmElemIds.push_back(elem->GetID());
- }
-
- }
- else if (elem->GetType() == SMDSAbs_Volume) {
- // Polyhedral volume
- if (nbUniqueNodes < 4) {
- rmElemIds.push_back(elem->GetID());
- }
- else {
- // each face has to be analyzed in order to check volume validity
- const SMDS_VtkVolume* aPolyedre =
- dynamic_cast<const SMDS_VtkVolume*>( elem );
- if (aPolyedre) {
- int nbFaces = aPolyedre->NbFaces();
-
- vector<const SMDS_MeshNode *> poly_nodes;
- vector<int> quantities;
-
- for (int iface = 1; iface <= nbFaces; iface++) {
- int nbFaceNodes = aPolyedre->NbFaceNodes(iface);
- vector<const SMDS_MeshNode *> faceNodes (nbFaceNodes);
-
- for (int inode = 1; inode <= nbFaceNodes; inode++) {
- const SMDS_MeshNode * faceNode = aPolyedre->GetFaceNode(iface, inode);
- TNodeNodeMap::iterator nnIt = nodeNodeMap.find(faceNode);
- if (nnIt != nodeNodeMap.end()) { // faceNode sticks
- faceNode = (*nnIt).second;
- }
- faceNodes[inode - 1] = faceNode;
- }
-
- SimplifyFace(faceNodes, poly_nodes, quantities);
- }
-
- if (quantities.size() > 3) {
- // to be done: remove coincident faces
- }
-
- if (quantities.size() > 3)
- {
- MESSAGE("ChangeElementNodes MergeNodes Polyhedron");
- //aMesh->ChangePolyhedronNodes(elem, poly_nodes, quantities);
- const SMDS_MeshElement* newElem = 0;
- newElem = aMesh->AddPolyhedralVolume(poly_nodes, quantities);
- myLastCreatedElems.Append(newElem);
- if ( aShapeId && newElem )
- aMesh->SetMeshElementOnShape( newElem, aShapeId );
- rmElemIds.push_back(elem->GetID());
- }
- }
- else {
- rmElemIds.push_back(elem->GetID());
- }
- }
- }
- else {
- }
-
- continue;
- } // poly element
-
- // Regular elements
- // TODO not all the possible cases are solved. Find something more generic?
- switch ( nbNodes ) {
- case 2: ///////////////////////////////////// EDGE
- isOk = false; break;
- case 3: ///////////////////////////////////// TRIANGLE
- isOk = false; break;
- case 4:
- if ( elem->GetType() == SMDSAbs_Volume ) // TETRAHEDRON
- isOk = false;
- else { //////////////////////////////////// QUADRANGLE
- if ( nbUniqueNodes < 3 )
- isOk = false;
- else if ( nbRepl == 2 && iRepl[ 1 ] - iRepl[ 0 ] == 2 )
- isOk = false; // opposite nodes stick
- //MESSAGE("isOk " << isOk);
- }
- break;
- case 6: ///////////////////////////////////// PENTAHEDRON
- if ( nbUniqueNodes == 4 ) {
- // ---------------------------------> tetrahedron
- if (nbRepl == 3 &&
- iRepl[ 0 ] > 2 && iRepl[ 1 ] > 2 && iRepl[ 2 ] > 2 ) {
- // all top nodes stick: reverse a bottom
- uniqueNodes[ 0 ] = curNodes [ 1 ];
- uniqueNodes[ 1 ] = curNodes [ 0 ];
- }
- else if (nbRepl == 3 &&
- iRepl[ 0 ] < 3 && iRepl[ 1 ] < 3 && iRepl[ 2 ] < 3 ) {
- // all bottom nodes stick: set a top before
- uniqueNodes[ 3 ] = uniqueNodes [ 0 ];
- uniqueNodes[ 0 ] = curNodes [ 3 ];
- uniqueNodes[ 1 ] = curNodes [ 4 ];
- uniqueNodes[ 2 ] = curNodes [ 5 ];
- }
- else if (nbRepl == 4 &&
- iRepl[ 2 ] - iRepl [ 0 ] == 3 && iRepl[ 3 ] - iRepl [ 1 ] == 3 ) {
- // a lateral face turns into a line: reverse a bottom
- uniqueNodes[ 0 ] = curNodes [ 1 ];
- uniqueNodes[ 1 ] = curNodes [ 0 ];
- }
- else
- isOk = false;
- }
- else if ( nbUniqueNodes == 5 ) {
- // PENTAHEDRON --------------------> 2 tetrahedrons
- if ( nbRepl == 2 && iRepl[ 1 ] - iRepl [ 0 ] == 3 ) {
- // a bottom node sticks with a linked top one
- // 1.
- SMDS_MeshElement* newElem =
- aMesh->AddVolume(curNodes[ 3 ],
- curNodes[ 4 ],
- curNodes[ 5 ],
- curNodes[ iRepl[ 0 ] == 2 ? 1 : 2 ]);
- myLastCreatedElems.Append(newElem);
- if ( aShapeId )
- aMesh->SetMeshElementOnShape( newElem, aShapeId );
- // 2. : reverse a bottom
- uniqueNodes[ 0 ] = curNodes [ 1 ];
- uniqueNodes[ 1 ] = curNodes [ 0 ];
- nbUniqueNodes = 4;
- }
- else
- isOk = false;
- }
- else
- isOk = false;
- break;
- case 8: {
- if(elem->IsQuadratic()) { // Quadratic quadrangle
- // 1 5 2
- // +---+---+
- // | |
- // | |
- // 4+ +6
- // | |
- // | |
- // +---+---+
- // 0 7 3
- isOk = false;
- if(nbRepl==2) {
- MESSAGE("nbRepl=2: " << iRepl[0] << " " << iRepl[1]);
- }
- if(nbRepl==3) {
- MESSAGE("nbRepl=3: " << iRepl[0] << " " << iRepl[1] << " " << iRepl[2]);
- nbUniqueNodes = 6;
- if( iRepl[0]==0 && iRepl[1]==1 && iRepl[2]==4 ) {
- uniqueNodes[0] = curNodes[0];
- uniqueNodes[1] = curNodes[2];
- uniqueNodes[2] = curNodes[3];
- uniqueNodes[3] = curNodes[5];
- uniqueNodes[4] = curNodes[6];
- uniqueNodes[5] = curNodes[7];
- isOk = true;
- }
- if( iRepl[0]==0 && iRepl[1]==3 && iRepl[2]==7 ) {
- uniqueNodes[0] = curNodes[0];
- uniqueNodes[1] = curNodes[1];
- uniqueNodes[2] = curNodes[2];
- uniqueNodes[3] = curNodes[4];
- uniqueNodes[4] = curNodes[5];
- uniqueNodes[5] = curNodes[6];
- isOk = true;
- }
- if( iRepl[0]==0 && iRepl[1]==4 && iRepl[2]==7 ) {
- uniqueNodes[0] = curNodes[1];
- uniqueNodes[1] = curNodes[2];
- uniqueNodes[2] = curNodes[3];
- uniqueNodes[3] = curNodes[5];
- uniqueNodes[4] = curNodes[6];
- uniqueNodes[5] = curNodes[0];
- isOk = true;
- }
- if( iRepl[0]==1 && iRepl[1]==2 && iRepl[2]==5 ) {
- uniqueNodes[0] = curNodes[0];
- uniqueNodes[1] = curNodes[1];
- uniqueNodes[2] = curNodes[3];
- uniqueNodes[3] = curNodes[4];
- uniqueNodes[4] = curNodes[6];
- uniqueNodes[5] = curNodes[7];
- isOk = true;
- }
- if( iRepl[0]==1 && iRepl[1]==4 && iRepl[2]==5 ) {
- uniqueNodes[0] = curNodes[0];
- uniqueNodes[1] = curNodes[2];
- uniqueNodes[2] = curNodes[3];
- uniqueNodes[3] = curNodes[1];
- uniqueNodes[4] = curNodes[6];
- uniqueNodes[5] = curNodes[7];
- isOk = true;
- }
- if( iRepl[0]==2 && iRepl[1]==3 && iRepl[2]==6 ) {
- uniqueNodes[0] = curNodes[0];
- uniqueNodes[1] = curNodes[1];
- uniqueNodes[2] = curNodes[2];
- uniqueNodes[3] = curNodes[4];
- uniqueNodes[4] = curNodes[5];
- uniqueNodes[5] = curNodes[7];
- isOk = true;
- }
- if( iRepl[0]==2 && iRepl[1]==5 && iRepl[2]==6 ) {
- uniqueNodes[0] = curNodes[0];
- uniqueNodes[1] = curNodes[1];
- uniqueNodes[2] = curNodes[3];
- uniqueNodes[3] = curNodes[4];
- uniqueNodes[4] = curNodes[2];
- uniqueNodes[5] = curNodes[7];
- isOk = true;
- }
- if( iRepl[0]==3 && iRepl[1]==6 && iRepl[2]==7 ) {
- uniqueNodes[0] = curNodes[0];
- uniqueNodes[1] = curNodes[1];
- uniqueNodes[2] = curNodes[2];
- uniqueNodes[3] = curNodes[4];
- uniqueNodes[4] = curNodes[5];
- uniqueNodes[5] = curNodes[3];
- isOk = true;
- }
- }
- if(nbRepl==4) {
- MESSAGE("nbRepl=4: " << iRepl[0] << " " << iRepl[1] << " " << iRepl[2] << " " << iRepl[3]);
- }
- if(nbRepl==5) {
- MESSAGE("nbRepl=5: " << iRepl[0] << " " << iRepl[1] << " " << iRepl[2] << " " << iRepl[3] << " " << iRepl[4]);
- }
- break;
- }
- //////////////////////////////////// HEXAHEDRON
- isOk = false;
- SMDS_VolumeTool hexa (elem);
- hexa.SetExternalNormal();
- if ( nbUniqueNodes == 4 && nbRepl == 4 ) {
- //////////////////////// HEX ---> 1 tetrahedron
- for ( int iFace = 0; iFace < 6; iFace++ ) {
- const int *ind = hexa.GetFaceNodesIndices( iFace ); // indices of face nodes
- if (curNodes[ind[ 0 ]] == curNodes[ind[ 1 ]] &&
- curNodes[ind[ 0 ]] == curNodes[ind[ 2 ]] &&
- curNodes[ind[ 0 ]] == curNodes[ind[ 3 ]] ) {
- // one face turns into a point ...
- int iOppFace = hexa.GetOppFaceIndex( iFace );
- ind = hexa.GetFaceNodesIndices( iOppFace );
- int nbStick = 0;
- for ( iCur = 0; iCur < 4 && nbStick < 2; iCur++ ) {
- if ( curNodes[ind[ iCur ]] == curNodes[ind[ iCur + 1 ]] )
- nbStick++;
- }
- if ( nbStick == 1 ) {
- // ... and the opposite one - into a triangle.
- // set a top node
- ind = hexa.GetFaceNodesIndices( iFace );
- uniqueNodes[ 3 ] = curNodes[ind[ 0 ]];
- isOk = true;
- }
- break;
- }
- }
- }
- else if ( nbUniqueNodes == 6 && nbRepl == 2 ) {
- //////////////////////// HEX ---> 1 prism
- int nbTria = 0, iTria[3];
- const int *ind; // indices of face nodes
- // look for triangular faces
- for ( int iFace = 0; iFace < 6 && nbTria < 3; iFace++ ) {
- ind = hexa.GetFaceNodesIndices( iFace );
- TIDSortedNodeSet faceNodes;
- for ( iCur = 0; iCur < 4; iCur++ )
- faceNodes.insert( curNodes[ind[iCur]] );
- if ( faceNodes.size() == 3 )
- iTria[ nbTria++ ] = iFace;
- }
- // check if triangles are opposite
- if ( nbTria == 2 && iTria[0] == hexa.GetOppFaceIndex( iTria[1] ))
- {
- isOk = true;
- // set nodes of the bottom triangle
- ind = hexa.GetFaceNodesIndices( iTria[ 0 ]);
- vector<int> indB;
- for ( iCur = 0; iCur < 4; iCur++ )
- if ( ind[iCur] != iRepl[0] && ind[iCur] != iRepl[1])
- indB.push_back( ind[iCur] );
- if ( !hexa.IsForward() )
- std::swap( indB[0], indB[2] );
- for ( iCur = 0; iCur < 3; iCur++ )
- uniqueNodes[ iCur ] = curNodes[indB[iCur]];
- // set nodes of the top triangle
- const int *indT = hexa.GetFaceNodesIndices( iTria[ 1 ]);
- for ( iCur = 0; iCur < 3; ++iCur )
- for ( int j = 0; j < 4; ++j )
- if ( hexa.IsLinked( indB[ iCur ], indT[ j ] ))
- {
- uniqueNodes[ iCur + 3 ] = curNodes[ indT[ j ]];
- break;
- }
- }
- break;
- }
- else if (nbUniqueNodes == 5 && nbRepl == 4 ) {
- //////////////////// HEXAHEDRON ---> 2 tetrahedrons
- for ( int iFace = 0; iFace < 6; iFace++ ) {
- const int *ind = hexa.GetFaceNodesIndices( iFace ); // indices of face nodes
- if (curNodes[ind[ 0 ]] == curNodes[ind[ 1 ]] &&
- curNodes[ind[ 0 ]] == curNodes[ind[ 2 ]] &&
- curNodes[ind[ 0 ]] == curNodes[ind[ 3 ]] ) {
- // one face turns into a point ...
- int iOppFace = hexa.GetOppFaceIndex( iFace );
- ind = hexa.GetFaceNodesIndices( iOppFace );
- int nbStick = 0;
- iUnique = 2; // reverse a tetrahedron 1 bottom
- for ( iCur = 0; iCur < 4 && nbStick == 0; iCur++ ) {
- if ( curNodes[ind[ iCur ]] == curNodes[ind[ iCur + 1 ]] )
- nbStick++;
- else if ( iUnique >= 0 )
- uniqueNodes[ iUnique-- ] = curNodes[ind[ iCur ]];
- }
- if ( nbStick == 0 ) {
- // ... and the opposite one is a quadrangle
- // set a top node
- const int* indTop = hexa.GetFaceNodesIndices( iFace );
- uniqueNodes[ 3 ] = curNodes[indTop[ 0 ]];
- nbUniqueNodes = 4;
- // tetrahedron 2
- SMDS_MeshElement* newElem =
- aMesh->AddVolume(curNodes[ind[ 0 ]],
- curNodes[ind[ 3 ]],
- curNodes[ind[ 2 ]],
- curNodes[indTop[ 0 ]]);
- myLastCreatedElems.Append(newElem);
- if ( aShapeId )
- aMesh->SetMeshElementOnShape( newElem, aShapeId );
- isOk = true;
- }
- break;
- }
- }
- }
- else if ( nbUniqueNodes == 6 && nbRepl == 4 ) {
- ////////////////// HEXAHEDRON ---> 2 tetrahedrons or 1 prism
- // find indices of quad and tri faces
- int iQuadFace[ 6 ], iTriFace[ 6 ], nbQuad = 0, nbTri = 0, iFace;
- for ( iFace = 0; iFace < 6; iFace++ ) {
- const int *ind = hexa.GetFaceNodesIndices( iFace ); // indices of face nodes
- nodeSet.clear();
- for ( iCur = 0; iCur < 4; iCur++ )
- nodeSet.insert( curNodes[ind[ iCur ]] );
- nbUniqueNodes = nodeSet.size();
- if ( nbUniqueNodes == 3 )
- iTriFace[ nbTri++ ] = iFace;
- else if ( nbUniqueNodes == 4 )
- iQuadFace[ nbQuad++ ] = iFace;
- }
- if (nbQuad == 2 && nbTri == 4 &&
- hexa.GetOppFaceIndex( iQuadFace[ 0 ] ) == iQuadFace[ 1 ]) {
- // 2 opposite quadrangles stuck with a diagonal;
- // sample groups of merged indices: (0-4)(2-6)
- // --------------------------------------------> 2 tetrahedrons
- const int *ind1 = hexa.GetFaceNodesIndices( iQuadFace[ 0 ]); // indices of quad1 nodes
- const int *ind2 = hexa.GetFaceNodesIndices( iQuadFace[ 1 ]);
- int i0, i1d, i2, i3d, i0t, i2t; // d-daigonal, t-top
- if (curNodes[ind1[ 0 ]] == curNodes[ind2[ 0 ]] &&
- curNodes[ind1[ 2 ]] == curNodes[ind2[ 2 ]]) {
- // stuck with 0-2 diagonal
- i0 = ind1[ 3 ];
- i1d = ind1[ 0 ];
- i2 = ind1[ 1 ];
- i3d = ind1[ 2 ];
- i0t = ind2[ 1 ];
- i2t = ind2[ 3 ];
- }
- else if (curNodes[ind1[ 1 ]] == curNodes[ind2[ 3 ]] &&
- curNodes[ind1[ 3 ]] == curNodes[ind2[ 1 ]]) {
- // stuck with 1-3 diagonal
- i0 = ind1[ 0 ];
- i1d = ind1[ 1 ];
- i2 = ind1[ 2 ];
- i3d = ind1[ 3 ];
- i0t = ind2[ 0 ];
- i2t = ind2[ 1 ];
- }
- else {
- ASSERT(0);
- }
- // tetrahedron 1
- uniqueNodes[ 0 ] = curNodes [ i0 ];
- uniqueNodes[ 1 ] = curNodes [ i1d ];
- uniqueNodes[ 2 ] = curNodes [ i3d ];
- uniqueNodes[ 3 ] = curNodes [ i0t ];
- nbUniqueNodes = 4;
- // tetrahedron 2
- SMDS_MeshElement* newElem = aMesh->AddVolume(curNodes[ i1d ],
- curNodes[ i2 ],
- curNodes[ i3d ],
- curNodes[ i2t ]);
- myLastCreatedElems.Append(newElem);
- if ( aShapeId )
- aMesh->SetMeshElementOnShape( newElem, aShapeId );
- isOk = true;
- }
- else if (( nbTri == 2 && nbQuad == 3 ) || // merged (0-4)(1-5)
- ( nbTri == 4 && nbQuad == 2 )) { // merged (7-4)(1-5)
- // --------------------------------------------> prism
- // find 2 opposite triangles
- nbUniqueNodes = 6;
- for ( iFace = 0; iFace + 1 < nbTri; iFace++ ) {
- if ( hexa.GetOppFaceIndex( iTriFace[ iFace ] ) == iTriFace[ iFace + 1 ]) {
- // find indices of kept and replaced nodes
- // and fill unique nodes of 2 opposite triangles
- const int *ind1 = hexa.GetFaceNodesIndices( iTriFace[ iFace ]);
- const int *ind2 = hexa.GetFaceNodesIndices( iTriFace[ iFace + 1 ]);
- const SMDS_MeshNode** hexanodes = hexa.GetNodes();
- // fill unique nodes
- iUnique = 0;
- isOk = true;
- for ( iCur = 0; iCur < 4 && isOk; iCur++ ) {
- const SMDS_MeshNode* n = curNodes[ind1[ iCur ]];
- const SMDS_MeshNode* nInit = hexanodes[ind1[ iCur ]];
- if ( n == nInit ) {
- // iCur of a linked node of the opposite face (make normals co-directed):
- int iCurOpp = ( iCur == 1 || iCur == 3 ) ? 4 - iCur : iCur;
- // check that correspondent corners of triangles are linked
- if ( !hexa.IsLinked( ind1[ iCur ], ind2[ iCurOpp ] ))
- isOk = false;
- else {
- uniqueNodes[ iUnique ] = n;
- uniqueNodes[ iUnique + 3 ] = curNodes[ind2[ iCurOpp ]];
- iUnique++;
- }
- }
- }
- break;
- }
- }
- }
- } // if ( nbUniqueNodes == 6 && nbRepl == 4 )
- else
- {
- MESSAGE("MergeNodes() removes hexahedron "<< elem);
- }
- break;
- } // HEXAHEDRON
-
- default:
- isOk = false;
- } // switch ( nbNodes )
-
- } // if ( nbNodes != nbUniqueNodes ) // some nodes stick
-
- if ( isOk ) { // the elem remains valid after sticking nodes
- if (elem->IsPoly() && elem->GetType() == SMDSAbs_Volume)
- {
- // Change nodes of polyedre
- const SMDS_VtkVolume* aPolyedre =
- dynamic_cast<const SMDS_VtkVolume*>( elem );
- if (aPolyedre) {
- int nbFaces = aPolyedre->NbFaces();
-
- vector<const SMDS_MeshNode *> poly_nodes;
- vector<int> quantities (nbFaces);
-
- for (int iface = 1; iface <= nbFaces; iface++) {
- int inode, nbFaceNodes = aPolyedre->NbFaceNodes(iface);
- quantities[iface - 1] = nbFaceNodes;
-
- for (inode = 1; inode <= nbFaceNodes; inode++) {
- const SMDS_MeshNode* curNode = aPolyedre->GetFaceNode(iface, inode);
-
- TNodeNodeMap::iterator nnIt = nodeNodeMap.find( curNode );
- if (nnIt != nodeNodeMap.end()) { // curNode sticks
- curNode = (*nnIt).second;
- }
- poly_nodes.push_back(curNode);
- }
- }
- aMesh->ChangePolyhedronNodes( elem, poly_nodes, quantities );
- }
- }
- else // replace non-polyhedron elements
- {
- const SMDSAbs_ElementType etyp = elem->GetType();
- const int elemId = elem->GetID();
- const bool isPoly = (elem->GetEntityType() == SMDSEntity_Polygon);
- uniqueNodes.resize(nbUniqueNodes);
-
- SMESHDS_SubMesh * sm = aShapeId > 0 ? aMesh->MeshElements(aShapeId) : 0;
-
- aMesh->RemoveFreeElement(elem, sm, /*fromGroups=*/false);
- SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, isPoly, elemId);
- if ( sm && newElem )
- sm->AddElement( newElem );
- if ( elem != newElem )
- ReplaceElemInGroups( elem, newElem, aMesh );
- }
- }
- else {
- // Remove invalid regular element or invalid polygon
- rmElemIds.push_back( elem->GetID() );
- }
-
- } // loop on elements
-
- // Remove bad elements, then equal nodes (order important)
-
- Remove( rmElemIds, false );
- Remove( rmNodeIds, true );
-
-}
-
-
-// ========================================================
-// class : SortableElement
-// purpose : allow sorting elements basing on their nodes
-// ========================================================
-class SortableElement : public set <const SMDS_MeshElement*>
-{