Polygons and polyhedral volumes support

This commit is contained in:
jfa 2005-02-18 10:37:47 +00:00
parent 9b4762cb6b
commit a05b651f04
9 changed files with 106 additions and 87 deletions

View File

@ -378,7 +378,7 @@ module SMESH
long NbQuadrangles() long NbQuadrangles()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long NbPolygones() long NbPolygons()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long NbVolumes() long NbVolumes()
@ -396,7 +396,7 @@ module SMESH
long NbPrisms() long NbPrisms()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long NbPolyhedrones() long NbPolyhedrons()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long NbSubMesh() long NbSubMesh()

View File

@ -280,12 +280,13 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
TElemNum aIndex = aPolygoneInfo->GetIndex(); TElemNum aIndex = aPolygoneInfo->GetIndex();
TInt nbPolygons = aPolygoneInfo->GetNbElem(); TInt nbPolygons = aPolygoneInfo->GetNbElem();
for (TInt iPG = 0; iPG < nbPolygons; iPG++) { for (TInt iPG = 0; iPG < nbPolygons; iPG++) {
// get nodes // get nodes
TInt aCurrPG_FirstNodeIndex = aIndex[iPG] - 1; TInt aCurrPG_FirstNodeIndex = aIndex[iPG] - 1;
int aNbNodes = aPolygoneInfo->GetNbConn(iPG); int nbNodes = aPolygoneInfo->GetNbConn(iPG);
std::vector<int> nodes_ids (aNbNodes); std::vector<int> nodes_ids (nbNodes);
for (TInt inode = 0; inode < aNbNodes; inode++) { for (TInt inode = 0; inode < nbNodes; inode++) {
nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode]; nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
} }
@ -299,20 +300,17 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
(nodes_ids, aPolygoneInfo->GetElemNum(iPG)); (nodes_ids, aPolygoneInfo->GetElemNum(iPG));
} }
if (!anElement) { if (!anElement) {
std::vector<const SMDS_MeshNode*> nodes (aNbNodes); std::vector<const SMDS_MeshNode*> nodes (nbNodes);
for (int inode = 0; inode < aNbNodes; inode++) { for (int inode = 0; inode < nbNodes; inode++) {
nodes[inode] = FindNode(myMesh, nodes_ids[inode]); nodes[inode] = FindNode(myMesh, nodes_ids[inode]);
} }
anElement = myMesh->AddPolygonalFace(nodes); anElement = myMesh->AddPolygonalFace(nodes);
isRenum = anIsElemNum; isRenum = anIsElemNum;
} }
} catch (const std::exception& exc) { } catch (const std::exception& exc) {
aResult = DRS_FAIL; aResult = DRS_FAIL;
INFOS("Follow exception was cought:\n\t"<<exc.what());
} catch (...) { } catch (...) {
aResult = DRS_FAIL; aResult = DRS_FAIL;
INFOS("Follow unknown exception was cought!");
} }
if (!anElement) { if (!anElement) {
@ -326,17 +324,11 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
} }
if (myFamilies.find(aFamNum) != myFamilies.end()) { if (myFamilies.find(aFamNum) != myFamilies.end()) {
// Save reference to this element from its family // Save reference to this element from its family
if (MYDEBUG){
cout<<"myFamilies["<<aFamNum
<<"] IsPoly()="<<anElement->IsPoly()
<<"; GetType="<<anElement->GetType()
<<"; aNbNodes="<<aNbNodes<<endl;
}
myFamilies[aFamNum]->AddElement(anElement); myFamilies[aFamNum]->AddElement(anElement);
myFamilies[aFamNum]->SetType(anElement->GetType()); myFamilies[aFamNum]->SetType(anElement->GetType());
} }
} }
} } // for (TInt iPG = 0; iPG < nbPolygons; iPG++)
continue; continue;
} else if (aGeom == ePOLYEDRE) { } else if (aGeom == ePOLYEDRE) {
@ -359,8 +351,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
int aCurrFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa] - 1; int aCurrFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa] - 1;
int aNextFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa + 1] - 1; int aNextFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa + 1] - 1;
int aNbNodes = aNextFace_FirstNodeIndex - aCurrFace_FirstNodeIndex; int nbNodes = aNextFace_FirstNodeIndex - aCurrFace_FirstNodeIndex;
quantities[iFa] = aNbNodes; quantities[iFa] = nbNodes;
} }
// get nodes // get nodes
@ -390,10 +382,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
} }
} catch (const std::exception& exc) { } catch (const std::exception& exc) {
aResult = DRS_FAIL; aResult = DRS_FAIL;
INFOS("Follow exception was cought:\n\t"<<exc.what());
} catch (...) { } catch (...) {
aResult = DRS_FAIL; aResult = DRS_FAIL;
INFOS("Follow unknown exception was cought!");
} }
if (!anElement) { if (!anElement) {
@ -407,19 +397,14 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
} }
if (myFamilies.find(aFamNum) != myFamilies.end()) { if (myFamilies.find(aFamNum) != myFamilies.end()) {
// Save reference to this element from its family // Save reference to this element from its family
if (MYDEBUG){
cout<<"myFamilies["<<aFamNum
<<"] IsPoly()="<<anElement->IsPoly()
<<"; GetType="<<anElement->GetType()
<<"; aNbNodes="<<nbPENodes<<endl;
}
myFamilies[aFamNum]->AddElement(anElement); myFamilies[aFamNum]->AddElement(anElement);
myFamilies[aFamNum]->SetType(anElement->GetType()); myFamilies[aFamNum]->SetType(anElement->GetType());
} }
} }
} } // for (int iPE = 0; iPE < nbPolyedres; iPE++)
continue; continue;
} else {
} }
PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom); PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
@ -496,6 +481,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
SMDS_MeshElement* anElement = NULL; SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aCellInfo->GetFamNum(iElem); TInt aFamNum = aCellInfo->GetFamNum(iElem);
try{ try{
//MESSAGE("Try to create element # " << iElem << " with id = "
// << aCellInfo->GetElemNum(iElem));
switch(aGeom){ switch(aGeom){
case eSEG2: case eSEG2:
case eSEG3: case eSEG3:

View File

@ -635,28 +635,27 @@ void SMESH_VisualObjDef::buildElemPrs()
GetConnect(aNodesIter,aConnect); GetConnect(aNodesIter,aConnect);
// Convertions connectivities from SMDS to VTK // Convertions connectivities from SMDS to VTK
if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
if (MYDEBUG) cout << "SMESH:Polyedre IsPoly()="<<anElem->IsPoly()<<"; aType="<<aType<<"; aNbNodes="<<aNbNodes<<endl;
for (int k = 0; k < aNbNodes; k++) { for (int k = 0; k < aNbNodes; k++) {
aConnectivities.push_back(k); aConnectivities.push_back(k);
if (MYDEBUG) cout << " "<<k;
} }
if (MYDEBUG) cout << endl;
} } else if (aNbNodes == 4) {
else if (aNbNodes == 4){
static int anIds[] = {0,2,1,3}; static int anIds[] = {0,2,1,3};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else if (aNbNodes == 5){ } else if (aNbNodes == 5) {
static int anIds[] = {0,3,2,1,4}; static int anIds[] = {0,3,2,1,4};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else if (aNbNodes == 6){ } else if (aNbNodes == 6) {
static int anIds[] = {0,1,2,3,4,5}; static int anIds[] = {0,1,2,3,4,5};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else if (aNbNodes == 8){ } else if (aNbNodes == 8) {
static int anIds[] = {0,3,2,1,4,7,6,5}; static int anIds[] = {0,3,2,1,4,7,6,5};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else {
} }
if (aConnectivities.size() > 0) { if (aConnectivities.size() > 0) {

View File

@ -83,9 +83,11 @@ bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode
//SMDS_VolumeOfNodes::ChangeNodes(aNodes, aNbNodes); //SMDS_VolumeOfNodes::ChangeNodes(aNodes, aNbNodes);
delete [] myNodes; delete [] myNodes;
//myNbNodes = nodes.size();
myNbNodes = aNbNodes; myNbNodes = aNbNodes;
myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes = new const SMDS_MeshNode* [myNbNodes];
for (int i = 0; i < myNbNodes; i++) { for (int i = 0; i < myNbNodes; i++) {
//myNodes[i] = nodes[i];
myNodes[i] = aNodes[i]; myNodes[i] = aNodes[i];
} }

View File

@ -833,7 +833,12 @@ int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
int Nb = 0; int Nb = 0;
SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++; //while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++;
const SMDS_MeshFace * curFace;
while (itFaces->more()) {
curFace = itFaces->next();
if (!curFace->IsPoly() && curFace->NbNodes() == 3) Nb++;
}
return Nb; return Nb;
} }
@ -846,20 +851,25 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
int Nb = 0; int Nb = 0;
SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++; //while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++;
const SMDS_MeshFace * curFace;
while (itFaces->more()) {
curFace = itFaces->next();
if (!curFace->IsPoly() && curFace->NbNodes() == 4) Nb++;
}
return Nb; return Nb;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Return the number of polygone faces in the mesh. This method run in O(n) /// Return the number of polygonal faces in the mesh. This method run in O(n)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
int SMESH_Mesh::NbPolygones() throw(SALOME_Exception) int SMESH_Mesh::NbPolygons() throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_FaceIteratorPtr itFaces = _myMeshDS->facesIterator(); SMDS_FaceIteratorPtr itFaces = _myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->IsPoly()) Nb++; while (itFaces->more())
if (itFaces->next()->IsPoly()) Nb++;
return Nb; return Nb;
} }
@ -879,7 +889,12 @@ int SMESH_Mesh::NbTetras() throw(SALOME_Exception)
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++; //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++;
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 4) Nb++;
}
return Nb; return Nb;
} }
@ -888,7 +903,12 @@ int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++; //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++;
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 8) Nb++;
}
return Nb; return Nb;
} }
@ -897,7 +917,12 @@ int SMESH_Mesh::NbPyramids() throw(SALOME_Exception)
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++; //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++;
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 5) Nb++;
}
return Nb; return Nb;
} }
@ -906,16 +931,22 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception)
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++; //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++;
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 6) Nb++;
}
return Nb; return Nb;
} }
int SMESH_Mesh::NbPolyhedrones() throw(SALOME_Exception) int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes = _myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes = _myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->IsPoly()) Nb++; while (itVolumes->more())
if (itVolumes->next()->IsPoly()) Nb++;
return Nb; return Nb;
} }

