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 {
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -764,16 +763,15 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
}
else {
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -877,17 +875,16 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
}
else {
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -1006,23 +1003,22 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
}
else {
// --- retrieve nodes ID
vector<vtkIdType> 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());
myNodeIds[0] = n1->getVtkId();
myNodeIds[0] = n6->getVtkId();
myNodeIds[0] = n5->getVtkId();
myNodeIds[0] = n4->getVtkId();
myNodeIds[0] = n3->getVtkId();
myNodeIds[0] = 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] = 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);
@ -1133,19 +1129,18 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
}
else {
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -1329,8 +1324,8 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID (const vector<int> & nodes_ids,
/// Add a polygon defined by its nodes
///////////////////////////////////////////////////////////////////////////////
SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
(const vector<const SMDS_MeshNode*> & nodes,
SMDS_MeshFace*
SMDS_Mesh::AddPolygonalFaceWithID (const vector<const SMDS_MeshNode*> & nodes,
const int ID)
{
SMDS_MeshFace * face;
@ -1345,14 +1340,12 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
{
//#ifdef VTK_HAVE_POLYHEDRON
//MESSAGE("AddPolygonalFaceWithID vtk " << ID);
vector<vtkIdType> nodeIds;
nodeIds.clear();
vector<const SMDS_MeshNode*>::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);
@ -1419,8 +1412,8 @@ SMDS_MeshVolume * SMDS_Mesh::AddPolyhedralVolumeWithID
/// @return The created volume
///////////////////////////////////////////////////////////////////////////////
SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID
(const vector<const SMDS_MeshNode*>& nodes,
SMDS_MeshVolume*
SMDS_Mesh::AddPolyhedralVolumeWithID (const vector<const SMDS_MeshNode*>& nodes,
const vector<int> & quantities,
const int ID)
{
@ -1442,14 +1435,12 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID
{
//#ifdef VTK_HAVE_POLYHEDRON
//MESSAGE("AddPolyhedralVolumeWithID vtk " << ID);
vector<vtkIdType> nodeIds;
nodeIds.clear();
vector<const SMDS_MeshNode*>::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_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->initPoly(nodeIds, quantities, this);
volvtk->initPoly(myNodeIds, quantities, this);
if (!this->registerElement(ID, volvtk))
{
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
@ -1705,15 +1696,14 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1,
else
{
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -1759,16 +1749,15 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1,
else
{
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -2094,13 +2083,12 @@ 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<vtkIdType> 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);
@ -3591,15 +3579,14 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
if ( !n1 || !n2 || !n12 ) return 0;
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -3672,18 +3659,17 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
else
{
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -3759,19 +3745,18 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
else
{
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -3850,20 +3835,19 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
else
{
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -3944,21 +3928,20 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
else
{
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -4046,23 +4029,22 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
return 0;
}
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -4159,26 +4141,25 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
return 0;
}
// --- retrieve nodes ID
vector<vtkIdType> 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(13);
myNodeIds[0] = n1->getVtkId();
myNodeIds[1] = n4->getVtkId();
myNodeIds[2] = n3->getVtkId();
myNodeIds[3] = n2->getVtkId();
myNodeIds[4] = n5->getVtkId();
nodeIds.push_back(n41->getVtkId());
nodeIds.push_back(n34->getVtkId());
nodeIds.push_back(n23->getVtkId());
nodeIds.push_back(n12->getVtkId());
myNodeIds[5] = n41->getVtkId();
myNodeIds[6] = n34->getVtkId();
myNodeIds[7] = n23->getVtkId();
myNodeIds[8] = n12->getVtkId();
nodeIds.push_back(n15->getVtkId());
nodeIds.push_back(n45->getVtkId());
nodeIds.push_back(n35->getVtkId());
nodeIds.push_back(n25->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);
@ -4283,30 +4264,29 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
return 0;
}
// --- retrieve nodes ID
vector<vtkIdType> 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);
@ -4426,35 +4406,34 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
// creation quadratic faces - not implemented
}
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getVtkId());
nodeIds.push_back(n4->getVtkId());
nodeIds.push_back(n3->getVtkId());
nodeIds.push_back(n2->getVtkId());
myNodeIds.resize(20);
myNodeIds[0] = n1->getVtkId();
myNodeIds[1] = n4->getVtkId();
myNodeIds[2] = n3->getVtkId();
myNodeIds[3] = n2->getVtkId();
nodeIds.push_back(n5->getVtkId());
nodeIds.push_back(n8->getVtkId());
nodeIds.push_back(n7->getVtkId());
nodeIds.push_back(n6->getVtkId());
myNodeIds[4] = n5->getVtkId();
myNodeIds[5] = n8->getVtkId();
myNodeIds[6] = n7->getVtkId();
myNodeIds[7] = n6->getVtkId();
nodeIds.push_back(n41->getVtkId());
nodeIds.push_back(n34->getVtkId());
nodeIds.push_back(n23->getVtkId());
nodeIds.push_back(n12->getVtkId());
myNodeIds[8] = n41->getVtkId();
myNodeIds[9] = n34->getVtkId();
myNodeIds[10] = n23->getVtkId();
myNodeIds[11] = n12->getVtkId();
nodeIds.push_back(n85->getVtkId());
nodeIds.push_back(n78->getVtkId());
nodeIds.push_back(n67->getVtkId());
nodeIds.push_back(n56->getVtkId());
myNodeIds[12] = n85->getVtkId();
myNodeIds[13] = n78->getVtkId();
myNodeIds[14] = n67->getVtkId();
myNodeIds[15] = n56->getVtkId();
nodeIds.push_back(n15->getVtkId());
nodeIds.push_back(n48->getVtkId());
nodeIds.push_back(n37->getVtkId());
nodeIds.push_back(n26->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);
@ -4599,43 +4578,42 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
// creation quadratic faces - not implemented
}
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getVtkId());
nodeIds.push_back(n4->getVtkId());
nodeIds.push_back(n3->getVtkId());
nodeIds.push_back(n2->getVtkId());
myNodeIds.resize(27);
myNodeIds[0] = n1->getVtkId();
myNodeIds[1] = n4->getVtkId();
myNodeIds[2] = n3->getVtkId();
myNodeIds[3] = n2->getVtkId();
nodeIds.push_back(n5->getVtkId());
nodeIds.push_back(n8->getVtkId());
nodeIds.push_back(n7->getVtkId());
nodeIds.push_back(n6->getVtkId());
myNodeIds[4] = n5->getVtkId();
myNodeIds[5] = n8->getVtkId();
myNodeIds[6] = n7->getVtkId();
myNodeIds[7] = n6->getVtkId();
nodeIds.push_back(n41->getVtkId());
nodeIds.push_back(n34->getVtkId());
nodeIds.push_back(n23->getVtkId());
nodeIds.push_back(n12->getVtkId());
myNodeIds[8] = n41->getVtkId();
myNodeIds[9] = n34->getVtkId();
myNodeIds[10] = n23->getVtkId();
myNodeIds[11] = n12->getVtkId();
nodeIds.push_back(n85->getVtkId());
nodeIds.push_back(n78->getVtkId());
nodeIds.push_back(n67->getVtkId());
nodeIds.push_back(n56->getVtkId());
myNodeIds[12] = n85->getVtkId();
myNodeIds[13] = n78->getVtkId();
myNodeIds[14] = n67->getVtkId();
myNodeIds[15] = n56->getVtkId();
nodeIds.push_back(n15->getVtkId());
nodeIds.push_back(n48->getVtkId());
nodeIds.push_back(n37->getVtkId());
nodeIds.push_back(n26->getVtkId());
myNodeIds[16] = n15->getVtkId();
myNodeIds[17] = n48->getVtkId();
myNodeIds[18] = n37->getVtkId();
myNodeIds[19] = 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[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);

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
SetOfCells myCells;
//! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid
//std::vector<int> myCellIdSmdsToVtk;
//! a buffer to speed up elements addition by excluding some memory allocation
std::vector<vtkIdType> myNodeIds;
//! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users
std::vector<int> myCellIdVtkToSmds;

View File

@ -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

View File

@ -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);

View File

@ -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<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
list<const SMESHDS_Hypothesis*>::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<SMESH_subMesh*>::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<SMESH_subMesh*>::const_iterator smIt = ancestors.begin();
for ( ; smIt != ancestors.end(); smIt++ )
{
const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
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 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 <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
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<const SMESHDS_Hypothesis*>& 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<SMESH_subMesh*>::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<SMESH_subMesh*>::const_iterator smIt = ancestors.begin();
for ( ; smIt != ancestors.end(); smIt++ )
{
const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
if ( !map.Add( curSh ))
continue;
const list<const SMESHDS_Hypothesis*>& 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<SMESH_subMesh*>( 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 <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() );
}
}
@ -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
}
}
}
{

View File

@ -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<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);

View File

@ -47,13 +47,14 @@
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <gp_Pnt.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx>
#include <gp_Pnt.hxx>
#include <Standard_OutOfMemory.hxx>
#include <Standard_ErrorHandler.hxx>
@ -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<int, SMESH_subMesh*>::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 = 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)
// 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

View File

@ -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;

View File

@ -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<TopoDS_Edge> edges;
list<SMESH_subMesh*>::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<TopoDS_Edge> 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,7 +373,7 @@ 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 ))
if ( SMESH_Algo* algo = oppSM->GetAlgo() )
oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO, algo);
}
else {
@ -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