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()
raises (SALOME::SALOME_Exception);
long NbPolygones()
long NbPolygons()
raises (SALOME::SALOME_Exception);
long NbVolumes()
@ -396,7 +396,7 @@ module SMESH
long NbPrisms()
raises (SALOME::SALOME_Exception);
long NbPolyhedrones()
long NbPolyhedrons()
raises (SALOME::SALOME_Exception);
long NbSubMesh()

View File

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

View File

@ -634,33 +634,32 @@ void SMESH_VisualObjDef::buildElemPrs()
std::vector<int> aConnectivities;
GetConnect(aNodesIter,aConnect);
// Convertions connectivities from SMDS to VTK
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++){
if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
for (int k = 0; k < aNbNodes; k++) {
aConnectivities.push_back(k);
if (MYDEBUG) cout << " "<<k;
}
if (MYDEBUG) cout << endl;
}
else if (aNbNodes == 4){
static int anIds[] = {0,2,1,3};
for (int k=0; k<aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else if (aNbNodes == 5){
static int anIds[] = {0,3,2,1,4};
for (int k=0; k<aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else if (aNbNodes == 6){
static int anIds[] = {0,1,2,3,4,5};
for (int k=0; k<aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else if (aNbNodes == 8){
static int anIds[] = {0,3,2,1,4,7,6,5};
for (int k=0; k<aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
if(aConnectivities.size()>0){
for( vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++ )
} else if (aNbNodes == 4) {
static int anIds[] = {0,2,1,3};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else if (aNbNodes == 5) {
static int anIds[] = {0,3,2,1,4};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else if (aNbNodes == 6) {
static int anIds[] = {0,1,2,3,4,5};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else if (aNbNodes == 8) {
static int anIds[] = {0,3,2,1,4,7,6,5};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else {
}
if (aConnectivities.size() > 0) {
for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++)
SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
}
break;
@ -673,7 +672,7 @@ void SMESH_VisualObjDef::buildElemPrs()
}
aConnectivity->InsertNextCell( anIdList );
aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(),aNbNodes ) );
aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) );
iElem++;
}

View File

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

View File

@ -833,7 +833,12 @@ int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
int Nb = 0;
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;
}
@ -846,20 +851,25 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
int Nb = 0;
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 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);
int Nb = 0;
SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->IsPoly()) Nb++;
SMDS_FaceIteratorPtr itFaces = _myMeshDS->facesIterator();
while (itFaces->more())
if (itFaces->next()->IsPoly()) Nb++;
return Nb;
}
@ -879,7 +889,12 @@ int SMESH_Mesh::NbTetras() throw(SALOME_Exception)
Unexpect aCatch(SalomeException);
int Nb = 0;
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;
}
@ -888,7 +903,12 @@ int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
Unexpect aCatch(SalomeException);
int Nb = 0;
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;
}
@ -897,7 +917,12 @@ int SMESH_Mesh::NbPyramids() throw(SALOME_Exception)
Unexpect aCatch(SalomeException);
int Nb = 0;
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;
}
@ -906,16 +931,22 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception)
Unexpect aCatch(SalomeException);
int Nb = 0;
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;
}
int SMESH_Mesh::NbPolyhedrones() throw(SALOME_Exception)
int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->IsPoly()) Nb++;
SMDS_VolumeIteratorPtr itVolumes = _myMeshDS->volumesIterator();
while (itVolumes->more())
if (itVolumes->next()->IsPoly()) Nb++;
return Nb;
}

View File

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

View File

@ -405,13 +405,13 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos()
myMeshNbFaces->setNum( (int)aMesh->NbFaces() );
myMeshNbTriangles->setNum( (int)aMesh->NbTriangles() );
myMeshNbQuadrangles->setNum( (int)aMesh->NbQuadrangles() );
myMeshNbPolygones->setNum( (int)aMesh->NbPolygones() );
myMeshNbPolygones->setNum( (int)aMesh->NbPolygons() );
myMeshNbVolumes->setNum( (int)aMesh->NbVolumes() );
myMeshNbTetra->setNum( (int)aMesh->NbTetras() );
myMeshNbHexa->setNum( (int)aMesh->NbHexas() );
myMeshNbPrism->setNum( (int)aMesh->NbPrisms() );
myMeshNbPyra->setNum( (int)aMesh->NbPyramids() );
myMeshNbPolyhedrones->setNum( (int)aMesh->NbPolyhedrones() );
myMeshNbPolyhedrones->setNum( (int)aMesh->NbPolyhedrons() );
return;
}
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();
}
CORBA::Long SMESH_Mesh_i::NbPolygones()throw(SALOME::SALOME_Exception)
CORBA::Long SMESH_Mesh_i::NbPolygons()throw(SALOME::SALOME_Exception)
{
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();
}
CORBA::Long SMESH_Mesh_i::NbPolyhedrones()throw(SALOME::SALOME_Exception)
CORBA::Long SMESH_Mesh_i::NbPolyhedrons()throw(SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
return _impl->NbPolyhedrones();
return _impl->NbPolyhedrons();
}
//=============================================================================

View File

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