52457: Addition of hypotheses is 8 time longer than meshing.

More optimization
This commit is contained in:
eap 2014-07-23 20:04:21 +04:00
parent 80a2161a03
commit f1013bf724
9 changed files with 630 additions and 529 deletions

View File

@ -657,15 +657,14 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
} }
else { else {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(4);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n3->getVtkId(); // order SMDS-->VTK
nodeIds.push_back(n3->getVtkId()); // order SMDS-->VTK myNodeIds[2] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[3] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -678,10 +677,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
myInfo.myNbTetras++; myInfo.myNbTetras++;
} }
// if (!registerElement(ID, volume)) { // if (!registerElement(ID, volume)) {
// RemoveElement(volume, false); // RemoveElement(volume, false);
// volume = NULL; // volume = NULL;
// } // }
return volume; return volume;
} }
@ -764,16 +763,15 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
} }
else { else {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(5);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[4] = n5->getVtkId();
nodeIds.push_back(n5->getVtkId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -786,10 +784,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
myInfo.myNbPyramids++; myInfo.myNbPyramids++;
} }
// if (!registerElement(ID, volume)) { // if (!registerElement(ID, volume)) {
// RemoveElement(volume, false); // RemoveElement(volume, false);
// volume = NULL; // volume = NULL;
// } // }
return volume; return volume;
} }
@ -877,17 +875,16 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
} }
else { else {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(6);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[4] = n5->getVtkId();
nodeIds.push_back(n5->getVtkId()); myNodeIds[5] = n6->getVtkId();
nodeIds.push_back(n6->getVtkId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -900,10 +897,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
myInfo.myNbPrisms++; myInfo.myNbPrisms++;
} }
// if (!registerElement(ID, volume)) { // if (!registerElement(ID, volume)) {
// RemoveElement(volume, false); // RemoveElement(volume, false);
// volume = NULL; // volume = NULL;
// } // }
return volume; return volume;
} }
@ -1006,23 +1003,22 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
} }
else { else {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[0] = n6->getVtkId();
nodeIds.push_back(n6->getVtkId()); myNodeIds[0] = n5->getVtkId();
nodeIds.push_back(n5->getVtkId()); myNodeIds[0] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[0] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[0] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId());
nodeIds.push_back(n7->getVtkId()); myNodeIds[0] = n7->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[0] = n12->getVtkId();
nodeIds.push_back(n11->getVtkId()); myNodeIds[0] = n11->getVtkId();
nodeIds.push_back(n10->getVtkId()); myNodeIds[0] = n10->getVtkId();
nodeIds.push_back(n9->getVtkId()); myNodeIds[0] = n9->getVtkId();
nodeIds.push_back(n8->getVtkId()); myNodeIds[0] = n8->getVtkId();
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -1133,19 +1129,18 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
} }
else { else {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(8);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[4] = n5->getVtkId();
nodeIds.push_back(n5->getVtkId()); myNodeIds[5] = n8->getVtkId();
nodeIds.push_back(n8->getVtkId()); myNodeIds[6] = n7->getVtkId();
nodeIds.push_back(n7->getVtkId()); myNodeIds[7] = n6->getVtkId();
nodeIds.push_back(n6->getVtkId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -1158,10 +1153,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
myInfo.myNbHexas++; myInfo.myNbHexas++;
} }
// if (!registerElement(ID, volume)) { // if (!registerElement(ID, volume)) {
// RemoveElement(volume, false); // RemoveElement(volume, false);
// volume = NULL; // volume = NULL;
// } // }
return volume; return volume;
} }
@ -1329,8 +1324,8 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID (const vector<int> & nodes_ids,
/// Add a polygon defined by its nodes /// Add a polygon defined by its nodes
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID SMDS_MeshFace*
(const vector<const SMDS_MeshNode*> & nodes, SMDS_Mesh::AddPolygonalFaceWithID (const vector<const SMDS_MeshNode*> & nodes,
const int ID) const int ID)
{ {
SMDS_MeshFace * face; SMDS_MeshFace * face;
@ -1343,16 +1338,14 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
} }
else else
{ {
//#ifdef VTK_HAVE_POLYHEDRON //#ifdef VTK_HAVE_POLYHEDRON
//MESSAGE("AddPolygonalFaceWithID vtk " << ID); //MESSAGE("AddPolygonalFaceWithID vtk " << ID);
vector<vtkIdType> nodeIds; myNodeIds.resize( nodes.size() );
nodeIds.clear(); for ( size_t i = 0; i < nodes.size(); ++i )
vector<const SMDS_MeshNode*>::const_iterator it = nodes.begin(); myNodeIds[i] = nodes[i]->getVtkId();
for ( ; it != nodes.end(); ++it)
nodeIds.push_back((*it)->getVtkId());
SMDS_VtkFace *facevtk = myFacePool->getNew(); SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->initPoly(nodeIds, this); facevtk->initPoly(myNodeIds, this);
if (!this->registerElement(ID,facevtk)) if (!this->registerElement(ID,facevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
@ -1360,25 +1353,25 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
return 0; return 0;
} }
face = facevtk; face = facevtk;
//#else //#else
// MESSAGE("AddPolygonalFaceWithID smds " << ID); // MESSAGE("AddPolygonalFaceWithID smds " << ID);
// for ( int i = 0; i < nodes.size(); ++i ) // for ( int i = 0; i < nodes.size(); ++i )
// if ( !nodes[ i ] ) return 0; // if ( !nodes[ i ] ) return 0;
// face = new SMDS_PolygonalFaceOfNodes(nodes); // face = new SMDS_PolygonalFaceOfNodes(nodes);
//#endif //#endif
adjustmyCellsCapacity(ID); adjustmyCellsCapacity(ID);
myCells[ID] = face; myCells[ID] = face;
myInfo.myNbPolygons++; myInfo.myNbPolygons++;
} }
//#ifndef VTK_HAVE_POLYHEDRON //#ifndef VTK_HAVE_POLYHEDRON
// if (!registerElement(ID, face)) // if (!registerElement(ID, face))
// { // {
// registerElement(myElementIDFactory->GetFreeID(), face); // registerElement(myElementIDFactory->GetFreeID(), face);
// //RemoveElement(face, false); // //RemoveElement(face, false);
// //face = NULL; // //face = NULL;
// } // }
//#endif //#endif
return face; return face;
} }
@ -1419,8 +1412,8 @@ SMDS_MeshVolume * SMDS_Mesh::AddPolyhedralVolumeWithID
/// @return The created volume /// @return The created volume
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID SMDS_MeshVolume*
(const vector<const SMDS_MeshNode*>& nodes, SMDS_Mesh::AddPolyhedralVolumeWithID (const vector<const SMDS_MeshNode*>& nodes,
const vector<int> & quantities, const vector<int> & quantities,
const int ID) const int ID)
{ {
@ -1440,16 +1433,14 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID
} }
else else
{ {
//#ifdef VTK_HAVE_POLYHEDRON //#ifdef VTK_HAVE_POLYHEDRON
//MESSAGE("AddPolyhedralVolumeWithID vtk " << ID); //MESSAGE("AddPolyhedralVolumeWithID vtk " << ID);
vector<vtkIdType> nodeIds; myNodeIds.resize( nodes.size() );
nodeIds.clear(); for ( size_t i = 0; i < nodes.size(); ++i )
vector<const SMDS_MeshNode*>::const_iterator it = nodes.begin(); myNodeIds[i] = nodes[i]->getVtkId();
for (; it != nodes.end(); ++it)
nodeIds.push_back((*it)->getVtkId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->initPoly(nodeIds, quantities, this); volvtk->initPoly(myNodeIds, quantities, this);
if (!this->registerElement(ID, volvtk)) if (!this->registerElement(ID, volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -1457,25 +1448,25 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID
return 0; return 0;
} }
volume = volvtk; volume = volvtk;
//#else //#else
// MESSAGE("AddPolyhedralVolumeWithID smds " << ID); // MESSAGE("AddPolyhedralVolumeWithID smds " << ID);
// for ( int i = 0; i < nodes.size(); ++i ) // for ( int i = 0; i < nodes.size(); ++i )
// if ( !nodes[ i ] ) return 0; // if ( !nodes[ i ] ) return 0;
// volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities); // volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities);
//#endif //#endif
adjustmyCellsCapacity(ID); adjustmyCellsCapacity(ID);
myCells[ID] = volume; myCells[ID] = volume;
myInfo.myNbPolyhedrons++; myInfo.myNbPolyhedrons++;
} }
//#ifndef VTK_HAVE_POLYHEDRON //#ifndef VTK_HAVE_POLYHEDRON
// if (!registerElement(ID, volume)) // if (!registerElement(ID, volume))
// { // {
// registerElement(myElementIDFactory->GetFreeID(), volume); // registerElement(myElementIDFactory->GetFreeID(), volume);
// //RemoveElement(volume, false); // //RemoveElement(volume, false);
// //volume = NULL; // //volume = NULL;
// } // }
//#endif //#endif
return volume; return volume;
} }
@ -1705,15 +1696,14 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1,
else else
{ {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(3);
nodeIds.clear(); myNodeIds[0] = node1->getVtkId();
nodeIds.push_back(node1->getVtkId()); myNodeIds[1] = node2->getVtkId();
nodeIds.push_back(node2->getVtkId()); myNodeIds[2] = node3->getVtkId();
nodeIds.push_back(node3->getVtkId());
SMDS_MeshFace * face = 0; SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew(); SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this); // put in vtkUnstructuredGrid facevtk->init(myNodeIds, this); // put in vtkUnstructuredGrid
if (!this->registerElement(ID,facevtk)) if (!this->registerElement(ID,facevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
@ -1759,16 +1749,15 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1,
else else
{ {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(4);
nodeIds.clear(); myNodeIds[0] = node1->getVtkId();
nodeIds.push_back(node1->getVtkId()); myNodeIds[1] = node2->getVtkId();
nodeIds.push_back(node2->getVtkId()); myNodeIds[2] = node3->getVtkId();
nodeIds.push_back(node3->getVtkId()); myNodeIds[3] = node4->getVtkId();
nodeIds.push_back(node4->getVtkId());
SMDS_MeshFace * face = 0; SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew(); SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this); facevtk->init(myNodeIds, this);
if (!this->registerElement(ID,facevtk)) if (!this->registerElement(ID,facevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
@ -2094,13 +2083,12 @@ SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1,
if ( NbEdges() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if ( NbEdges() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
int ID = myElementIDFactory->GetFreeID(); // -PR- voir si on range cet element int ID = myElementIDFactory->GetFreeID(); // -PR- voir si on range cet element
adjustmyCellsCapacity(ID); adjustmyCellsCapacity(ID);
vector<vtkIdType> nodeIds; myNodeIds.resize(2);
nodeIds.clear(); myNodeIds[0] = node1->getVtkId();
nodeIds.push_back(node1->getVtkId()); myNodeIds[1] = node2->getVtkId();
nodeIds.push_back(node2->getVtkId());
SMDS_VtkEdge *edgevtk = myEdgePool->getNew(); SMDS_VtkEdge *edgevtk = myEdgePool->getNew();
edgevtk->init(nodeIds, this); edgevtk->init(myNodeIds, this);
if (!this->registerElement(ID,edgevtk)) if (!this->registerElement(ID,edgevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL);
@ -3591,15 +3579,14 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
if ( !n1 || !n2 || !n12 ) return 0; if ( !n1 || !n2 || !n12 ) return 0;
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(3);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[2] = n12->getVtkId();
nodeIds.push_back(n12->getVtkId());
SMDS_MeshEdge * edge = 0; SMDS_MeshEdge * edge = 0;
SMDS_VtkEdge *edgevtk = myEdgePool->getNew(); SMDS_VtkEdge *edgevtk = myEdgePool->getNew();
edgevtk->init(nodeIds, this); edgevtk->init(myNodeIds, this);
if (!this->registerElement(ID,edgevtk)) if (!this->registerElement(ID,edgevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL);
@ -3611,10 +3598,10 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
myCells[ID] = edge; myCells[ID] = edge;
myInfo.myNbQuadEdges++; myInfo.myNbQuadEdges++;
// if (!registerElement(ID, edge)) { // if (!registerElement(ID, edge)) {
// RemoveElement(edge, false); // RemoveElement(edge, false);
// edge = NULL; // edge = NULL;
// } // }
return edge; return edge;
} }
@ -3672,18 +3659,17 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
else else
{ {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(6);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n12->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[4] = n23->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[5] = n31->getVtkId();
nodeIds.push_back(n31->getVtkId());
SMDS_MeshFace * face = 0; SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew(); SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this); facevtk->init(myNodeIds, this);
if (!this->registerElement(ID,facevtk)) if (!this->registerElement(ID,facevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
@ -3695,10 +3681,10 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
myCells[ID] = face; myCells[ID] = face;
myInfo.myNbQuadTriangles++; myInfo.myNbQuadTriangles++;
// if (!registerElement(ID, face)) { // if (!registerElement(ID, face)) {
// RemoveElement(face, false); // RemoveElement(face, false);
// face = NULL; // face = NULL;
// } // }
return face; return face;
} }
} }
@ -3759,19 +3745,18 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
else else
{ {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(7);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n12->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[4] = n23->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[5] = n31->getVtkId();
nodeIds.push_back(n31->getVtkId()); myNodeIds[6] = nCenter->getVtkId();
nodeIds.push_back(nCenter->getVtkId());
SMDS_MeshFace * face = 0; SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew(); SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this); facevtk->init(myNodeIds, this);
if (!this->registerElement(ID,facevtk)) if (!this->registerElement(ID,facevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
@ -3783,10 +3768,10 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
myCells[ID] = face; myCells[ID] = face;
myInfo.myNbBiQuadTriangles++; myInfo.myNbBiQuadTriangles++;
// if (!registerElement(ID, face)) { // if (!registerElement(ID, face)) {
// RemoveElement(face, false); // RemoveElement(face, false);
// face = NULL; // face = NULL;
// } // }
return face; return face;
} }
} }
@ -3850,20 +3835,19 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
else else
{ {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(8);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[4] = n12->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[5] = n23->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[6] = n34->getVtkId();
nodeIds.push_back(n34->getVtkId()); myNodeIds[7] = n41->getVtkId();
nodeIds.push_back(n41->getVtkId());
SMDS_MeshFace * face = 0; SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew(); SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this); facevtk->init(myNodeIds, this);
if (!this->registerElement(ID,facevtk)) if (!this->registerElement(ID,facevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
@ -3875,10 +3859,10 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
myCells[ID] = face; myCells[ID] = face;
myInfo.myNbQuadQuadrangles++; myInfo.myNbQuadQuadrangles++;
// if (!registerElement(ID, face)) { // if (!registerElement(ID, face)) {
// RemoveElement(face, false); // RemoveElement(face, false);
// face = NULL; // face = NULL;
// } // }
return face; return face;
} }
} }
@ -3944,21 +3928,20 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
else else
{ {
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(9);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[4] = n12->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[5] = n23->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[6] = n34->getVtkId();
nodeIds.push_back(n34->getVtkId()); myNodeIds[7] = n41->getVtkId();
nodeIds.push_back(n41->getVtkId()); myNodeIds[8] = nCenter->getVtkId();
nodeIds.push_back(nCenter->getVtkId());
SMDS_MeshFace * face = 0; SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew(); SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this); facevtk->init(myNodeIds, this);
if (!this->registerElement(ID,facevtk)) if (!this->registerElement(ID,facevtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
@ -3970,10 +3953,10 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
myCells[ID] = face; myCells[ID] = face;
myInfo.myNbBiQuadQuadrangles++; myInfo.myNbBiQuadQuadrangles++;
// if (!registerElement(ID, face)) { // if (!registerElement(ID, face)) {
// RemoveElement(face, false); // RemoveElement(face, false);
// face = NULL; // face = NULL;
// } // }
return face; return face;
} }
} }
@ -4046,23 +4029,22 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
return 0; return 0;
} }
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(10);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[2] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[3] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId());
nodeIds.push_back(n31->getVtkId()); myNodeIds[4] = n31->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[5] = n23->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[6] = n12->getVtkId();
nodeIds.push_back(n14->getVtkId()); myNodeIds[7] = n14->getVtkId();
nodeIds.push_back(n34->getVtkId()); myNodeIds[8] = n34->getVtkId();
nodeIds.push_back(n24->getVtkId()); myNodeIds[9] = n24->getVtkId();
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -4073,10 +4055,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
myCells[ID] = volvtk; myCells[ID] = volvtk;
myInfo.myNbQuadTetras++; myInfo.myNbQuadTetras++;
// if (!registerElement(ID, volvtk)) { // if (!registerElement(ID, volvtk)) {
// RemoveElement(volvtk, false); // RemoveElement(volvtk, false);
// volvtk = NULL; // volvtk = NULL;
// } // }
return volvtk; return volvtk;
} }
@ -4159,26 +4141,25 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
return 0; return 0;
} }
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(13);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[4] = n5->getVtkId();
nodeIds.push_back(n5->getVtkId());
nodeIds.push_back(n41->getVtkId()); myNodeIds[5] = n41->getVtkId();
nodeIds.push_back(n34->getVtkId()); myNodeIds[6] = n34->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[7] = n23->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[8] = n12->getVtkId();
nodeIds.push_back(n15->getVtkId()); myNodeIds[9] = n15->getVtkId();
nodeIds.push_back(n45->getVtkId()); myNodeIds[10] = n45->getVtkId();
nodeIds.push_back(n35->getVtkId()); myNodeIds[11] = n35->getVtkId();
nodeIds.push_back(n25->getVtkId()); myNodeIds[12] = n25->getVtkId();
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -4189,10 +4170,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
myCells[ID] = volvtk; myCells[ID] = volvtk;
myInfo.myNbQuadPyramids++; myInfo.myNbQuadPyramids++;
// if (!registerElement(ID, volvtk)) { // if (!registerElement(ID, volvtk)) {
// RemoveElement(volvtk, false); // RemoveElement(volvtk, false);
// volvtk = NULL; // volvtk = NULL;
// } // }
return volvtk; return volvtk;
} }
@ -4283,30 +4264,29 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
return 0; return 0;
} }
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(15);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId());
nodeIds.push_back(n4->getVtkId()); myNodeIds[3] = n4->getVtkId();
nodeIds.push_back(n5->getVtkId()); myNodeIds[4] = n5->getVtkId();
nodeIds.push_back(n6->getVtkId()); myNodeIds[5] = n6->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[6] = n12->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[7] = n23->getVtkId();
nodeIds.push_back(n31->getVtkId()); myNodeIds[8] = n31->getVtkId();
nodeIds.push_back(n45->getVtkId()); myNodeIds[9] = n45->getVtkId();
nodeIds.push_back(n56->getVtkId()); myNodeIds[10] = n56->getVtkId();
nodeIds.push_back(n64->getVtkId()); myNodeIds[11] = n64->getVtkId();
nodeIds.push_back(n14->getVtkId()); myNodeIds[12] = n14->getVtkId();
nodeIds.push_back(n25->getVtkId()); myNodeIds[13] = n25->getVtkId();
nodeIds.push_back(n36->getVtkId()); myNodeIds[14] = n36->getVtkId();
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -4317,10 +4297,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
myCells[ID] = volvtk; myCells[ID] = volvtk;
myInfo.myNbQuadPrisms++; myInfo.myNbQuadPrisms++;
// if (!registerElement(ID, volvtk)) { // if (!registerElement(ID, volvtk)) {
// RemoveElement(volvtk, false); // RemoveElement(volvtk, false);
// volvtk = NULL; // volvtk = NULL;
// } // }
return volvtk; return volvtk;
} }
@ -4426,35 +4406,34 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
// creation quadratic faces - not implemented // creation quadratic faces - not implemented
} }
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(20);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId());
nodeIds.push_back(n5->getVtkId()); myNodeIds[4] = n5->getVtkId();
nodeIds.push_back(n8->getVtkId()); myNodeIds[5] = n8->getVtkId();
nodeIds.push_back(n7->getVtkId()); myNodeIds[6] = n7->getVtkId();
nodeIds.push_back(n6->getVtkId()); myNodeIds[7] = n6->getVtkId();
nodeIds.push_back(n41->getVtkId()); myNodeIds[8] = n41->getVtkId();
nodeIds.push_back(n34->getVtkId()); myNodeIds[9] = n34->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[10] = n23->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[11] = n12->getVtkId();
nodeIds.push_back(n85->getVtkId()); myNodeIds[12] = n85->getVtkId();
nodeIds.push_back(n78->getVtkId()); myNodeIds[13] = n78->getVtkId();
nodeIds.push_back(n67->getVtkId()); myNodeIds[14] = n67->getVtkId();
nodeIds.push_back(n56->getVtkId()); myNodeIds[15] = n56->getVtkId();
nodeIds.push_back(n15->getVtkId()); myNodeIds[16] = n15->getVtkId();
nodeIds.push_back(n48->getVtkId()); myNodeIds[17] = n48->getVtkId();
nodeIds.push_back(n37->getVtkId()); myNodeIds[18] = n37->getVtkId();
nodeIds.push_back(n26->getVtkId()); myNodeIds[19] = n26->getVtkId();
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -4465,10 +4444,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
myCells[ID] = volvtk; myCells[ID] = volvtk;
myInfo.myNbQuadHexas++; myInfo.myNbQuadHexas++;
// if (!registerElement(ID, volvtk)) { // if (!registerElement(ID, volvtk)) {
// RemoveElement(volvtk, false); // RemoveElement(volvtk, false);
// volvtk = NULL; // volvtk = NULL;
// } // }
return volvtk; return volvtk;
} }
@ -4599,43 +4578,42 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
// creation quadratic faces - not implemented // creation quadratic faces - not implemented
} }
// --- retrieve nodes ID // --- retrieve nodes ID
vector<vtkIdType> nodeIds; myNodeIds.resize(27);
nodeIds.clear(); myNodeIds[0] = n1->getVtkId();
nodeIds.push_back(n1->getVtkId()); myNodeIds[1] = n4->getVtkId();
nodeIds.push_back(n4->getVtkId()); myNodeIds[2] = n3->getVtkId();
nodeIds.push_back(n3->getVtkId()); myNodeIds[3] = n2->getVtkId();
nodeIds.push_back(n2->getVtkId());
nodeIds.push_back(n5->getVtkId()); myNodeIds[4] = n5->getVtkId();
nodeIds.push_back(n8->getVtkId()); myNodeIds[5] = n8->getVtkId();
nodeIds.push_back(n7->getVtkId()); myNodeIds[6] = n7->getVtkId();
nodeIds.push_back(n6->getVtkId()); myNodeIds[7] = n6->getVtkId();
nodeIds.push_back(n41->getVtkId()); myNodeIds[8] = n41->getVtkId();
nodeIds.push_back(n34->getVtkId()); myNodeIds[9] = n34->getVtkId();
nodeIds.push_back(n23->getVtkId()); myNodeIds[10] = n23->getVtkId();
nodeIds.push_back(n12->getVtkId()); myNodeIds[11] = n12->getVtkId();
nodeIds.push_back(n85->getVtkId()); myNodeIds[12] = n85->getVtkId();
nodeIds.push_back(n78->getVtkId()); myNodeIds[13] = n78->getVtkId();
nodeIds.push_back(n67->getVtkId()); myNodeIds[14] = n67->getVtkId();
nodeIds.push_back(n56->getVtkId()); myNodeIds[15] = n56->getVtkId();
nodeIds.push_back(n15->getVtkId()); myNodeIds[16] = n15->getVtkId();
nodeIds.push_back(n48->getVtkId()); myNodeIds[17] = n48->getVtkId();
nodeIds.push_back(n37->getVtkId()); myNodeIds[18] = n37->getVtkId();
nodeIds.push_back(n26->getVtkId()); myNodeIds[19] = n26->getVtkId();
nodeIds.push_back(n1256->getVtkId()); myNodeIds[20] = n1256->getVtkId();
nodeIds.push_back(n3478->getVtkId()); myNodeIds[21] = n3478->getVtkId();
nodeIds.push_back(n1458->getVtkId()); myNodeIds[22] = n1458->getVtkId();
nodeIds.push_back(n2367->getVtkId()); myNodeIds[23] = n2367->getVtkId();
nodeIds.push_back(n1234->getVtkId()); myNodeIds[24] = n1234->getVtkId();
nodeIds.push_back(n5678->getVtkId()); myNodeIds[25] = n5678->getVtkId();
nodeIds.push_back(nCenter->getVtkId()); myNodeIds[26] = nCenter->getVtkId();
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this); volvtk->init(myNodeIds, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID,volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);

