X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHDS%2FSMESHDS_Mesh.cxx;h=865e700c13332585d7087bbc0cf6195ac25c0bcd;hp=7c233db58e7c600d57822f4c449c121d2103fb61;hb=ccb5e3c25bf204e839c0094f50f543eacedba5e6;hpb=f3e2b7fea2d36b7dbe2df39f3e08e9c4d9b30e6d diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index 7c233db58..865e700c1 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -1374,7 +1374,7 @@ const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const if ( ShapeIndex > 0 ) return myIndexToShape.FindKey(ShapeIndex); } - catch ( Standard_OutOfRange ) + catch ( ... ) { } static TopoDS_Shape nullShape; @@ -1398,11 +1398,7 @@ int SMESHDS_Mesh::MaxSubMeshIndex() const //======================================================================= int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const { - if (myShape.IsNull()) - MESSAGE("myShape is NULL"); - int index = myIndexToShape.FindIndex(S); - return index; } @@ -1866,7 +1862,7 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, //======================================================================= //function : AddVolume -//purpose : +//purpose : 2nd order pentahedron (prism) with 15 nodes //======================================================================= SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1, const SMDS_MeshNode * n2, @@ -1897,7 +1893,7 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1, //======================================================================= //function : AddVolumeWithID -//purpose : +//purpose : 2nd order pentahedron (prism) with 15 nodes //======================================================================= SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, @@ -1913,10 +1909,96 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, n45,n56,n64,n14,n25,n36); return anElem; } + +//======================================================================= +//function : AddVolumeWithID +//purpose : 2d order Pentahedron (prism) with 15 nodes +//======================================================================= +SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2, + const SMDS_MeshNode * n3, + const SMDS_MeshNode * n4, + const SMDS_MeshNode * n5, + const SMDS_MeshNode * n6, + const SMDS_MeshNode * n12, + const SMDS_MeshNode * n23, + const SMDS_MeshNode * n31, + const SMDS_MeshNode * n45, + const SMDS_MeshNode * n56, + const SMDS_MeshNode * n64, + const SMDS_MeshNode * n14, + const SMDS_MeshNode * n25, + const SMDS_MeshNode * n36, + int ID) +{ + return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), + n4->GetID(), n5->GetID(), n6->GetID(), + n12->GetID(), n23->GetID(), n31->GetID(), + n45->GetID(), n56->GetID(), n64->GetID(), + n14->GetID(), n25->GetID(), n36->GetID(), + ID); +} +//======================================================================= +//function : AddVolume +//purpose : 2nd order pentahedron (prism) with 18 nodes +//======================================================================= +SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2, + const SMDS_MeshNode * n3, + const SMDS_MeshNode * n4, + const SMDS_MeshNode * n5, + const SMDS_MeshNode * n6, + const SMDS_MeshNode * n12, + const SMDS_MeshNode * n23, + const SMDS_MeshNode * n31, + const SMDS_MeshNode * n45, + const SMDS_MeshNode * n56, + const SMDS_MeshNode * n64, + const SMDS_MeshNode * n14, + const SMDS_MeshNode * n25, + const SMDS_MeshNode * n36, + const SMDS_MeshNode * n1245, + const SMDS_MeshNode * n2356, + const SMDS_MeshNode * n1346) +{ + SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31, + n45,n56,n64,n14,n25,n36, + n1245, n2356, n1346); + if(anElem) + myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(), + n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(), + n12->GetID(), n23->GetID(), n31->GetID(), + n45->GetID(), n56->GetID(), n64->GetID(), + n14->GetID(), n25->GetID(), n36->GetID(), + n1245->GetID(), n2356->GetID(), n1346->GetID()); + return anElem; +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : 2nd order pentahedron (prism) with 18 nodes +//======================================================================= +SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, + int n4, int n5, int n6, + int n12,int n23,int n31, + int n45,int n56,int n64, + int n14,int n25,int n36, + int n1245, int n2356, int n1346, + int ID) +{ + SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6, + n12,n23,n31, + n45,n56,n64, + n14,n25,n36, + n1245, n2356, n1346, ID); + if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31, + n45,n56,n64,n14,n25,n36, n1245, n2356, n1346); + return anElem; +} //======================================================================= //function : AddVolumeWithID -//purpose : 2d order Pentahedron with 15 nodes +//purpose : 2d order Pentahedron with 18 nodes //======================================================================= SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, const SMDS_MeshNode * n2, @@ -1933,6 +2015,9 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, const SMDS_MeshNode * n14, const SMDS_MeshNode * n25, const SMDS_MeshNode * n36, + const SMDS_MeshNode * n1245, + const SMDS_MeshNode * n2356, + const SMDS_MeshNode * n1346, int ID) { return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), @@ -1940,7 +2025,7 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, n12->GetID(), n23->GetID(), n31->GetID(), n45->GetID(), n56->GetID(), n64->GetID(), n14->GetID(), n25->GetID(), n36->GetID(), - ID); + n1245->GetID(), n2356->GetID(), n1346->GetID(), ID); } @@ -2149,16 +2234,15 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, void SMESHDS_Mesh::compactMesh() { + if ( isCompacted() ) + return; + SMDS_Mesh::compactMesh(); + int newNodeSize = 0; - int nbNodes = myNodes.size(); - int nbVtkNodes = myGrid->GetNumberOfPoints(); - //MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes); - int nbNodeTemp = nbVtkNodes; - if (nbNodes > nbVtkNodes) - nbNodeTemp = nbNodes; - vector idNodesOldToNew; - idNodesOldToNew.clear(); - idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1 + int nbNodes = myNodes.size(); + int nbVtkNodes = myGrid->GetNumberOfPoints(); + int nbNodeTemp = Max( nbVtkNodes, nbNodes ); + vector idNodesOldToNew(nbNodeTemp, -1); // all unused id will be -1 for (int i = 0; i < nbNodes; i++) { @@ -2169,28 +2253,19 @@ void SMESHDS_Mesh::compactMesh() newNodeSize++; } } - bool areNodesModified = (newNodeSize < nbVtkNodes); - //MESSAGE("------------------------- compactMesh Nodes Modified: " << areNodesModified); + bool areNodesModified = (newNodeSize != nbVtkNodes); areNodesModified = true; int newCellSize = 0; - int nbCells = myCells.size(); - int nbVtkCells = myGrid->GetNumberOfCells(); - //MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells); - int nbCellTemp = nbVtkCells; - if (nbCells > nbVtkCells) - nbCellTemp = nbCells; - vector idCellsOldToNew; - idCellsOldToNew.clear(); - idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1 + int nbCells = myCells.size(); + int nbVtkCells = myGrid->GetNumberOfCells(); + int nbCellTemp = Max( nbVtkCells, nbCells ); + vector idCellsOldToNew(nbCellTemp, -1); // all unused id will be -1 for (int i = 0; i < nbCells; i++) { if (myCells[i]) { - // //idCellsOldToNew[i] = myCellIdVtkToSmds[i]; // valid vtk indexes are > = 0 - // int vtkid = myCells[i]->getVtkId(); - // idCellsOldToNew[vtkid] = i; // old vtkId --> old smdsId (not used in input) newCellSize++; } } @@ -2212,61 +2287,43 @@ void SMESHDS_Mesh::compactMesh() if (nbVtkCells > newCellSize) newCellSize = nbVtkCells; // several cells with same SMDS Id } - // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory + // --- SMDS_MeshNode and myNodes, myNodeIdFactory - if (areNodesModified) + if ( true ) { - //MESSAGE("-------------- modify myNodes"); - SetOfNodes newNodes; - newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n + SetOfNodes newNodes(newNodeSize+1,NULL); // 0 not used, SMDS numbers 1..n int newSmdsId = 0; for (int i = 0; i < nbNodes; i++) { if (myNodes[i]) { - newSmdsId++; // SMDS id start to 1 + newSmdsId++; // SMDS id starts from 1 int oldVtkId = myNodes[i]->getVtkId(); int newVtkId = idNodesOldToNew[oldVtkId]; - //MESSAGE("myNodes["<< i << "] vtkId " << oldVtkId << " --> " << newVtkId); myNodes[i]->setVtkId(newVtkId); myNodes[i]->setId(newSmdsId); newNodes[newSmdsId] = myNodes[i]; - //MESSAGE("myNodes["<< i << "] --> newNodes[" << newSmdsId << "]"); } } myNodes.swap(newNodes); this->myNodeIDFactory->emptyPool(newSmdsId); // newSmdsId = number of nodes - //MESSAGE("myNodes.size " << myNodes.size()); } // --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells int vtkIndexSize = myCellIdVtkToSmds.size(); - int maxVtkId = -1; for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++) { int oldSmdsId = this->myCellIdVtkToSmds[oldVtkId]; if (oldSmdsId > 0) { int newVtkId = idCellsOldToNew[oldVtkId]; - if (newVtkId > maxVtkId) - maxVtkId = newVtkId; - //MESSAGE("myCells["<< oldSmdsId << "] vtkId " << oldVtkId << " --> " << newVtkId); myCells[oldSmdsId]->setVtkId(newVtkId); } } - // MESSAGE("myCells.size()=" << myCells.size() - // << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size() - // << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() ); - - SetOfCells newCells; - //vector newSmdsToVtk; - vector newVtkToSmds; - assert(maxVtkId < newCellSize); - newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n - //newSmdsToVtk.resize(newCellSize+1, -1); - newVtkToSmds.resize(newCellSize+1, -1); + SetOfCells newCells(newCellSize+1, NULL); // 0 not used, SMDS numbers 1..n + vector newVtkToSmds(newCellSize+1, -1); int myCellsSize = myCells.size(); int newSmdsId = 0; @@ -2274,22 +2331,18 @@ void SMESHDS_Mesh::compactMesh() { if ( myCells[i] ) { - newSmdsId++; // SMDS id start to 1 + newSmdsId++; // SMDS id starts from 1 assert(newSmdsId <= newCellSize); newCells[newSmdsId] = myCells[i]; newCells[newSmdsId]->setId(newSmdsId); - //MESSAGE("myCells["<< i << "] --> newCells[" << newSmdsId << "]"); int idvtk = myCells[i]->getVtkId(); - //newSmdsToVtk[newSmdsId] = idvtk; assert(idvtk < newCellSize); newVtkToSmds[idvtk] = newSmdsId; } } myCells.swap(newCells); - //myCellIdSmdsToVtk.swap(newSmdsToVtk); myCellIdVtkToSmds.swap(newVtkToSmds); - //MESSAGE("myCells.size()="<< myCells.size()<<" myCellIdVtkToSmds.size()="<myElementIDFactory->emptyPool(newSmdsId); this->myScript->SetModified(true); // notify GUI client for buildPrs when update