View File

@ -166,7 +166,7 @@ public:
int NbQuadrangles() throw(SALOME_Exception); int NbQuadrangles() throw(SALOME_Exception);
int NbPolygones() throw(SALOME_Exception); int NbPolygons() throw(SALOME_Exception);
int NbVolumes() throw(SALOME_Exception); int NbVolumes() throw(SALOME_Exception);
@ -176,10 +176,10 @@ public:
int NbPyramids() throw(SALOME_Exception); int NbPyramids() throw(SALOME_Exception);
int NbPolyhedrones() throw(SALOME_Exception);
int NbPrisms() throw(SALOME_Exception); int NbPrisms() throw(SALOME_Exception);
int NbPolyhedrons() throw(SALOME_Exception);
int NbSubMesh() throw(SALOME_Exception); int NbSubMesh() throw(SALOME_Exception);
int NbGroup() const { return _mapGroup.size(); } int NbGroup() const { return _mapGroup.size(); }

View File

@ -405,13 +405,13 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos()
myMeshNbFaces->setNum( (int)aMesh->NbFaces() ); myMeshNbFaces->setNum( (int)aMesh->NbFaces() );
myMeshNbTriangles->setNum( (int)aMesh->NbTriangles() ); myMeshNbTriangles->setNum( (int)aMesh->NbTriangles() );
myMeshNbQuadrangles->setNum( (int)aMesh->NbQuadrangles() ); myMeshNbQuadrangles->setNum( (int)aMesh->NbQuadrangles() );
myMeshNbPolygones->setNum( (int)aMesh->NbPolygones() ); myMeshNbPolygones->setNum( (int)aMesh->NbPolygons() );
myMeshNbVolumes->setNum( (int)aMesh->NbVolumes() ); myMeshNbVolumes->setNum( (int)aMesh->NbVolumes() );
myMeshNbTetra->setNum( (int)aMesh->NbTetras() ); myMeshNbTetra->setNum( (int)aMesh->NbTetras() );
myMeshNbHexa->setNum( (int)aMesh->NbHexas() ); myMeshNbHexa->setNum( (int)aMesh->NbHexas() );
myMeshNbPrism->setNum( (int)aMesh->NbPrisms() ); myMeshNbPrism->setNum( (int)aMesh->NbPrisms() );
myMeshNbPyra->setNum( (int)aMesh->NbPyramids() ); myMeshNbPyra->setNum( (int)aMesh->NbPyramids() );
myMeshNbPolyhedrones->setNum( (int)aMesh->NbPolyhedrones() ); myMeshNbPolyhedrones->setNum( (int)aMesh->NbPolyhedrons() );
return; return;
} }
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( anObject ); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( anObject );

