From: eap Date: Wed, 23 Jul 2014 16:04:21 +0000 (+0400) Subject: 52457: Addition of hypotheses is 8 time longer than meshing. X-Git-Tag: V7_5_0a1~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f1013bf7248e1d093c9a5865acbe74f6f98140b6;p=modules%2Fsmesh.git 52457: Addition of hypotheses is 8 time longer than meshing. More optimization --- diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 29f119e50..823936204 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -637,7 +637,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, const SMDS_MeshNode * n4, int ID) { - //MESSAGE("AddVolumeWithID " << ID); + //MESSAGE("AddVolumeWithID " << ID); SMDS_MeshVolume* volume = 0; if ( !n1 || !n2 || !n3 || !n4) return volume; if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); @@ -657,31 +657,30 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n3->getVtkId()); // order SMDS-->VTK - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n4->getVtkId()); + myNodeIds.resize(4); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n3->getVtkId(); // order SMDS-->VTK + myNodeIds[2] = n2->getVtkId(); + myNodeIds[3] = n4->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } volume = volvtk; adjustmyCellsCapacity(ID); myCells[ID] = volume; myInfo.myNbTetras++; } -// if (!registerElement(ID, volume)) { -// RemoveElement(volume, false); -// volume = NULL; -// } + // if (!registerElement(ID, volume)) { + // RemoveElement(volume, false); + // volume = NULL; + // } return volume; } @@ -744,7 +743,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, const SMDS_MeshNode * n5, int ID) { - //MESSAGE("AddVolumeWithID " << ID); + //MESSAGE("AddVolumeWithID " << ID); SMDS_MeshVolume* volume = 0; if ( !n1 || !n2 || !n3 || !n4 || !n5) return volume; if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); @@ -764,32 +763,31 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n5->getVtkId()); + myNodeIds.resize(5); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n4->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n2->getVtkId(); + myNodeIds[4] = n5->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } volume = volvtk; adjustmyCellsCapacity(ID); myCells[ID] = volume; myInfo.myNbPyramids++; } -// if (!registerElement(ID, volume)) { -// RemoveElement(volume, false); -// volume = NULL; -// } + // if (!registerElement(ID, volume)) { + // RemoveElement(volume, false); + // volume = NULL; + // } return volume; } @@ -856,7 +854,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, const SMDS_MeshNode * n6, int ID) { - //MESSAGE("AddVolumeWithID " << ID); + //MESSAGE("AddVolumeWithID " << ID); SMDS_MeshVolume* volume = 0; if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6) return volume; if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); @@ -877,33 +875,32 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n5->getVtkId()); - nodeIds.push_back(n6->getVtkId()); + myNodeIds.resize(6); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n2->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n4->getVtkId(); + myNodeIds[4] = n5->getVtkId(); + myNodeIds[5] = n6->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } volume = volvtk; adjustmyCellsCapacity(ID); myCells[ID] = volume; myInfo.myNbPrisms++; } -// if (!registerElement(ID, volume)) { -// RemoveElement(volume, false); -// volume = NULL; -// } + // if (!registerElement(ID, volume)) { + // RemoveElement(volume, false); + // volume = NULL; + // } return volume; } @@ -1006,29 +1003,28 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n6->getVtkId()); - nodeIds.push_back(n5->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - - nodeIds.push_back(n7->getVtkId()); - nodeIds.push_back(n12->getVtkId()); - nodeIds.push_back(n11->getVtkId()); - nodeIds.push_back(n10->getVtkId()); - nodeIds.push_back(n9->getVtkId()); - nodeIds.push_back(n8->getVtkId()); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[0] = n6->getVtkId(); + myNodeIds[0] = n5->getVtkId(); + myNodeIds[0] = n4->getVtkId(); + myNodeIds[0] = n3->getVtkId(); + myNodeIds[0] = n2->getVtkId(); + + myNodeIds[0] = n7->getVtkId(); + myNodeIds[0] = n12->getVtkId(); + myNodeIds[0] = n11->getVtkId(); + myNodeIds[0] = n10->getVtkId(); + myNodeIds[0] = n9->getVtkId(); + myNodeIds[0] = n8->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } volume = volvtk; adjustmyCellsCapacity(ID); myCells[ID] = volume; @@ -1133,35 +1129,34 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n5->getVtkId()); - nodeIds.push_back(n8->getVtkId()); - nodeIds.push_back(n7->getVtkId()); - nodeIds.push_back(n6->getVtkId()); + myNodeIds.resize(8); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n4->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n2->getVtkId(); + myNodeIds[4] = n5->getVtkId(); + myNodeIds[5] = n8->getVtkId(); + myNodeIds[6] = n7->getVtkId(); + myNodeIds[7] = n6->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } volume = volvtk; adjustmyCellsCapacity(ID); myCells[ID] = volume; myInfo.myNbHexas++; } - -// if (!registerElement(ID, volume)) { -// RemoveElement(volume, false); -// volume = NULL; -// } + + // if (!registerElement(ID, volume)) { + // RemoveElement(volume, false); + // volume = NULL; + // } return volume; } @@ -1329,57 +1324,55 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID (const vector & nodes_ids, /// Add a polygon defined by its nodes /////////////////////////////////////////////////////////////////////////////// -SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID - (const vector & nodes, - const int ID) +SMDS_MeshFace* +SMDS_Mesh::AddPolygonalFaceWithID (const vector & nodes, + const int ID) { SMDS_MeshFace * face; if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if (hasConstructionEdges()) - { - MESSAGE("Error : Not implemented"); - return NULL; - } + { + MESSAGE("Error : Not implemented"); + return NULL; + } else - { -//#ifdef VTK_HAVE_POLYHEDRON + { + //#ifdef VTK_HAVE_POLYHEDRON //MESSAGE("AddPolygonalFaceWithID vtk " << ID); - vector nodeIds; - nodeIds.clear(); - vector::const_iterator it = nodes.begin(); - for ( ; it != nodes.end(); ++it) - nodeIds.push_back((*it)->getVtkId()); + myNodeIds.resize( nodes.size() ); + for ( size_t i = 0; i < nodes.size(); ++i ) + myNodeIds[i] = nodes[i]->getVtkId(); SMDS_VtkFace *facevtk = myFacePool->getNew(); - facevtk->initPoly(nodeIds, this); + facevtk->initPoly(myNodeIds, this); if (!this->registerElement(ID,facevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); - myFacePool->destroy(facevtk); - return 0; - } - face = facevtk; -//#else -// MESSAGE("AddPolygonalFaceWithID smds " << ID); -// for ( int i = 0; i < nodes.size(); ++i ) -// if ( !nodes[ i ] ) return 0; -// face = new SMDS_PolygonalFaceOfNodes(nodes); -//#endif - adjustmyCellsCapacity(ID); - myCells[ID] = face; - myInfo.myNbPolygons++; + { + this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); + myFacePool->destroy(facevtk); + return 0; } + face = facevtk; + //#else + // MESSAGE("AddPolygonalFaceWithID smds " << ID); + // for ( int i = 0; i < nodes.size(); ++i ) + // if ( !nodes[ i ] ) return 0; + // face = new SMDS_PolygonalFaceOfNodes(nodes); + //#endif + adjustmyCellsCapacity(ID); + myCells[ID] = face; + myInfo.myNbPolygons++; + } -//#ifndef VTK_HAVE_POLYHEDRON -// if (!registerElement(ID, face)) -// { -// registerElement(myElementIDFactory->GetFreeID(), face); -// //RemoveElement(face, false); -// //face = NULL; -// } -//#endif - return face; + //#ifndef VTK_HAVE_POLYHEDRON + // if (!registerElement(ID, face)) + // { + // registerElement(myElementIDFactory->GetFreeID(), face); + // //RemoveElement(face, false); + // //face = NULL; + // } + //#endif + return face; } /////////////////////////////////////////////////////////////////////////////// @@ -1419,63 +1412,61 @@ SMDS_MeshVolume * SMDS_Mesh::AddPolyhedralVolumeWithID /// @return The created volume /////////////////////////////////////////////////////////////////////////////// -SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID - (const vector& nodes, - const vector & quantities, - const int ID) +SMDS_MeshVolume* +SMDS_Mesh::AddPolyhedralVolumeWithID (const vector& nodes, + const vector & quantities, + const int ID) { SMDS_MeshVolume* volume = 0; if ( nodes.empty() || quantities.empty() ) return NULL; if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if (hasConstructionFaces()) - { - MESSAGE("Error : Not implemented"); - return NULL; - } + { + MESSAGE("Error : Not implemented"); + return NULL; + } else if (hasConstructionEdges()) - { - MESSAGE("Error : Not implemented"); - return NULL; - } + { + MESSAGE("Error : Not implemented"); + return NULL; + } else + { + //#ifdef VTK_HAVE_POLYHEDRON + //MESSAGE("AddPolyhedralVolumeWithID vtk " << ID); + myNodeIds.resize( nodes.size() ); + for ( size_t i = 0; i < nodes.size(); ++i ) + myNodeIds[i] = nodes[i]->getVtkId(); + + SMDS_VtkVolume *volvtk = myVolumePool->getNew(); + volvtk->initPoly(myNodeIds, quantities, this); + if (!this->registerElement(ID, volvtk)) { -//#ifdef VTK_HAVE_POLYHEDRON - //MESSAGE("AddPolyhedralVolumeWithID vtk " << ID); - vector nodeIds; - nodeIds.clear(); - vector::const_iterator it = nodes.begin(); - for (; it != nodes.end(); ++it) - nodeIds.push_back((*it)->getVtkId()); - - SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->initPoly(nodeIds, quantities, this); - if (!this->registerElement(ID, volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } - volume = volvtk; -//#else -// MESSAGE("AddPolyhedralVolumeWithID smds " << ID); -// for ( int i = 0; i < nodes.size(); ++i ) -// if ( !nodes[ i ] ) return 0; -// volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities); -//#endif - adjustmyCellsCapacity(ID); - myCells[ID] = volume; - myInfo.myNbPolyhedrons++; + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; } + volume = volvtk; + //#else + // MESSAGE("AddPolyhedralVolumeWithID smds " << ID); + // for ( int i = 0; i < nodes.size(); ++i ) + // if ( !nodes[ i ] ) return 0; + // volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities); + //#endif + adjustmyCellsCapacity(ID); + myCells[ID] = volume; + myInfo.myNbPolyhedrons++; + } -//#ifndef VTK_HAVE_POLYHEDRON -// if (!registerElement(ID, volume)) -// { -// registerElement(myElementIDFactory->GetFreeID(), volume); -// //RemoveElement(volume, false); -// //volume = NULL; -// } -//#endif + //#ifndef VTK_HAVE_POLYHEDRON + // if (!registerElement(ID, volume)) + // { + // registerElement(myElementIDFactory->GetFreeID(), volume); + // //RemoveElement(volume, false); + // //volume = NULL; + // } + //#endif return volume; } @@ -1705,21 +1696,20 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(node1->getVtkId()); - nodeIds.push_back(node2->getVtkId()); - nodeIds.push_back(node3->getVtkId()); + myNodeIds.resize(3); + myNodeIds[0] = node1->getVtkId(); + myNodeIds[1] = node2->getVtkId(); + myNodeIds[2] = node3->getVtkId(); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); - facevtk->init(nodeIds, this); // put in vtkUnstructuredGrid + facevtk->init(myNodeIds, this); // put in vtkUnstructuredGrid if (!this->registerElement(ID,facevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); - myFacePool->destroy(facevtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); + myFacePool->destroy(facevtk); + return 0; + } face = facevtk; adjustmyCellsCapacity(ID); myCells[ID] = face; @@ -1743,7 +1733,7 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionEdges()) { - //MESSAGE("createQuadrangle hasConstructionEdges "<< ID); + //MESSAGE("createQuadrangle hasConstructionEdges "<< ID); SMDS_MeshEdge *edge1, *edge2, *edge3, *edge4; edge1=FindEdgeOrCreate(node1,node2); edge2=FindEdgeOrCreate(node2,node3); @@ -1759,22 +1749,21 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(node1->getVtkId()); - nodeIds.push_back(node2->getVtkId()); - nodeIds.push_back(node3->getVtkId()); - nodeIds.push_back(node4->getVtkId()); + myNodeIds.resize(4); + myNodeIds[0] = node1->getVtkId(); + myNodeIds[1] = node2->getVtkId(); + myNodeIds[2] = node3->getVtkId(); + myNodeIds[3] = node4->getVtkId(); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); - facevtk->init(nodeIds, this); + facevtk->init(myNodeIds, this); if (!this->registerElement(ID,facevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); - myFacePool->destroy(facevtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); + myFacePool->destroy(facevtk); + return 0; + } face = facevtk; adjustmyCellsCapacity(ID); myCells[ID] = face; @@ -2094,19 +2083,18 @@ SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1, if ( NbEdges() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); int ID = myElementIDFactory->GetFreeID(); // -PR- voir si on range cet element adjustmyCellsCapacity(ID); - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(node1->getVtkId()); - nodeIds.push_back(node2->getVtkId()); + myNodeIds.resize(2); + myNodeIds[0] = node1->getVtkId(); + myNodeIds[1] = node2->getVtkId(); SMDS_VtkEdge *edgevtk = myEdgePool->getNew(); - edgevtk->init(nodeIds, this); + edgevtk->init(myNodeIds, this); if (!this->registerElement(ID,edgevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL); - myEdgePool->destroy(edgevtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL); + myEdgePool->destroy(edgevtk); + return 0; + } toReturn = edgevtk; myCells[ID] = toReturn; myInfo.myNbEdges++; @@ -3591,30 +3579,29 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, if ( !n1 || !n2 || !n12 ) return 0; // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n12->getVtkId()); + myNodeIds.resize(3); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n2->getVtkId(); + myNodeIds[2] = n12->getVtkId(); SMDS_MeshEdge * edge = 0; SMDS_VtkEdge *edgevtk = myEdgePool->getNew(); - edgevtk->init(nodeIds, this); + edgevtk->init(myNodeIds, this); if (!this->registerElement(ID,edgevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL); - myEdgePool->destroy(edgevtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL); + myEdgePool->destroy(edgevtk); + return 0; + } edge = edgevtk; adjustmyCellsCapacity(ID); myCells[ID] = edge; myInfo.myNbQuadEdges++; -// if (!registerElement(ID, edge)) { -// RemoveElement(edge, false); -// edge = NULL; -// } + // if (!registerElement(ID, edge)) { + // RemoveElement(edge, false); + // edge = NULL; + // } return edge; } @@ -3672,33 +3659,32 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n12->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n31->getVtkId()); + myNodeIds.resize(6); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n2->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n12->getVtkId(); + myNodeIds[4] = n23->getVtkId(); + myNodeIds[5] = n31->getVtkId(); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); - facevtk->init(nodeIds, this); + facevtk->init(myNodeIds, this); if (!this->registerElement(ID,facevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); - myFacePool->destroy(facevtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); + myFacePool->destroy(facevtk); + return 0; + } face = facevtk; adjustmyCellsCapacity(ID); myCells[ID] = face; myInfo.myNbQuadTriangles++; -// if (!registerElement(ID, face)) { -// RemoveElement(face, false); -// face = NULL; -// } + // if (!registerElement(ID, face)) { + // RemoveElement(face, false); + // face = NULL; + // } return face; } } @@ -3759,34 +3745,33 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n12->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n31->getVtkId()); - nodeIds.push_back(nCenter->getVtkId()); + myNodeIds.resize(7); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n2->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n12->getVtkId(); + myNodeIds[4] = n23->getVtkId(); + myNodeIds[5] = n31->getVtkId(); + myNodeIds[6] = nCenter->getVtkId(); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); - facevtk->init(nodeIds, this); + facevtk->init(myNodeIds, this); if (!this->registerElement(ID,facevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); - myFacePool->destroy(facevtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); + myFacePool->destroy(facevtk); + return 0; + } face = facevtk; adjustmyCellsCapacity(ID); myCells[ID] = face; myInfo.myNbBiQuadTriangles++; -// if (!registerElement(ID, face)) { -// RemoveElement(face, false); -// face = NULL; -// } + // if (!registerElement(ID, face)) { + // RemoveElement(face, false); + // face = NULL; + // } return face; } } @@ -3845,40 +3830,39 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, if ( !n1 || !n2 || !n3 || !n4 || !n12 || !n23 || !n34 || !n41) return 0; if(hasConstructionEdges()) { // creation quadratic edges - not implemented - return 0; + return 0; } else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n12->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n34->getVtkId()); - nodeIds.push_back(n41->getVtkId()); + myNodeIds.resize(8); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n2->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n4->getVtkId(); + myNodeIds[4] = n12->getVtkId(); + myNodeIds[5] = n23->getVtkId(); + myNodeIds[6] = n34->getVtkId(); + myNodeIds[7] = n41->getVtkId(); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); - facevtk->init(nodeIds, this); + facevtk->init(myNodeIds, this); if (!this->registerElement(ID,facevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); - myFacePool->destroy(facevtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); + myFacePool->destroy(facevtk); + return 0; + } face = facevtk; adjustmyCellsCapacity(ID); myCells[ID] = face; myInfo.myNbQuadQuadrangles++; -// if (!registerElement(ID, face)) { -// RemoveElement(face, false); -// face = NULL; -// } + // if (!registerElement(ID, face)) { + // RemoveElement(face, false); + // face = NULL; + // } return face; } } @@ -3939,41 +3923,40 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, if ( !n1 || !n2 || !n3 || !n4 || !n12 || !n23 || !n34 || !n41 || !nCenter) return 0; if(hasConstructionEdges()) { // creation quadratic edges - not implemented - return 0; + return 0; } else { // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n12->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n34->getVtkId()); - nodeIds.push_back(n41->getVtkId()); - nodeIds.push_back(nCenter->getVtkId()); + myNodeIds.resize(9); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n2->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n4->getVtkId(); + myNodeIds[4] = n12->getVtkId(); + myNodeIds[5] = n23->getVtkId(); + myNodeIds[6] = n34->getVtkId(); + myNodeIds[7] = n41->getVtkId(); + myNodeIds[8] = nCenter->getVtkId(); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); - facevtk->init(nodeIds, this); + facevtk->init(myNodeIds, this); if (!this->registerElement(ID,facevtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); - myFacePool->destroy(facevtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); + myFacePool->destroy(facevtk); + return 0; + } face = facevtk; adjustmyCellsCapacity(ID); myCells[ID] = face; myInfo.myNbBiQuadQuadrangles++; -// if (!registerElement(ID, face)) { -// RemoveElement(face, false); -// face = NULL; -// } + // if (!registerElement(ID, face)) { + // RemoveElement(face, false); + // face = NULL; + // } return face; } } @@ -4046,37 +4029,36 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, return 0; } // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n4->getVtkId()); + myNodeIds.resize(10); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n3->getVtkId(); + myNodeIds[2] = n2->getVtkId(); + myNodeIds[3] = n4->getVtkId(); - nodeIds.push_back(n31->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n12->getVtkId()); + myNodeIds[4] = n31->getVtkId(); + myNodeIds[5] = n23->getVtkId(); + myNodeIds[6] = n12->getVtkId(); - nodeIds.push_back(n14->getVtkId()); - nodeIds.push_back(n34->getVtkId()); - nodeIds.push_back(n24->getVtkId()); + myNodeIds[7] = n14->getVtkId(); + myNodeIds[8] = n34->getVtkId(); + myNodeIds[9] = n24->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } adjustmyCellsCapacity(ID); myCells[ID] = volvtk; myInfo.myNbQuadTetras++; -// if (!registerElement(ID, volvtk)) { -// RemoveElement(volvtk, false); -// volvtk = NULL; -// } + // if (!registerElement(ID, volvtk)) { + // RemoveElement(volvtk, false); + // volvtk = NULL; + // } return volvtk; } @@ -4159,40 +4141,39 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, return 0; } // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n5->getVtkId()); - - nodeIds.push_back(n41->getVtkId()); - nodeIds.push_back(n34->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n12->getVtkId()); - - nodeIds.push_back(n15->getVtkId()); - nodeIds.push_back(n45->getVtkId()); - nodeIds.push_back(n35->getVtkId()); - nodeIds.push_back(n25->getVtkId()); + myNodeIds.resize(13); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n4->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n2->getVtkId(); + myNodeIds[4] = n5->getVtkId(); + + myNodeIds[5] = n41->getVtkId(); + myNodeIds[6] = n34->getVtkId(); + myNodeIds[7] = n23->getVtkId(); + myNodeIds[8] = n12->getVtkId(); + + myNodeIds[9] = n15->getVtkId(); + myNodeIds[10] = n45->getVtkId(); + myNodeIds[11] = n35->getVtkId(); + myNodeIds[12] = n25->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } adjustmyCellsCapacity(ID); myCells[ID] = volvtk; myInfo.myNbQuadPyramids++; -// if (!registerElement(ID, volvtk)) { -// RemoveElement(volvtk, false); -// volvtk = NULL; -// } + // if (!registerElement(ID, volvtk)) { + // RemoveElement(volvtk, false); + // volvtk = NULL; + // } return volvtk; } @@ -4283,44 +4264,43 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, return 0; } // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - nodeIds.push_back(n3->getVtkId()); + myNodeIds.resize(15); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n2->getVtkId(); + myNodeIds[2] = n3->getVtkId(); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n5->getVtkId()); - nodeIds.push_back(n6->getVtkId()); + myNodeIds[3] = n4->getVtkId(); + myNodeIds[4] = n5->getVtkId(); + myNodeIds[5] = n6->getVtkId(); - nodeIds.push_back(n12->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n31->getVtkId()); + myNodeIds[6] = n12->getVtkId(); + myNodeIds[7] = n23->getVtkId(); + myNodeIds[8] = n31->getVtkId(); - nodeIds.push_back(n45->getVtkId()); - nodeIds.push_back(n56->getVtkId()); - nodeIds.push_back(n64->getVtkId()); + myNodeIds[9] = n45->getVtkId(); + myNodeIds[10] = n56->getVtkId(); + myNodeIds[11] = n64->getVtkId(); - nodeIds.push_back(n14->getVtkId()); - nodeIds.push_back(n25->getVtkId()); - nodeIds.push_back(n36->getVtkId()); + myNodeIds[12] = n14->getVtkId(); + myNodeIds[13] = n25->getVtkId(); + myNodeIds[14] = n36->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } adjustmyCellsCapacity(ID); myCells[ID] = volvtk; myInfo.myNbQuadPrisms++; -// if (!registerElement(ID, volvtk)) { -// RemoveElement(volvtk, false); -// volvtk = NULL; -// } + // if (!registerElement(ID, volvtk)) { + // RemoveElement(volvtk, false); + // volvtk = NULL; + // } return volvtk; } @@ -4426,49 +4406,48 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // creation quadratic faces - not implemented } // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - - nodeIds.push_back(n5->getVtkId()); - nodeIds.push_back(n8->getVtkId()); - nodeIds.push_back(n7->getVtkId()); - nodeIds.push_back(n6->getVtkId()); - - nodeIds.push_back(n41->getVtkId()); - nodeIds.push_back(n34->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n12->getVtkId()); - - nodeIds.push_back(n85->getVtkId()); - nodeIds.push_back(n78->getVtkId()); - nodeIds.push_back(n67->getVtkId()); - nodeIds.push_back(n56->getVtkId()); - - nodeIds.push_back(n15->getVtkId()); - nodeIds.push_back(n48->getVtkId()); - nodeIds.push_back(n37->getVtkId()); - nodeIds.push_back(n26->getVtkId()); + myNodeIds.resize(20); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n4->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n2->getVtkId(); + + myNodeIds[4] = n5->getVtkId(); + myNodeIds[5] = n8->getVtkId(); + myNodeIds[6] = n7->getVtkId(); + myNodeIds[7] = n6->getVtkId(); + + myNodeIds[8] = n41->getVtkId(); + myNodeIds[9] = n34->getVtkId(); + myNodeIds[10] = n23->getVtkId(); + myNodeIds[11] = n12->getVtkId(); + + myNodeIds[12] = n85->getVtkId(); + myNodeIds[13] = n78->getVtkId(); + myNodeIds[14] = n67->getVtkId(); + myNodeIds[15] = n56->getVtkId(); + + myNodeIds[16] = n15->getVtkId(); + myNodeIds[17] = n48->getVtkId(); + myNodeIds[18] = n37->getVtkId(); + myNodeIds[19] = n26->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } adjustmyCellsCapacity(ID); myCells[ID] = volvtk; myInfo.myNbQuadHexas++; -// if (!registerElement(ID, volvtk)) { -// RemoveElement(volvtk, false); -// volvtk = NULL; -// } + // if (!registerElement(ID, volvtk)) { + // RemoveElement(volvtk, false); + // volvtk = NULL; + // } return volvtk; } @@ -4599,49 +4578,48 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // creation quadratic faces - not implemented } // --- retrieve nodes ID - vector nodeIds; - nodeIds.clear(); - nodeIds.push_back(n1->getVtkId()); - nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n2->getVtkId()); - - nodeIds.push_back(n5->getVtkId()); - nodeIds.push_back(n8->getVtkId()); - nodeIds.push_back(n7->getVtkId()); - nodeIds.push_back(n6->getVtkId()); - - nodeIds.push_back(n41->getVtkId()); - nodeIds.push_back(n34->getVtkId()); - nodeIds.push_back(n23->getVtkId()); - nodeIds.push_back(n12->getVtkId()); - - nodeIds.push_back(n85->getVtkId()); - nodeIds.push_back(n78->getVtkId()); - nodeIds.push_back(n67->getVtkId()); - nodeIds.push_back(n56->getVtkId()); - - nodeIds.push_back(n15->getVtkId()); - nodeIds.push_back(n48->getVtkId()); - nodeIds.push_back(n37->getVtkId()); - nodeIds.push_back(n26->getVtkId()); - - nodeIds.push_back(n1256->getVtkId()); - nodeIds.push_back(n3478->getVtkId()); - nodeIds.push_back(n1458->getVtkId()); - nodeIds.push_back(n2367->getVtkId()); - nodeIds.push_back(n1234->getVtkId()); - nodeIds.push_back(n5678->getVtkId()); - nodeIds.push_back(nCenter->getVtkId()); + myNodeIds.resize(27); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n4->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + myNodeIds[3] = n2->getVtkId(); + + myNodeIds[4] = n5->getVtkId(); + myNodeIds[5] = n8->getVtkId(); + myNodeIds[6] = n7->getVtkId(); + myNodeIds[7] = n6->getVtkId(); + + myNodeIds[8] = n41->getVtkId(); + myNodeIds[9] = n34->getVtkId(); + myNodeIds[10] = n23->getVtkId(); + myNodeIds[11] = n12->getVtkId(); + + myNodeIds[12] = n85->getVtkId(); + myNodeIds[13] = n78->getVtkId(); + myNodeIds[14] = n67->getVtkId(); + myNodeIds[15] = n56->getVtkId(); + + myNodeIds[16] = n15->getVtkId(); + myNodeIds[17] = n48->getVtkId(); + myNodeIds[18] = n37->getVtkId(); + myNodeIds[19] = n26->getVtkId(); + + myNodeIds[20] = n1256->getVtkId(); + myNodeIds[21] = n3478->getVtkId(); + myNodeIds[22] = n1458->getVtkId(); + myNodeIds[23] = n2367->getVtkId(); + myNodeIds[24] = n1234->getVtkId(); + myNodeIds[25] = n5678->getVtkId(); + myNodeIds[26] = nCenter->getVtkId(); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); - volvtk->init(nodeIds, this); + volvtk->init(myNodeIds, this); if (!this->registerElement(ID,volvtk)) - { - this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); - myVolumePool->destroy(volvtk); - return 0; - } + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } adjustmyCellsCapacity(ID); myCells[ID] = volvtk; myInfo.myNbTriQuadHexas++; @@ -4655,8 +4633,8 @@ void SMDS_Mesh::updateNodeMinMax() myNodeMin = 0; if (myNodes.size() == 0) { - myNodeMax=0; - return; + myNodeMax=0; + return; } while (!myNodes[myNodeMin] && (myNodeMin& setOfChildren, - const SMDS_MeshElement * element, + const SMDS_MeshElement * element, std::set& nodes); inline void adjustmyCellsCapacity(int ID) @@ -818,8 +818,8 @@ protected: //! SMDS_MeshCells refer to vtk cells (vtk id != index in myCells),store reference to this mesh, and sub-shape SetOfCells myCells; - //! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid - //std::vector myCellIdSmdsToVtk; + //! a buffer to speed up elements addition by excluding some memory allocation + std::vector myNodeIds; //! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users std::vector myCellIdVtkToSmds; diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 3acff6796..864f50c21 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -232,7 +232,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, if ( aShapesId && aShapeDim > (int)aDim ) continue; - SMESH_Algo* algo = GetAlgo( aMesh, aSubShape, &algoShape ); + SMESH_Algo* algo = GetAlgo( smToCompute, &algoShape ); if ( algo && !algo->NeedDiscreteBoundary() ) { if ( algo->SupportSubmeshes() ) @@ -308,7 +308,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, sm = smVec[i]; // get a shape the algo is assigned to - if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape )) + if ( !GetAlgo( sm, & algoShape )) continue; // strange... // look for more local algos @@ -331,7 +331,8 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, .And( SMESH_HypoFilter::IsApplicableTo( aSubShape )) .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh )); - if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) { + if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( smToCompute, filter, true)) + { if ( ! subAlgo->NeedDiscreteBoundary() ) continue; SMESH_Hypothesis::Hypothesis_Status status; if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status )) @@ -477,7 +478,7 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh, const int aShapeDim = GetShapeDim( aSubShape ); if ( aShapeDim < 1 ) break; - SMESH_Algo* algo = GetAlgo( aMesh, aSubShape ); + SMESH_Algo* algo = GetAlgo( smToCompute ); if ( algo && !algo->NeedDiscreteBoundary() ) { if ( algo->SupportSubmeshes() ) { smWithAlgoSupportingSubmeshes.push_front( smToCompute ); @@ -508,7 +509,7 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh, // get a shape the algo is assigned to TopoDS_Shape algoShape; - if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape )) + if ( !GetAlgo( sm, & algoShape )) continue; // strange... // look for more local algos @@ -525,7 +526,8 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh, .And( SMESH_HypoFilter::IsApplicableTo( aSubShape )) .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh )); - if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) { + if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( smToCompute, filter, true )) + { if ( ! subAlgo->NeedDiscreteBoundary() ) continue; SMESH_Hypothesis::Hypothesis_Status status; if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status )) @@ -1013,6 +1015,23 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo) { + return GetAlgo( aMesh.GetSubMesh( aShape ), assignedTo ); +} + +//============================================================================= +/*! + * Finds algo to mesh a sub-mesh. Optionally returns a shape the found algo is bound to + */ +//============================================================================= + +SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_subMesh * aSubMesh, + TopoDS_Shape* assignedTo) +{ + if ( !aSubMesh ) return 0; + + const TopoDS_Shape & aShape = aSubMesh->GetSubShape(); + SMESH_Mesh& aMesh = *aSubMesh->GetFather(); + SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() ); filter.And( filter.IsApplicableTo( aShape )); @@ -1020,7 +1039,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, TopoDS_Shape assignedToShape; SMESH_Algo* algo = - (SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, &assignedToShape ); + (SMESH_Algo*) aMesh.GetHypothesis( aSubMesh, filter, true, &assignedToShape ); if ( algo && aShape.ShapeType() == TopAbs_FACE && @@ -1035,7 +1054,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, filter.AndNot( filter.Is( algo )); TopoDS_Shape assignedToShape2; SMESH_Algo* algo2 = - (SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, &assignedToShape2 ); + (SMESH_Algo*) aMesh.GetHypothesis( aSubMesh, filter, true, &assignedToShape2 ); if ( algo2 && // algo found !assignedToShape2.IsSame( aMesh.GetShapeToMesh() ) && // algo is local ( SMESH_MesherHelper::GetGroupType( assignedToShape2 ) == // algo of the same level diff --git a/src/SMESH/SMESH_Gen.hxx b/src/SMESH/SMESH_Gen.hxx index 5462eacab..4dac76d43 100644 --- a/src/SMESH/SMESH_Gen.hxx +++ b/src/SMESH/SMESH_Gen.hxx @@ -147,6 +147,7 @@ public: { return GetShapeDim( aShape.ShapeType() ); } SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0); + SMESH_Algo* GetAlgo(SMESH_subMesh * aSubMesh, TopoDS_Shape* assignedTo=0); static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh); diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index a7c20a0c5..3988f2a23 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -773,7 +773,30 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS const bool andAncestors, TopoDS_Shape* assignedTo) const { + return GetHypothesis( const_cast< SMESH_Mesh* >(this)->GetSubMesh( aSubShape ), + aFilter, andAncestors, assignedTo ); +} + +//======================================================================= +/*! + * \brief Return the hypothesis assigned to the shape of a sub-mesh + * \param aSubMesh - the sub-mesh to check + * \param aFilter - the hypothesis filter + * \param andAncestors - flag to check hypos assigned to ancestors of the shape + * \param assignedTo - to return the shape the found hypo is assigned to + * \retval SMESH_Hypothesis* - the first hypo passed through aFilter + */ +//======================================================================= + +const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const SMESH_subMesh * aSubMesh, + const SMESH_HypoFilter& aFilter, + const bool andAncestors, + TopoDS_Shape* assignedTo) const +{ + if ( !aSubMesh ) return 0; + { + const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape(); const list& hypList = _myMeshDS->GetHypothesis(aSubShape); list::const_iterator hyp = hypList.begin(); for ( ; hyp != hypList.end(); hyp++ ) { @@ -787,9 +810,12 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS if ( andAncestors ) { // user sorted submeshes of ancestors, according to stored submesh priority - getAncestorsSubMeshes( aSubShape, _ancestorSubMeshes ); - vector::const_iterator smIt = _ancestorSubMeshes.begin(); - for ( ; smIt != _ancestorSubMeshes.end(); smIt++ ) + std::vector< SMESH_subMesh * > & ancestors = + const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() ); + SortByMeshOrder( ancestors ); + + vector::const_iterator smIt = ancestors.begin(); + for ( ; smIt != ancestors.end(); smIt++ ) { const TopoDS_Shape& curSh = (*smIt)->GetSubShape(); const list& hypList = _myMeshDS->GetHypothesis(curSh); @@ -808,7 +834,7 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS //================================================================================ /*! - * \brief Return hypothesis assigned to the shape + * \brief Return hypotheses assigned to the shape * \param aSubShape - the shape to check * \param aFilter - the hypothesis filter * \param aHypList - the list of the found hypotheses @@ -823,6 +849,29 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape, const bool andAncestors, list< TopoDS_Shape > * assignedTo/*=0*/) const { + return GetHypotheses( const_cast< SMESH_Mesh* >(this)->GetSubMesh( aSubShape ), + aFilter, aHypList, andAncestors, assignedTo ); +} + +//================================================================================ +/*! + * \brief Return hypotheses assigned to the shape of a sub-mesh + * \param aSubShape - the sub-mesh to check + * \param aFilter - the hypothesis filter + * \param aHypList - the list of the found hypotheses + * \param andAncestors - flag to check hypos assigned to ancestors of the shape + * \retval int - number of unique hypos in aHypList + */ +//================================================================================ + +int SMESH_Mesh::GetHypotheses(const SMESH_subMesh * aSubMesh, + const SMESH_HypoFilter& aFilter, + list & aHypList, + const bool andAncestors, + list< TopoDS_Shape > * assignedTo/*=0*/) const +{ + if ( !aSubMesh ) return 0; + set hypTypes; // to exclude same type hypos from the result list int nbHyps = 0; @@ -840,6 +889,7 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape, // get hypos from aSubShape { + const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape(); const list& hypList = _myMeshDS->GetHypothesis(aSubShape); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ ) if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) && @@ -857,16 +907,15 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape, // get hypos from ancestors of aSubShape if ( andAncestors ) { - TopTools_MapOfShape map; - // user sorted submeshes of ancestors, according to stored submesh priority - getAncestorsSubMeshes( aSubShape, _ancestorSubMeshes ); - vector::const_iterator smIt = _ancestorSubMeshes.begin(); - for ( ; smIt != _ancestorSubMeshes.end(); smIt++ ) + std::vector< SMESH_subMesh * > & ancestors = + const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() ); + SortByMeshOrder( ancestors ); + + vector::const_iterator smIt = ancestors.begin(); + for ( ; smIt != ancestors.end(); smIt++ ) { const TopoDS_Shape& curSh = (*smIt)->GetSubShape(); - if ( !map.Add( curSh )) - continue; const list& hypList = _myMeshDS->GetHypothesis(curSh); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ ) if (( aFilter.IsOk( cSMESH_Hyp( *hyp ), curSh )) && @@ -1047,9 +1096,7 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp )) return false; - const TopoDS_Shape & aSubShape = const_cast( aSubMesh )->GetSubShape(); - - SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape ); + SMESH_Algo *algo = aSubMesh->GetAlgo(); // algorithm if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO) @@ -1062,7 +1109,7 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, const SMESH_HypoFilter* hypoKind; if (( hypoKind = algo->GetCompatibleHypoFilter( !hyp->IsAuxiliary() ))) { list usedHyps; - if ( GetHypotheses( aSubShape, *hypoKind, usedHyps, true )) + if ( GetHypotheses( aSubMesh, *hypoKind, usedHyps, true )) return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() ); } } @@ -1134,7 +1181,7 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h { // check if hyp is used by algo usedHyps.clear(); - if ( GetHypotheses( aSubShape, *compatibleHypoKind, usedHyps, true ) && + if ( GetHypotheses( aSubMesh, *compatibleHypoKind, usedHyps, true ) && find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() ) { aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP, @@ -2138,7 +2185,10 @@ void SMESH_Mesh::fillAncestorsMap(const TopoDS_Shape& theShape) while ( ancIt.More() && ancIt.Value().ShapeType() >= memberType ) ancIt.Next(); if ( ancIt.More() ) + { ancList.InsertBefore( theShape, ancIt ); + GetSubMesh( des.Current() )->ClearAncestors(); // to re-fill _ancestors + } } } { diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 84086a3ea..1e92a4871 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -148,6 +148,17 @@ public: const bool andAncestors, std::list< TopoDS_Shape > * assignedTo=0) const; + const SMESH_Hypothesis * GetHypothesis(const SMESH_subMesh * aSubMesh, + const SMESH_HypoFilter& aFilter, + const bool andAncestors, + TopoDS_Shape* assignedTo=0) const; + + int GetHypotheses(const SMESH_subMesh * aSubMesh, + const SMESH_HypoFilter& aFilter, + std::list< const SMESHDS_Hypothesis * >& aHypList, + const bool andAncestors, + std::list< TopoDS_Shape > * assignedTo=0) const; + SMESH_Hypothesis * GetHypothesis(const int aHypID) const; const std::list & GetLog() throw(SALOME_Exception); diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index e85c7bd44..5edc28da0 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -47,13 +47,14 @@ #include #include #include +#include #include #include +#include #include #include -#include -#include #include +#include #include #include @@ -195,7 +196,10 @@ SMESH_subMesh *SMESH_subMesh::GetFirstToCompute() SMESH_Algo* SMESH_subMesh::GetAlgo() const { if ( !_algo ) - ((SMESH_subMesh*)this)->_algo = _father->GetGen()->GetAlgo(*_father, _subShape); + { + SMESH_subMesh* me = const_cast< SMESH_subMesh* >( this ); + me->_algo = _father->GetGen()->GetAlgo( me ); + } return _algo; } @@ -735,7 +739,7 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_HypoFilter filter( SMESH_HypoFilter::HasType( algo->GetType() )); filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+1 )); filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+2 )); - if ( SMESH_Algo * curAlgo = (SMESH_Algo*)_father->GetHypothesis(_subShape, filter, true )) + if ( SMESH_Algo * curAlgo = (SMESH_Algo*)_father->GetHypothesis( this, filter, true )) if ( !curAlgo->NeedDiscreteBoundary() ) algoRequiringCleaning = curAlgo; } @@ -964,7 +968,7 @@ SMESH_Hypothesis::Hypothesis_Status f.Init( SMESH_HypoFilter::IsAlgo() ); f.And( SMESH_HypoFilter::IsApplicableTo( _subShape )); f.AndNot( SMESH_HypoFilter::Is( algo )); - const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( _subShape, f, true ); + const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( this, f, true ); if (prevAlgo && string(algo->GetName()) != string(prevAlgo->GetName()) ) modifiedHyp = true; @@ -1023,7 +1027,7 @@ SMESH_Hypothesis::Hypothesis_Status f.Init( SMESH_HypoFilter::IsAlgo() ); f.And( SMESH_HypoFilter::IsApplicableTo( _subShape )); f.AndNot( SMESH_HypoFilter::Is( algo )); - const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( _subShape, f, true ); + const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( this, f, true ); if (prevAlgo && string(algo->GetName()) != string(prevAlgo->GetName()) ) modifiedHyp = true; @@ -1089,21 +1093,22 @@ SMESH_Hypothesis::Hypothesis_Status { // is algo hidden? SMESH_Gen* gen = _father->GetGen(); - TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); - for ( ; ( ret == SMESH_Hypothesis::HYP_OK && it.More()); it.Next() ) { - if ( SMESH_Algo* upperAlgo = gen->GetAlgo( *_father, it.Value() )) + const std::vector< SMESH_subMesh * > & ancestors = GetAncestors(); + for ( size_t iA = 0; ( ret == SMESH_Hypothesis::HYP_OK && iA < ancestors.size()); ++iA ) { + if ( SMESH_Algo* upperAlgo = ancestors[ iA ]->GetAlgo() ) if ( !upperAlgo->NeedDiscreteBoundary() && !upperAlgo->SupportSubmeshes()) ret = SMESH_Hypothesis::HYP_HIDDEN_ALGO; } // is algo hiding? if ( ret == SMESH_Hypothesis::HYP_OK && !algo->NeedDiscreteBoundary() && - !algo->SupportSubmeshes()) { + !algo->SupportSubmeshes()) + { TopoDS_Shape algoAssignedTo, otherAssignedTo; - gen->GetAlgo( *_father, _subShape, &algoAssignedTo ); + gen->GetAlgo( this, &algoAssignedTo ); map::reverse_iterator i_sm = _mapDepend.rbegin(); for ( ; ( ret == SMESH_Hypothesis::HYP_OK && i_sm != _mapDepend.rend()) ; ++i_sm ) - if ( gen->GetAlgo( *_father, i_sm->second->_subShape, &otherAssignedTo ) && + if ( gen->GetAlgo( i_sm->second, &otherAssignedTo ) && SMESH_MesherHelper::IsSubShape( /*sub=*/otherAssignedTo, /*main=*/algoAssignedTo )) ret = SMESH_Hypothesis::HYP_HIDING_ALGO; } @@ -1177,16 +1182,16 @@ bool SMESH_subMesh::IsConform(const SMESH_Algo* theAlgo) for (; itsub.More(); itsub.Next()) { // loop on adjacent subShapes - TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( itsub.Value() )); - for (; it.More(); it.Next()) + const std::vector< SMESH_subMesh * > & ancestors = GetAncestors(); + for ( size_t iA = 0; iA < ancestors.size(); ++iA ) { - const TopoDS_Shape& adjacent = it.Value(); + const TopoDS_Shape& adjacent = ancestors[ iA ]->GetSubShape(); if ( _subShape.IsSame( adjacent )) continue; if ( adjacent.ShapeType() != _subShape.ShapeType()) break; // check algo attached to smAdjacent - SMESH_Algo * algo = gen->GetAlgo((*_father), adjacent); + SMESH_Algo * algo = ancestors[ iA ]->GetAlgo(); if (algo && !algo->NeedDiscreteBoundary() && algo->OnlyUnaryInput()) @@ -2035,12 +2040,10 @@ void SMESH_subMesh::ComputeSubMeshStateEngine(int event, const bool includeSelf) void SMESH_subMesh::updateDependantsState(const compute_event theEvent) { - TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); - for (; it.More(); it.Next()) + const std::vector< SMESH_subMesh * > & ancestors = GetAncestors(); + for ( size_t iA = 0; iA < ancestors.size(); ++iA ) { - const TopoDS_Shape& ancestor = it.Value(); - if ( SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor)) - aSubMesh->ComputeStateEngine( theEvent ); + ancestors[ iA ]->ComputeStateEngine( theEvent ); } } @@ -2054,19 +2057,17 @@ void SMESH_subMesh::cleanDependants() { int dimToClean = SMESH_Gen::GetShapeDim( _subShape ) + 1; - TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); - for (; it.More(); it.Next()) + const std::vector< SMESH_subMesh * > & ancestors = GetAncestors(); + for ( size_t iA = 0; iA < ancestors.size(); ++iA ) { - const TopoDS_Shape& ancestor = it.Value(); - if ( SMESH_Gen::GetShapeDim( ancestor ) == dimToClean ) { + const TopoDS_Shape& ancestor = ancestors[ iA ]->GetSubShape(); + if ( SMESH_Gen::GetShapeDim( ancestor ) == dimToClean ) + { // PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEAN) // will erase mesh on other shapes in a compound - if ( ancestor.ShapeType() >= TopAbs_SOLID ) { - SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor); - if (aSubMesh && - !aSubMesh->IsEmpty() ) // prevent infinite CLEAN via event lesteners - aSubMesh->ComputeStateEngine(CLEAN); - } + if ( ancestor.ShapeType() >= TopAbs_SOLID && + !ancestors[ iA ]->IsEmpty() ) // prevent infinite CLEAN via event lesteners + ancestors[ iA ]->ComputeStateEngine(CLEAN); } } } @@ -2142,7 +2143,7 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * theGen, } else if ( subMesh->GetComputeState() == READY_TO_COMPUTE ) { - SMESH_Algo* anAlgo = theGen->GetAlgo( *_father, S ); + SMESH_Algo* anAlgo = theGen->GetAlgo( subMesh ); if (strcmp( anAlgo->GetName(), theAlgo->GetName()) == 0 && // same algo anAlgo->GetUsedHypothesis( *_father, S, ignoreAuxiliaryHyps ) == aUsedHyp) // same hyps aBuilder.Add( aCompound, S ); @@ -2576,6 +2577,44 @@ SMESH_subMeshIteratorPtr SMESH_subMesh::getDependsOnIterator(const bool includeS } } +//================================================================================ +/*! + * \brief Returns ancestor sub-meshes. Finds them if not yet found. + */ +//================================================================================ + +const std::vector< SMESH_subMesh * > & SMESH_subMesh::GetAncestors() const +{ + if ( _ancestors.empty() && + !_subShape.IsSame( _father->GetShapeToMesh() )) + { + const TopTools_ListOfShape& ancShapes = _father->GetAncestors( _subShape ); + + SMESH_subMesh* me = const_cast< SMESH_subMesh* >( this ); + me->_ancestors.reserve( ancShapes.Extent() ); + + TopTools_MapOfShape map; + + for ( TopTools_ListIteratorOfListOfShape it( ancShapes ); it.More(); it.Next() ) + if ( SMESH_subMesh* sm = _father->GetSubMeshContaining( it.Value() )) + if ( map.Add( it.Value() )) + me->_ancestors.push_back( sm ); + } + + return _ancestors; +} + +//================================================================================ +/*! + * \brief Clears the vector of ancestor sub-meshes + */ +//================================================================================ + +void SMESH_subMesh::ClearAncestors() +{ + _ancestors.clear(); +} + //================================================================================ /*! * \brief Find common submeshes (based on shared sub-shapes with other diff --git a/src/SMESH/SMESH_subMesh.hxx b/src/SMESH/SMESH_subMesh.hxx index 36a377400..59c700ec2 100644 --- a/src/SMESH/SMESH_subMesh.hxx +++ b/src/SMESH/SMESH_subMesh.hxx @@ -88,6 +88,9 @@ class SMESH_EXPORT SMESH_subMesh SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf, const bool complexShapeFirst=false) const; + const std::vector< SMESH_subMesh * > & GetAncestors() const; + void ClearAncestors(); + const TopoDS_Shape & GetSubShape() const; enum compute_state @@ -325,6 +328,7 @@ protected: std::map < int, SMESH_subMesh * >_mapDepend; bool _dependenceAnalysed; + std::vector< SMESH_subMesh * > _ancestors; SMESH_Algo * _algo; // the algorithm found by last *StateEngine() call algo_state _algoState; diff --git a/src/StdMeshers/StdMeshers_Propagation.cxx b/src/StdMeshers/StdMeshers_Propagation.cxx index dc71428c8..c56715d7e 100644 --- a/src/StdMeshers/StdMeshers_Propagation.cxx +++ b/src/StdMeshers/StdMeshers_Propagation.cxx @@ -209,23 +209,22 @@ namespace { /*! * \brief Returns a local 1D hypothesis used for theEdge */ - const SMESH_Hypothesis* getLocal1DHyp (SMESH_Mesh& theMesh, - const TopoDS_Shape& theEdge, + const SMESH_Hypothesis* getLocal1DHyp (SMESH_subMesh* theSubMesh, + //const TopoDS_Shape& theEdge, TopoDS_Shape* theSssignedTo=0) { static SMESH_HypoFilter hypo; hypo.Init( hypo.HasDim( 1 )). AndNot ( hypo.IsAlgo() ). - AndNot ( hypo.IsAssignedTo( theMesh.GetShapeToMesh() )); + AndNot ( hypo.IsAssignedTo( theSubMesh->GetFather()->GetShapeToMesh() )); - return theMesh.GetHypothesis( theEdge, hypo, true, theSssignedTo ); + return theSubMesh->GetFather()->GetHypothesis( theSubMesh, hypo, true, theSssignedTo ); } //============================================================================= /*! * \brief Returns a propagation hypothesis assigned to theEdge */ - const SMESH_Hypothesis* getProagationHyp (SMESH_Mesh& theMesh, - const TopoDS_Shape& theEdge) + const SMESH_Hypothesis* getProagationHyp (SMESH_subMesh* theSubMesh) { static SMESH_HypoFilter propagHypFilter; if ( propagHypFilter.IsEmpty() ) @@ -234,7 +233,7 @@ namespace { Init( SMESH_HypoFilter::HasName( StdMeshers_Propagation::GetName ())). Or ( SMESH_HypoFilter::HasName( StdMeshers_PropagOfDistribution::GetName ())); } - return theMesh.GetHypothesis( theEdge, propagHypFilter, true ); + return theSubMesh->GetFather()->GetHypothesis( theSubMesh, propagHypFilter, true ); } //================================================================================ /*! @@ -261,13 +260,13 @@ namespace { SMESH_Mesh* mesh = theMainSubMesh->GetFather(); TopoDS_Shape shapeOfHyp1D; // shape to which an hyp being propagated is assigned - const SMESH_Hypothesis* hyp1D = getLocal1DHyp( *mesh, theMainEdge, &shapeOfHyp1D ); + const SMESH_Hypothesis* hyp1D = getLocal1DHyp( theMainSubMesh, &shapeOfHyp1D ); SMESH_HypoFilter moreLocalCheck( SMESH_HypoFilter::IsMoreLocalThan( shapeOfHyp1D, *mesh )); PropagationMgrData* chainData = getData( theMainSubMesh ); chainData->SetState( HAS_PROPAG_HYP ); - if ( const SMESH_Hypothesis * propagHyp = getProagationHyp( *mesh, theMainEdge )) + if ( const SMESH_Hypothesis * propagHyp = getProagationHyp( theMainSubMesh )) chainData->myIsPropagOfDistribution = ( StdMeshers_PropagOfDistribution::GetName() == propagHyp->GetName() ); @@ -279,6 +278,8 @@ namespace { TopTools_MapOfShape checkedShapes; checkedShapes.Add( theMainEdge ); + vector edges; + list::iterator smIt = chain.begin(); for ( ; smIt != chain.end(); ++smIt ) { @@ -295,9 +296,8 @@ namespace { continue; // Get ordered edges and find index of anE in a sequence + edges.clear(); BRepTools_WireExplorer aWE (TopoDS::Wire(itA.Value())); - vector edges; - edges.reserve(4); int edgeIndex = 0; for (; aWE.More(); aWE.Next()) { TopoDS_Edge edge = aWE.Current(); @@ -361,7 +361,7 @@ namespace { if ( oppData->State() == WAIT_PROPAG_HYP ) // ... anOppE is not in any chain { oppData->SetSource( theMainSubMesh ); - if ( ! (hyp1D = getLocal1DHyp( *mesh, anOppE, &shapeOfHyp1D )) || //...no 1d hyp on anOppE + if ( ! (hyp1D = getLocal1DHyp( oppSM, &shapeOfHyp1D )) || //...no 1d hyp on anOppE ! (moreLocalCheck.IsOk( hyp1D, shapeOfHyp1D ))) // ... or hyp1D is "more global" { oppData->myForward = data->myForward; @@ -373,8 +373,8 @@ namespace { DBGMSG( "set IN_CHAIN on " << oppSM->GetId() ); if ( oppSM->GetAlgoState() != SMESH_subMesh::HYP_OK ) // make oppSM check algo state - if ( SMESH_Algo* algo = mesh->GetGen()->GetAlgo( *mesh, anOppE )) - oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO,algo); + if ( SMESH_Algo* algo = oppSM->GetAlgo() ) + oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO, algo); } else { oppData->SetState( LAST_IN_CHAIN ); @@ -490,7 +490,7 @@ namespace { submesh->SetEventListener( getListener(), data, submesh ); const SMESH_Hypothesis * propagHyp = - getProagationHyp( *submesh->GetFather(), submesh->GetSubShape() ); + getProagationHyp( submesh ); if ( propagHyp ) { data->myIsPropagOfDistribution = @@ -556,11 +556,10 @@ namespace { case WAIT_PROPAG_HYP: { // propagation hyp or local 1D hyp is missing // -------------------------------------------------------- - bool hasPropagHyp = ( isPropagHyp || - getProagationHyp( *subMesh->GetFather(), subMesh->GetSubShape()) ); + bool hasPropagHyp = ( isPropagHyp || getProagationHyp( subMesh )); if ( !hasPropagHyp ) return; - bool hasLocal1DHyp = getLocal1DHyp( *subMesh->GetFather(), subMesh->GetSubShape()); + bool hasLocal1DHyp = getLocal1DHyp( subMesh ); if ( !hasLocal1DHyp ) return; if ( event == SMESH_subMesh::ADD_HYP || @@ -577,7 +576,7 @@ namespace { switch ( event ) { case SMESH_subMesh::REMOVE_HYP: case SMESH_subMesh::REMOVE_FATHER_HYP: // remove propagation hyp - if ( isPropagHyp && !getProagationHyp( *subMesh->GetFather(), subMesh->GetSubShape()) ) + if ( isPropagHyp && !getProagationHyp( subMesh )) { DBGMSG( "REMOVE_HYP propagation from HAS_PROPAG_HYP " << subMesh->GetId() ); // clear propagation chain