View File

@ -818,8 +818,8 @@ protected:
//! SMDS_MeshCells refer to vtk cells (vtk id != index in myCells),store reference to this mesh, and sub-shape //! SMDS_MeshCells refer to vtk cells (vtk id != index in myCells),store reference to this mesh, and sub-shape
SetOfCells myCells; SetOfCells myCells;
//! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid //! a buffer to speed up elements addition by excluding some memory allocation
//std::vector<int> myCellIdSmdsToVtk; std::vector<vtkIdType> myNodeIds;
//! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users //! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users
std::vector<int> myCellIdVtkToSmds; std::vector<int> myCellIdVtkToSmds;

View File

@ -232,7 +232,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
if ( aShapesId && aShapeDim > (int)aDim ) if ( aShapesId && aShapeDim > (int)aDim )
continue; continue;
SMESH_Algo* algo = GetAlgo( aMesh, aSubShape, &algoShape ); SMESH_Algo* algo = GetAlgo( smToCompute, &algoShape );
if ( algo && !algo->NeedDiscreteBoundary() ) if ( algo && !algo->NeedDiscreteBoundary() )
{ {
if ( algo->SupportSubmeshes() ) if ( algo->SupportSubmeshes() )
@ -308,7 +308,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
sm = smVec[i]; sm = smVec[i];
// get a shape the algo is assigned to // get a shape the algo is assigned to
if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape )) if ( !GetAlgo( sm, & algoShape ))
continue; // strange... continue; // strange...
// look for more local algos // look for more local algos
@ -331,7 +331,8 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
.And( SMESH_HypoFilter::IsApplicableTo( aSubShape )) .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
.And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh )); .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; if ( ! subAlgo->NeedDiscreteBoundary() ) continue;
SMESH_Hypothesis::Hypothesis_Status status; SMESH_Hypothesis::Hypothesis_Status status;
if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status )) if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
@ -477,7 +478,7 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
const int aShapeDim = GetShapeDim( aSubShape ); const int aShapeDim = GetShapeDim( aSubShape );
if ( aShapeDim < 1 ) break; if ( aShapeDim < 1 ) break;
SMESH_Algo* algo = GetAlgo( aMesh, aSubShape ); SMESH_Algo* algo = GetAlgo( smToCompute );
if ( algo && !algo->NeedDiscreteBoundary() ) { if ( algo && !algo->NeedDiscreteBoundary() ) {
if ( algo->SupportSubmeshes() ) { if ( algo->SupportSubmeshes() ) {
smWithAlgoSupportingSubmeshes.push_front( smToCompute ); smWithAlgoSupportingSubmeshes.push_front( smToCompute );
@ -508,7 +509,7 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
// get a shape the algo is assigned to // get a shape the algo is assigned to
TopoDS_Shape algoShape; TopoDS_Shape algoShape;
if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape )) if ( !GetAlgo( sm, & algoShape ))
continue; // strange... continue; // strange...
// look for more local algos // look for more local algos
@ -525,7 +526,8 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
.And( SMESH_HypoFilter::IsApplicableTo( aSubShape )) .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
.And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh )); .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; if ( ! subAlgo->NeedDiscreteBoundary() ) continue;
SMESH_Hypothesis::Hypothesis_Status status; SMESH_Hypothesis::Hypothesis_Status status;
if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status )) if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
@ -1013,6 +1015,23 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape, const TopoDS_Shape & aShape,
TopoDS_Shape* assignedTo) 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() ); SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
filter.And( filter.IsApplicableTo( aShape )); filter.And( filter.IsApplicableTo( aShape ));
@ -1020,7 +1039,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
TopoDS_Shape assignedToShape; TopoDS_Shape assignedToShape;
SMESH_Algo* algo = SMESH_Algo* algo =
(SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, &assignedToShape ); (SMESH_Algo*) aMesh.GetHypothesis( aSubMesh, filter, true, &assignedToShape );
if ( algo && if ( algo &&
aShape.ShapeType() == TopAbs_FACE && aShape.ShapeType() == TopAbs_FACE &&
@ -1035,7 +1054,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
filter.AndNot( filter.Is( algo )); filter.AndNot( filter.Is( algo ));
TopoDS_Shape assignedToShape2; TopoDS_Shape assignedToShape2;
SMESH_Algo* algo2 = SMESH_Algo* algo2 =
(SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, &assignedToShape2 ); (SMESH_Algo*) aMesh.GetHypothesis( aSubMesh, filter, true, &assignedToShape2 );
if ( algo2 && // algo found if ( algo2 && // algo found
!assignedToShape2.IsSame( aMesh.GetShapeToMesh() ) && // algo is local !assignedToShape2.IsSame( aMesh.GetShapeToMesh() ) && // algo is local
( SMESH_MesherHelper::GetGroupType( assignedToShape2 ) == // algo of the same level ( SMESH_MesherHelper::GetGroupType( assignedToShape2 ) == // algo of the same level

View File

@ -147,6 +147,7 @@ public:
{ return GetShapeDim( aShape.ShapeType() ); } { return GetShapeDim( aShape.ShapeType() ); }
SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0); 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); static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh);

View File

@ -773,7 +773,30 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS
const bool andAncestors, const bool andAncestors,
TopoDS_Shape* assignedTo) const 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<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape); const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin(); list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
for ( ; hyp != hypList.end(); hyp++ ) { for ( ; hyp != hypList.end(); hyp++ ) {
@ -787,9 +810,12 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS
if ( andAncestors ) if ( andAncestors )
{ {
// user sorted submeshes of ancestors, according to stored submesh priority // user sorted submeshes of ancestors, according to stored submesh priority
getAncestorsSubMeshes( aSubShape, _ancestorSubMeshes ); std::vector< SMESH_subMesh * > & ancestors =
vector<SMESH_subMesh*>::const_iterator smIt = _ancestorSubMeshes.begin(); const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() );
for ( ; smIt != _ancestorSubMeshes.end(); smIt++ ) SortByMeshOrder( ancestors );
vector<SMESH_subMesh*>::const_iterator smIt = ancestors.begin();
for ( ; smIt != ancestors.end(); smIt++ )
{ {
const TopoDS_Shape& curSh = (*smIt)->GetSubShape(); const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(curSh); const list<const SMESHDS_Hypothesis*>& 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 aSubShape - the shape to check
* \param aFilter - the hypothesis filter * \param aFilter - the hypothesis filter
* \param aHypList - the list of the found hypotheses * \param aHypList - the list of the found hypotheses
@ -823,6 +849,29 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
const bool andAncestors, const bool andAncestors,
list< TopoDS_Shape > * assignedTo/*=0*/) const 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 <const SMESHDS_Hypothesis * >& aHypList,
const bool andAncestors,
list< TopoDS_Shape > * assignedTo/*=0*/) const
{
if ( !aSubMesh ) return 0;
set<string> hypTypes; // to exclude same type hypos from the result list set<string> hypTypes; // to exclude same type hypos from the result list
int nbHyps = 0; int nbHyps = 0;
@ -840,6 +889,7 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
// get hypos from aSubShape // get hypos from aSubShape
{ {
const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape); const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ ) for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) && 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 // get hypos from ancestors of aSubShape
if ( andAncestors ) if ( andAncestors )
{ {
TopTools_MapOfShape map;
// user sorted submeshes of ancestors, according to stored submesh priority // user sorted submeshes of ancestors, according to stored submesh priority
getAncestorsSubMeshes( aSubShape, _ancestorSubMeshes ); std::vector< SMESH_subMesh * > & ancestors =
vector<SMESH_subMesh*>::const_iterator smIt = _ancestorSubMeshes.begin(); const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() );
for ( ; smIt != _ancestorSubMeshes.end(); smIt++ ) SortByMeshOrder( ancestors );
vector<SMESH_subMesh*>::const_iterator smIt = ancestors.begin();
for ( ; smIt != ancestors.end(); smIt++ )
{ {
const TopoDS_Shape& curSh = (*smIt)->GetSubShape(); const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
if ( !map.Add( curSh ))
continue;
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(curSh); const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(curSh);
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ ) for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
if (( aFilter.IsOk( cSMESH_Hyp( *hyp ), curSh )) && if (( aFilter.IsOk( cSMESH_Hyp( *hyp ), curSh )) &&
@ -1047,9 +1096,7 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp )) if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
return false; return false;
const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape(); SMESH_Algo *algo = aSubMesh->GetAlgo();
SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
// algorithm // algorithm
if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO) if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
@ -1062,7 +1109,7 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
const SMESH_HypoFilter* hypoKind; const SMESH_HypoFilter* hypoKind;
if (( hypoKind = algo->GetCompatibleHypoFilter( !hyp->IsAuxiliary() ))) { if (( hypoKind = algo->GetCompatibleHypoFilter( !hyp->IsAuxiliary() ))) {
list <const SMESHDS_Hypothesis * > usedHyps; list <const SMESHDS_Hypothesis * > usedHyps;
if ( GetHypotheses( aSubShape, *hypoKind, usedHyps, true )) if ( GetHypotheses( aSubMesh, *hypoKind, usedHyps, true ))
return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() ); 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 // check if hyp is used by algo
usedHyps.clear(); usedHyps.clear();
if ( GetHypotheses( aSubShape, *compatibleHypoKind, usedHyps, true ) && if ( GetHypotheses( aSubMesh, *compatibleHypoKind, usedHyps, true ) &&
find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() ) find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
{ {
aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP, 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 ) while ( ancIt.More() && ancIt.Value().ShapeType() >= memberType )
ancIt.Next(); ancIt.Next();
if ( ancIt.More() ) if ( ancIt.More() )
{
ancList.InsertBefore( theShape, ancIt ); ancList.InsertBefore( theShape, ancIt );
GetSubMesh( des.Current() )->ClearAncestors(); // to re-fill _ancestors
}
} }
} }
{ {

View File

@ -148,6 +148,17 @@ public:
const bool andAncestors, const bool andAncestors,
std::list< TopoDS_Shape > * assignedTo=0) const; 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; SMESH_Hypothesis * GetHypothesis(const int aHypID) const;
const std::list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception); const std::list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);

View File

@ -47,13 +47,14 @@
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx> #include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Compound.hxx> #include <TopoDS_Compound.hxx>
#include <gp_Pnt.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx> #include <TopoDS_Iterator.hxx>
#include <gp_Pnt.hxx>
#include <Standard_OutOfMemory.hxx> #include <Standard_OutOfMemory.hxx>
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
@ -195,7 +196,10 @@ SMESH_subMesh *SMESH_subMesh::GetFirstToCompute()
SMESH_Algo* SMESH_subMesh::GetAlgo() const SMESH_Algo* SMESH_subMesh::GetAlgo() const
{ {
if ( !_algo ) 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; return _algo;
} }
@ -735,7 +739,7 @@ SMESH_Hypothesis::Hypothesis_Status
SMESH_HypoFilter filter( SMESH_HypoFilter::HasType( algo->GetType() )); SMESH_HypoFilter filter( SMESH_HypoFilter::HasType( algo->GetType() ));
filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+1 )); filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+1 ));
filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+2 )); 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() ) if ( !curAlgo->NeedDiscreteBoundary() )
algoRequiringCleaning = curAlgo; algoRequiringCleaning = curAlgo;
} }
@ -964,7 +968,7 @@ SMESH_Hypothesis::Hypothesis_Status
f.Init( SMESH_HypoFilter::IsAlgo() ); f.Init( SMESH_HypoFilter::IsAlgo() );
f.And( SMESH_HypoFilter::IsApplicableTo( _subShape )); f.And( SMESH_HypoFilter::IsApplicableTo( _subShape ));
f.AndNot( SMESH_HypoFilter::Is( algo )); 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 && if (prevAlgo &&
string(algo->GetName()) != string(prevAlgo->GetName()) ) string(algo->GetName()) != string(prevAlgo->GetName()) )
modifiedHyp = true; modifiedHyp = true;
@ -1023,7 +1027,7 @@ SMESH_Hypothesis::Hypothesis_Status
f.Init( SMESH_HypoFilter::IsAlgo() ); f.Init( SMESH_HypoFilter::IsAlgo() );
f.And( SMESH_HypoFilter::IsApplicableTo( _subShape )); f.And( SMESH_HypoFilter::IsApplicableTo( _subShape ));
f.AndNot( SMESH_HypoFilter::Is( algo )); 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 && if (prevAlgo &&
string(algo->GetName()) != string(prevAlgo->GetName()) ) string(algo->GetName()) != string(prevAlgo->GetName()) )
modifiedHyp = true; modifiedHyp = true;
@ -1089,21 +1093,22 @@ SMESH_Hypothesis::Hypothesis_Status
{ {
// is algo hidden? // is algo hidden?
SMESH_Gen* gen = _father->GetGen(); SMESH_Gen* gen = _father->GetGen();
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); const std::vector< SMESH_subMesh * > & ancestors = GetAncestors();
for ( ; ( ret == SMESH_Hypothesis::HYP_OK && it.More()); it.Next() ) { for ( size_t iA = 0; ( ret == SMESH_Hypothesis::HYP_OK && iA < ancestors.size()); ++iA ) {
if ( SMESH_Algo* upperAlgo = gen->GetAlgo( *_father, it.Value() )) if ( SMESH_Algo* upperAlgo = ancestors[ iA ]->GetAlgo() )
if ( !upperAlgo->NeedDiscreteBoundary() && !upperAlgo->SupportSubmeshes()) if ( !upperAlgo->NeedDiscreteBoundary() && !upperAlgo->SupportSubmeshes())
ret = SMESH_Hypothesis::HYP_HIDDEN_ALGO; ret = SMESH_Hypothesis::HYP_HIDDEN_ALGO;
} }
// is algo hiding? // is algo hiding?
if ( ret == SMESH_Hypothesis::HYP_OK && if ( ret == SMESH_Hypothesis::HYP_OK &&
!algo->NeedDiscreteBoundary() && !algo->NeedDiscreteBoundary() &&
!algo->SupportSubmeshes()) { !algo->SupportSubmeshes())
{
TopoDS_Shape algoAssignedTo, otherAssignedTo; TopoDS_Shape algoAssignedTo, otherAssignedTo;
gen->GetAlgo( *_father, _subShape, &algoAssignedTo ); gen->GetAlgo( this, &algoAssignedTo );
map<int, SMESH_subMesh*>::reverse_iterator i_sm = _mapDepend.rbegin(); map<int, SMESH_subMesh*>::reverse_iterator i_sm = _mapDepend.rbegin();
for ( ; ( ret == SMESH_Hypothesis::HYP_OK && i_sm != _mapDepend.rend()) ; ++i_sm ) 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 )) SMESH_MesherHelper::IsSubShape( /*sub=*/otherAssignedTo, /*main=*/algoAssignedTo ))
ret = SMESH_Hypothesis::HYP_HIDING_ALGO; ret = SMESH_Hypothesis::HYP_HIDING_ALGO;
} }
@ -1177,16 +1182,16 @@ bool SMESH_subMesh::IsConform(const SMESH_Algo* theAlgo)
for (; itsub.More(); itsub.Next()) for (; itsub.More(); itsub.Next())
{ {
// loop on adjacent subShapes // loop on adjacent subShapes
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( itsub.Value() )); const std::vector< SMESH_subMesh * > & ancestors = GetAncestors();
for (; it.More(); it.Next()) 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 ( _subShape.IsSame( adjacent )) continue;
if ( adjacent.ShapeType() != _subShape.ShapeType()) if ( adjacent.ShapeType() != _subShape.ShapeType())
break; break;
// check algo attached to smAdjacent // check algo attached to smAdjacent
SMESH_Algo * algo = gen->GetAlgo((*_father), adjacent); SMESH_Algo * algo = ancestors[ iA ]->GetAlgo();
if (algo && if (algo &&
!algo->NeedDiscreteBoundary() && !algo->NeedDiscreteBoundary() &&
algo->OnlyUnaryInput()) algo->OnlyUnaryInput())
@ -2035,12 +2040,10 @@ void SMESH_subMesh::ComputeSubMeshStateEngine(int event, const bool includeSelf)
void SMESH_subMesh::updateDependantsState(const compute_event theEvent) void SMESH_subMesh::updateDependantsState(const compute_event theEvent)
{ {
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); const std::vector< SMESH_subMesh * > & ancestors = GetAncestors();
for (; it.More(); it.Next()) for ( size_t iA = 0; iA < ancestors.size(); ++iA )
{ {
const TopoDS_Shape& ancestor = it.Value(); ancestors[ iA ]->ComputeStateEngine( theEvent );
if ( SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor))
aSubMesh->ComputeStateEngine( theEvent );
} }
} }
@ -2054,19 +2057,17 @@ void SMESH_subMesh::cleanDependants()
{ {
int dimToClean = SMESH_Gen::GetShapeDim( _subShape ) + 1; int dimToClean = SMESH_Gen::GetShapeDim( _subShape ) + 1;
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); const std::vector< SMESH_subMesh * > & ancestors = GetAncestors();
for (; it.More(); it.Next()) for ( size_t iA = 0; iA < ancestors.size(); ++iA )
{
const TopoDS_Shape& ancestor = ancestors[ iA ]->GetSubShape();
if ( SMESH_Gen::GetShapeDim( ancestor ) == dimToClean )
{ {
const TopoDS_Shape& ancestor = it.Value();
if ( SMESH_Gen::GetShapeDim( ancestor ) == dimToClean ) {
// PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEAN) // PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEAN)
// will erase mesh on other shapes in a compound // will erase mesh on other shapes in a compound
if ( ancestor.ShapeType() >= TopAbs_SOLID ) { if ( ancestor.ShapeType() >= TopAbs_SOLID &&
SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor); !ancestors[ iA ]->IsEmpty() ) // prevent infinite CLEAN via event lesteners
if (aSubMesh && ancestors[ iA ]->ComputeStateEngine(CLEAN);
!aSubMesh->IsEmpty() ) // prevent infinite CLEAN via event lesteners
aSubMesh->ComputeStateEngine(CLEAN);
}
} }
} }
} }
@ -2142,7 +2143,7 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * theGen,
} }
else if ( subMesh->GetComputeState() == READY_TO_COMPUTE ) 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 if (strcmp( anAlgo->GetName(), theAlgo->GetName()) == 0 && // same algo
anAlgo->GetUsedHypothesis( *_father, S, ignoreAuxiliaryHyps ) == aUsedHyp) // same hyps anAlgo->GetUsedHypothesis( *_father, S, ignoreAuxiliaryHyps ) == aUsedHyp) // same hyps
aBuilder.Add( aCompound, S ); 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 * \brief Find common submeshes (based on shared sub-shapes with other

View File

@ -88,6 +88,9 @@ class SMESH_EXPORT SMESH_subMesh
SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf, SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf,
const bool complexShapeFirst=false) const; const bool complexShapeFirst=false) const;
const std::vector< SMESH_subMesh * > & GetAncestors() const;
void ClearAncestors();
const TopoDS_Shape & GetSubShape() const; const TopoDS_Shape & GetSubShape() const;
enum compute_state enum compute_state
@ -325,6 +328,7 @@ protected:
std::map < int, SMESH_subMesh * >_mapDepend; std::map < int, SMESH_subMesh * >_mapDepend;
bool _dependenceAnalysed; bool _dependenceAnalysed;
std::vector< SMESH_subMesh * > _ancestors;
SMESH_Algo * _algo; // the algorithm found by last *StateEngine() call SMESH_Algo * _algo; // the algorithm found by last *StateEngine() call
algo_state _algoState; algo_state _algoState;