View File

@ -1193,10 +1193,10 @@ CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
return _impl->NbQuadrangles(); return _impl->NbQuadrangles();
} }
CORBA::Long SMESH_Mesh_i::NbPolygones()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::NbPolygons()throw(SALOME::SALOME_Exception)
{ {
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
return _impl->NbPolygones(); return _impl->NbPolygons();
} }
//============================================================================= //=============================================================================
@ -1234,10 +1234,10 @@ CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception)
return _impl->NbPrisms(); return _impl->NbPrisms();
} }
CORBA::Long SMESH_Mesh_i::NbPolyhedrones()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::NbPolyhedrons()throw(SALOME::SALOME_Exception)
{ {
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
return _impl->NbPolyhedrones(); return _impl->NbPolyhedrons();
} }
//============================================================================= //=============================================================================

View File

@ -183,7 +183,7 @@ public:
CORBA::Long NbQuadrangles() CORBA::Long NbQuadrangles()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
CORBA::Long NbPolygones() CORBA::Long NbPolygons()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
CORBA::Long NbVolumes() CORBA::Long NbVolumes()
@ -201,7 +201,7 @@ public:
CORBA::Long NbPrisms() CORBA::Long NbPrisms()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
CORBA::Long NbPolyhedrones() CORBA::Long NbPolyhedrons()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
CORBA::Long NbSubMesh() CORBA::Long NbSubMesh()