View File

@ -209,23 +209,22 @@ namespace {
/*! /*!
* \brief Returns a local 1D hypothesis used for theEdge * \brief Returns a local 1D hypothesis used for theEdge
*/ */
const SMESH_Hypothesis* getLocal1DHyp (SMESH_Mesh& theMesh, const SMESH_Hypothesis* getLocal1DHyp (SMESH_subMesh* theSubMesh,
const TopoDS_Shape& theEdge, //const TopoDS_Shape& theEdge,
TopoDS_Shape* theSssignedTo=0) TopoDS_Shape* theSssignedTo=0)
{ {
static SMESH_HypoFilter hypo; static SMESH_HypoFilter hypo;
hypo.Init( hypo.HasDim( 1 )). hypo.Init( hypo.HasDim( 1 )).
AndNot ( hypo.IsAlgo() ). 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 * \brief Returns a propagation hypothesis assigned to theEdge
*/ */
const SMESH_Hypothesis* getProagationHyp (SMESH_Mesh& theMesh, const SMESH_Hypothesis* getProagationHyp (SMESH_subMesh* theSubMesh)
const TopoDS_Shape& theEdge)
{ {
static SMESH_HypoFilter propagHypFilter; static SMESH_HypoFilter propagHypFilter;
if ( propagHypFilter.IsEmpty() ) if ( propagHypFilter.IsEmpty() )
@ -234,7 +233,7 @@ namespace {
Init( SMESH_HypoFilter::HasName( StdMeshers_Propagation::GetName ())). Init( SMESH_HypoFilter::HasName( StdMeshers_Propagation::GetName ())).
Or ( SMESH_HypoFilter::HasName( StdMeshers_PropagOfDistribution::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(); SMESH_Mesh* mesh = theMainSubMesh->GetFather();
TopoDS_Shape shapeOfHyp1D; // shape to which an hyp being propagated is assigned 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 )); SMESH_HypoFilter moreLocalCheck( SMESH_HypoFilter::IsMoreLocalThan( shapeOfHyp1D, *mesh ));
PropagationMgrData* chainData = getData( theMainSubMesh ); PropagationMgrData* chainData = getData( theMainSubMesh );
chainData->SetState( HAS_PROPAG_HYP ); chainData->SetState( HAS_PROPAG_HYP );
if ( const SMESH_Hypothesis * propagHyp = getProagationHyp( *mesh, theMainEdge )) if ( const SMESH_Hypothesis * propagHyp = getProagationHyp( theMainSubMesh ))
chainData->myIsPropagOfDistribution = chainData->myIsPropagOfDistribution =
( StdMeshers_PropagOfDistribution::GetName() == propagHyp->GetName() ); ( StdMeshers_PropagOfDistribution::GetName() == propagHyp->GetName() );
@ -279,6 +278,8 @@ namespace {
TopTools_MapOfShape checkedShapes; TopTools_MapOfShape checkedShapes;
checkedShapes.Add( theMainEdge ); checkedShapes.Add( theMainEdge );
vector<TopoDS_Edge> edges;
list<SMESH_subMesh*>::iterator smIt = chain.begin(); list<SMESH_subMesh*>::iterator smIt = chain.begin();
for ( ; smIt != chain.end(); ++smIt ) for ( ; smIt != chain.end(); ++smIt )
{ {
@ -295,9 +296,8 @@ namespace {
continue; continue;
// Get ordered edges and find index of anE in a sequence // Get ordered edges and find index of anE in a sequence
edges.clear();
BRepTools_WireExplorer aWE (TopoDS::Wire(itA.Value())); BRepTools_WireExplorer aWE (TopoDS::Wire(itA.Value()));
vector<TopoDS_Edge> edges;
edges.reserve(4);
int edgeIndex = 0; int edgeIndex = 0;
for (; aWE.More(); aWE.Next()) { for (; aWE.More(); aWE.Next()) {
TopoDS_Edge edge = aWE.Current(); TopoDS_Edge edge = aWE.Current();
@ -361,7 +361,7 @@ namespace {
if ( oppData->State() == WAIT_PROPAG_HYP ) // ... anOppE is not in any chain if ( oppData->State() == WAIT_PROPAG_HYP ) // ... anOppE is not in any chain
{ {
oppData->SetSource( theMainSubMesh ); 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" ! (moreLocalCheck.IsOk( hyp1D, shapeOfHyp1D ))) // ... or hyp1D is "more global"
{ {
oppData->myForward = data->myForward; oppData->myForward = data->myForward;
@ -373,8 +373,8 @@ namespace {
DBGMSG( "set IN_CHAIN on " << oppSM->GetId() ); DBGMSG( "set IN_CHAIN on " << oppSM->GetId() );
if ( oppSM->GetAlgoState() != SMESH_subMesh::HYP_OK ) if ( oppSM->GetAlgoState() != SMESH_subMesh::HYP_OK )
// make oppSM check algo state // make oppSM check algo state
if ( SMESH_Algo* algo = mesh->GetGen()->GetAlgo( *mesh, anOppE )) if ( SMESH_Algo* algo = oppSM->GetAlgo() )
oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO,algo); oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO, algo);
} }
else { else {
oppData->SetState( LAST_IN_CHAIN ); oppData->SetState( LAST_IN_CHAIN );
@ -490,7 +490,7 @@ namespace {
submesh->SetEventListener( getListener(), data, submesh ); submesh->SetEventListener( getListener(), data, submesh );
const SMESH_Hypothesis * propagHyp = const SMESH_Hypothesis * propagHyp =
getProagationHyp( *submesh->GetFather(), submesh->GetSubShape() ); getProagationHyp( submesh );
if ( propagHyp ) if ( propagHyp )
{ {
data->myIsPropagOfDistribution = data->myIsPropagOfDistribution =
@ -556,11 +556,10 @@ namespace {
case WAIT_PROPAG_HYP: { // propagation hyp or local 1D hyp is missing case WAIT_PROPAG_HYP: { // propagation hyp or local 1D hyp is missing
// -------------------------------------------------------- // --------------------------------------------------------
bool hasPropagHyp = ( isPropagHyp || bool hasPropagHyp = ( isPropagHyp || getProagationHyp( subMesh ));
getProagationHyp( *subMesh->GetFather(), subMesh->GetSubShape()) );
if ( !hasPropagHyp ) if ( !hasPropagHyp )
return; return;
bool hasLocal1DHyp = getLocal1DHyp( *subMesh->GetFather(), subMesh->GetSubShape()); bool hasLocal1DHyp = getLocal1DHyp( subMesh );
if ( !hasLocal1DHyp ) if ( !hasLocal1DHyp )
return; return;
if ( event == SMESH_subMesh::ADD_HYP || if ( event == SMESH_subMesh::ADD_HYP ||
@ -577,7 +576,7 @@ namespace {
switch ( event ) { switch ( event ) {
case SMESH_subMesh::REMOVE_HYP: case SMESH_subMesh::REMOVE_HYP:
case SMESH_subMesh::REMOVE_FATHER_HYP: // remove propagation 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() ); DBGMSG( "REMOVE_HYP propagation from HAS_PROPAG_HYP " << subMesh->GetId() );
// clear propagation chain // clear propagation chain