aValue = aStr.str();
- MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description,
- MED::TIntVector anAttrIds (1, myId); // Id=0,
- MED::TIntVector anAttrVals (1, myId); // Value=0
+ MED::TStringVector anAttrDescs;
+ MED::TIntVector anAttrIds;
+ MED::TIntVector anAttrVals;
+ //MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description,
+ //MED::TIntVector anAttrIds (1, myId); // Id=0,
+ //MED::TIntVector anAttrVals (1, myId); // Value=0
MED::PFamilyInfo anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
aValue,
MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
const EGeometrieElement& aGeom = anTGeomIter->first;
- if(aGeom == ePOINT1) continue;
+
+ if (aGeom == ePOINT1) {
+ continue;
+
+ } else if (aGeom == ePOLYGONE) {
+ PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
+ EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX;
+
+ TElemNum aConn = aPolygoneInfo->GetConnectivite();
+ 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++) {
+ nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
+ }
+
+ bool isRenum = false;
+ SMDS_MeshElement* anElement = NULL;
+ TInt aFamNum = aPolygoneInfo->GetFamNum(iPG);
+
+ try {
+ if (anIsElemNum) {
+ anElement = myMesh->AddPolygonalFaceWithID
+ (nodes_ids, aPolygoneInfo->GetElemNum(iPG));
+ }
+ if (!anElement) {
+ std::vector<const SMDS_MeshNode*> nodes (aNbNodes);
+ for (int inode = 0; inode < aNbNodes; 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) {
+ aResult = DRS_WARN_SKIP_ELEM;
+ } else {
+ if (isRenum) {
+ anIsElemNum = eFAUX;
+ takeNumbers = false;
+ if (aResult < DRS_WARN_RENUMBER)
+ aResult = DRS_WARN_RENUMBER;
+ }
+ 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());
+ }
+ }
+ }
+ continue;
+
+ } else if (aGeom == ePOLYEDRE) {
+ PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom);
+ EBooleen anIsElemNum = takeNumbers ? aPolyedreInfo->IsElemNum() : eFAUX;
+
+ TElemNum aConn = aPolyedreInfo->GetConnectivite();
+ TElemNum aFacesIndex = aPolyedreInfo->GetFacesIndex();
+ TElemNum aIndex = aPolyedreInfo->GetIndex();
+
+ TInt nbPolyedres = aPolyedreInfo->GetNbElem();
+
+ for (int iPE = 0; iPE < nbPolyedres; iPE++) {
+ // get faces
+ int aCurrPE_FirstFaceIndex = aIndex[iPE] - 1;
+ int aNextPE_FirstFaceIndex = aIndex[iPE + 1] - 1;
+ int nbFaces = aNextPE_FirstFaceIndex - aCurrPE_FirstFaceIndex;
+ std::vector<int> quantities (nbFaces);
+ for (int iFa = 0; iFa < nbFaces; iFa++) {
+ 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;
+ }
+
+ // get nodes
+ int aCurrPE_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex] - 1;
+ int nbPENodes = aPolyedreInfo->GetNbConn(iPE);
+ std::vector<int> nodes_ids (nbPENodes);
+ for (int inode = 0; inode < nbPENodes; inode++) {
+ nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
+ }
+
+ bool isRenum = false;
+ SMDS_MeshElement* anElement = NULL;
+ TInt aFamNum = aPolyedreInfo->GetFamNum(iPE);
+
+ try {
+ if (anIsElemNum) {
+ anElement = myMesh->AddPolyhedralVolumeWithID
+ (nodes_ids, quantities, aPolyedreInfo->GetElemNum(iPE));
+ }
+ if (!anElement) {
+ std::vector<const SMDS_MeshNode*> nodes (nbPENodes);
+ for (int inode = 0; inode < nbPENodes; inode++) {
+ nodes[inode] = FindNode(myMesh, nodes_ids[inode]);
+ }
+ anElement = myMesh->AddPolyhedralVolume(nodes, quantities);
+ 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) {
+ aResult = DRS_WARN_SKIP_ELEM;
+ } else {
+ if (isRenum) {
+ anIsElemNum = eFAUX;
+ takeNumbers = false;
+ if (aResult < DRS_WARN_RENUMBER)
+ aResult = DRS_WARN_RENUMBER;
+ }
+ 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());
+ }
+ }
+ }
+ continue;
+
+ }
+
PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
TInt aNbElems = aCellInfo->GetNbElem();
for (; anElemsIter != anElements.end(); anElemsIter++)
{
element = *anElemsIter;
- theGroup->SMDSGroup().Add(element);
+ theGroup->SMDSGroup().Add(element);
}
if ( element )
theGroup->SetType( element->GetType() );
#include "SMESHDS_Mesh.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
+#include "SMDS_PolyhedralVolumeOfNodes.hxx"
+
#include "utilities.h"
#include "MED_Utilities.hxx"
MED::TIntVector aQuadConn;
aQuadConn.reserve(aNbElems*aNbQuadConn);
+ MED::TIntVector aPolygoneElemNums;
+ aPolygoneElemNums.reserve(aNbElems);
+ MED::TIntVector aPolygoneInds;
+ aPolygoneInds.reserve(aNbElems + 1);
+ aPolygoneInds.push_back(1); // reference on the first element in the connectivities
+ MED::TIntVector aPolygoneFamilyNums;
+ aPolygoneFamilyNums.reserve(aNbElems);
+ MED::TIntVector aPolygoneConn;
+ aPolygoneConn.reserve(aNbElems*aNbQuadConn);
+
for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
const SMDS_MeshFace* anElem = anIter->next();
TInt aNbNodes = anElem->NbNodes();
MED::TIntVector* anElemNums;
MED::TIntVector* aFamilyNums;
MED::TIntVector* aConnectivity;
- switch(aNbNodes){
- case 3:
- aNbConnectivity = aNbTriaConn;
- anElemNums = &anTriaElemNums;
- aFamilyNums = &aTriaFamilyNums;
- aConnectivity = &aTriaConn;
- break;
- case 4:
- aNbConnectivity = aNbQuadConn;
- anElemNums = &aQuadElemNums;
- aFamilyNums = &aQuadFamilyNums;
- aConnectivity = &aQuadConn;
- break;
- }
+ if (anElem->IsPoly()) {
+ aNbConnectivity = aNbNodes;
+ anElemNums = &aPolygoneElemNums;
+ aFamilyNums = &aPolygoneFamilyNums;
+ aConnectivity = &aPolygoneConn;
+ } else {
+ switch(aNbNodes){
+ case 3:
+ aNbConnectivity = aNbTriaConn;
+ anElemNums = &anTriaElemNums;
+ aFamilyNums = &aTriaFamilyNums;
+ aConnectivity = &aTriaConn;
+ break;
+ case 4:
+ aNbConnectivity = aNbQuadConn;
+ anElemNums = &aQuadElemNums;
+ aFamilyNums = &aQuadFamilyNums;
+ aConnectivity = &aQuadConn;
+ break;
+ default:
+ break;
+ }
+ }
MED::TIntVector aVector(aNbNodes);
for(TInt iNode = 0; aNodesIter->more(); iNode++){
const SMDS_MeshElement* aNode = aNodesIter->next();
+#ifdef _EDF_NODE_IDS_
+ aVector[iNode] = aNodeIdMap[aNode->GetID()];
+#else
aVector[iNode] = aNode->GetID();
+#endif
}
TInt aSize = aConnectivity->size();
aConnectivity->resize(aSize+aNbConnectivity);
- // There is some differnce between SMDS and MED in cells mapping
-#ifdef _EDF_NODE_IDS_
- switch(aNbNodes){
- case 4:
- (*aConnectivity)[aSize+0] = aNodeIdMap[aVector[0]];
- (*aConnectivity)[aSize+1] = aNodeIdMap[aVector[1]];
- (*aConnectivity)[aSize+2] = aNodeIdMap[aVector[3]];
- (*aConnectivity)[aSize+3] = aNodeIdMap[aVector[2]];
- default:
- for(TInt iNode = 0; iNode < aNbNodes; iNode++)
- (*aConnectivity)[aSize+iNode] = aNodeIdMap[aVector[iNode]];
- }
-#else
+ // There is some differences between SMDS and MED in cells mapping
switch(aNbNodes){
case 4:
(*aConnectivity)[aSize+0] = aVector[0];
for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aVector[iNode];
}
-#endif
+
+ if (anElem->IsPoly()) {
+ // fill indices for polygonal element
+ TInt aPrevPos = aPolygoneInds.back();
+ aPolygoneInds.push_back(aPrevPos + aNbNodes);
+ }
+
anElemNums->push_back(anElem->GetID());
if (anElemFamMap.find(anElem) != anElemFamMap.end())
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo);
}
+ if(TInt aNbElems = aPolygoneElemNums.size()){
+ // add one element in connectivities,
+ // referenced by the last element in indices
+ aPolygoneConn.push_back(0);
+
+ PPolygoneInfo aCellInfo = myMed->CrPolygoneInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePOLYGONE,
+ SMDS_MED_CONNECTIVITY,
+ aPolygoneConn,
+ aPolygoneInds,
+ aPolygoneFamilyNums,
+ aPolygoneElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYGONE<<"; aNbElems = "<<aNbElems);
+ myMed->SetPolygoneInfo(aCellInfo);
+ }
}
// Storing SMDS Volumes
MED::TIntVector aHexaConn;
aHexaConn.reserve(aNbElems*aNbHexaConn);
+ MED::TIntVector aPolyedreElemNums;
+ aPolyedreElemNums.reserve(aNbElems);
+ MED::TIntVector aPolyedreInds;
+ aPolyedreInds.reserve(aNbElems + 1);
+ aPolyedreInds.push_back(1); // reference on the first element in the faces
+ MED::TIntVector aPolyedreFaces;
+ aPolyedreFaces.reserve(aNbElems + 1);
+ aPolyedreFaces.push_back(1); // reference on the first element in the connectivities
+ MED::TIntVector aPolyedreFamilyNums;
+ aPolyedreFamilyNums.reserve(aNbElems);
+ MED::TIntVector aPolyedreConn;
+ aPolyedreConn.reserve(aNbElems*aNbHexaConn);
+
for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
const SMDS_MeshVolume* anElem = anIter->next();
- TInt aNbNodes = anElem->NbNodes();
- SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
- TInt aNbConnectivity;
- MED::TIntVector* anElemNums;
- MED::TIntVector* aFamilyNums;
- MED::TIntVector* aConnectivity;
- switch(aNbNodes){
- case 4:
- aNbConnectivity = aNbTetraConn;
- anElemNums = &anTetraElemNums;
- aFamilyNums = &aTetraFamilyNums;
- aConnectivity = &aTetraConn;
- break;
- case 5:
- aNbConnectivity = aNbPyraConn;
- anElemNums = &anPyraElemNums;
- aFamilyNums = &aPyraFamilyNums;
- aConnectivity = &aPyraConn;
- break;
- case 6:
- aNbConnectivity = aNbPentaConn;
- anElemNums = &anPentaElemNums;
- aFamilyNums = &aPentaFamilyNums;
- aConnectivity = &aPentaConn;
- break;
- case 8:
- aNbConnectivity = aNbHexaConn;
- anElemNums = &aHexaElemNums;
- aFamilyNums = &aHexaFamilyNums;
- aConnectivity = &aHexaConn;
- }
- MED::TIntVector aVector(aNbNodes);
- for(TInt iNode = 0; aNodesIter->more(); iNode++){
- const SMDS_MeshElement* aNode = aNodesIter->next();
- aVector[iNode] = aNode->GetID();
- }
- TInt aSize = aConnectivity->size();
- aConnectivity->resize(aSize+aNbConnectivity);
- // There is some difference between SMDS and MED in cells mapping
+ MED::TIntVector* anElemNums;
+ MED::TIntVector* aFamilyNums;
+
+ if (anElem->IsPoly()) {
+ const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
+ (const SMDS_PolyhedralVolumeOfNodes*) anElem;
+ if (!anElem) {
+ MESSAGE("Warning: bad volumic element");
+ continue;
+ }
+
+ anElemNums = &aPolyedreElemNums;
+ aFamilyNums = &aPolyedreFamilyNums;
+
+ TInt aNodeId, aNbFaces = aPolyedre->NbFaces();
+ for (int iface = 1; iface <= aNbFaces; iface++) {
+ int aNbFaceNodes = aPolyedre->NbFaceNodes(iface);
+ for (int inode = 1; inode <= aNbFaceNodes; inode++) {
+ aNodeId = aPolyedre->GetFaceNode(iface, inode)->GetID();
#ifdef _EDF_NODE_IDS_
- switch(aNbNodes){
- case 5:
- (*aConnectivity)[aSize+0] = aNodeIdMap[aVector[0]];
- (*aConnectivity)[aSize+1] = aNodeIdMap[aVector[3]];
- (*aConnectivity)[aSize+2] = aNodeIdMap[aVector[2]];
- (*aConnectivity)[aSize+3] = aNodeIdMap[aVector[1]];
- (*aConnectivity)[aSize+4] = aNodeIdMap[aVector[4]];
- default:
- for(TInt iNode = 0; iNode < aNbNodes; iNode++)
- (*aConnectivity)[aSize+iNode] = aNodeIdMap[aVector[iNode]];
- }
+ aPolyedreConn.push_back(aNodeIdMap[aNodeId]);
#else
- switch(aNbNodes){
- case 5:
- (*aConnectivity)[aSize+0] = aVector[0];
- (*aConnectivity)[aSize+1] = aVector[3];
- (*aConnectivity)[aSize+2] = aVector[2];
- (*aConnectivity)[aSize+3] = aVector[1];
- (*aConnectivity)[aSize+4] = aVector[4];
- default:
- for(TInt iNode = 0; iNode < aNbNodes; iNode++)
- (*aConnectivity)[aSize+iNode] = aVector[iNode];
- }
+ aPolyedreConn.push_back(aNodeId);
#endif
- anElemNums->push_back(anElem->GetID());
+ }
+ TInt aPrevPos = aPolyedreFaces.back();
+ aPolyedreFaces.push_back(aPrevPos + aNbFaceNodes);
+ }
+ TInt aPrevPos = aPolyedreInds.back();
+ aPolyedreInds.push_back(aPrevPos + aNbFaces);
+
+ } else {
+ TInt aNbNodes = anElem->NbNodes();
+ SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
+ TInt aNbConnectivity;
+ MED::TIntVector* aConnectivity;
+ switch(aNbNodes){
+ case 4:
+ aNbConnectivity = aNbTetraConn;
+ anElemNums = &anTetraElemNums;
+ aFamilyNums = &aTetraFamilyNums;
+ aConnectivity = &aTetraConn;
+ break;
+ case 5:
+ aNbConnectivity = aNbPyraConn;
+ anElemNums = &anPyraElemNums;
+ aFamilyNums = &aPyraFamilyNums;
+ aConnectivity = &aPyraConn;
+ break;
+ case 6:
+ aNbConnectivity = aNbPentaConn;
+ anElemNums = &anPentaElemNums;
+ aFamilyNums = &aPentaFamilyNums;
+ aConnectivity = &aPentaConn;
+ break;
+ case 8:
+ aNbConnectivity = aNbHexaConn;
+ anElemNums = &aHexaElemNums;
+ aFamilyNums = &aHexaFamilyNums;
+ aConnectivity = &aHexaConn;
+ }
+
+ TInt aSize = aConnectivity->size();
+ aConnectivity->resize(aSize + aNbConnectivity);
+
+ MED::TIntVector aVector(aNbNodes);
+ for(TInt iNode = 0; aNodesIter->more(); iNode++){
+ const SMDS_MeshElement* aNode = aNodesIter->next();
+#ifdef _EDF_NODE_IDS_
+ aVector[iNode] = aNodeIdMap[aNode->GetID()];
+#else
+ aVector[iNode] = aNode->GetID();
+#endif
+ }
+ // There is some difference between SMDS and MED in cells mapping
+ switch(aNbNodes){
+ case 5:
+ (*aConnectivity)[aSize+0] = aVector[0];
+ (*aConnectivity)[aSize+1] = aVector[3];
+ (*aConnectivity)[aSize+2] = aVector[2];
+ (*aConnectivity)[aSize+3] = aVector[1];
+ (*aConnectivity)[aSize+4] = aVector[4];
+ default:
+ for(TInt iNode = 0; iNode < aNbNodes; iNode++)
+ (*aConnectivity)[aSize+iNode] = aVector[iNode];
+ }
+ }
+
+ anElemNums->push_back(anElem->GetID());
if (anElemFamMap.find(anElem) != anElemFamMap.end())
aFamilyNums->push_back(anElemFamMap[anElem]);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo);
}
+ if(TInt aNbElems = aPolyedreElemNums.size()){
+ // add one element in connectivities,
+ // referenced by the last element in faces
+ aPolyedreConn.push_back(0);
+
+ PPolyedreInfo aCellInfo = myMed->CrPolyedreInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePOLYEDRE,
+ SMDS_MED_CONNECTIVITY,
+ aPolyedreConn,
+ aPolyedreFaces,
+ aPolyedreInds,
+ aPolyedreFamilyNums,
+ aPolyedreElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYEDRE<<"; aNbElems = "<<aNbElems);
+ myMed->SetPolyedreInfo(aCellInfo);
+ }
}
}catch(const std::exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.what());
aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
aFilter->RegisterCellsWithType(VTK_WEDGE);
aFilter->RegisterCellsWithType(VTK_PYRAMID);
+ aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
//Definition 1D divice of the actor
}
+ inline void AddPolygonsWithID(SMDS_Mesh* theMesh,
+ SMESH::log_array_var& theSeq,
+ CORBA::Long theId)
+ {
+ const SMESH::long_array& anIndexes = theSeq[theId].indexes;
+ CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
+
+ for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
+ int aFaceId = anIndexes[anIndexId++];
+
+ int aNbNodes = anIndexes[anIndexId++];
+ std::vector<int> nodes_ids (aNbNodes);
+ for (int i = 0; i < aNbNodes; i++) {
+ nodes_ids[i] = anIndexes[anIndexId++];
+ }
+
+ SMDS_MeshElement* anElem = theMesh->AddPolygonalFaceWithID(nodes_ids, aFaceId);
+ if (!anElem)
+ EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolygonalFaceWithID for ID = "
+ << anElemId);
+ }
+ }
+
+
inline void AddTetrasWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
anIndexes[anIndexId+4],
anIndexes[anIndexId]);
if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
+ EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
anIndexes[anIndexId+5],
anIndexes[anIndexId]);
if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
+ EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
anIndexes[anIndexId+6],
anIndexes[anIndexId]);
if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
+ EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
anIndexes[anIndexId+8],
anIndexes[anIndexId]);
if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
+ EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
+ }
+ }
+
+
+ inline void AddPolyhedronsWithID (SMDS_Mesh* theMesh,
+ SMESH::log_array_var& theSeq,
+ CORBA::Long theId)
+ {
+ const SMESH::long_array& anIndexes = theSeq[theId].indexes;
+ CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
+
+ for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
+ int aFaceId = anIndexes[anIndexId++];
+
+ int aNbNodes = anIndexes[anIndexId++];
+ std::vector<int> nodes_ids (aNbNodes);
+ for (int i = 0; i < aNbNodes; i++) {
+ nodes_ids[i] = anIndexes[anIndexId++];
+ }
+
+ int aNbFaces = anIndexes[anIndexId++];
+ std::vector<int> quantities (aNbFaces);
+ for (int i = 0; i < aNbFaces; i++) {
+ quantities[i] = anIndexes[anIndexId++];
+ }
+
+ SMDS_MeshElement* anElem =
+ theMesh->AddPolyhedralVolumeWithID(nodes_ids, quantities, aFaceId);
+ if (!anElem)
+ EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolyhedralVolumeWithID for ID = "
+ << anElemId);
+ }
+ }
+
+
+ inline void ChangePolyhedronNodes (SMDS_Mesh* theMesh,
+ SMESH::log_array_var& theSeq,
+ CORBA::Long theId)
+ {
+ const SMESH::long_array& anIndexes = theSeq[theId].indexes;
+ CORBA::Long iind = 0, aNbElems = theSeq[theId].number;
+
+ for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++)
+ {
+ // find element
+ const SMDS_MeshElement* elem = FindElement(theMesh, anIndexes[iind++]);
+ // nb nodes
+ int nbNodes = anIndexes[iind++];
+ // nodes
+ std::vector<const SMDS_MeshNode*> aNodes (nbNodes);
+ for (int iNode = 0; iNode < nbNodes; iNode++) {
+ aNodes[iNode] = FindNode(theMesh, anIndexes[iind++]);
+ }
+ // nb faces
+ int nbFaces = anIndexes[iind++];
+ // quantities
+ std::vector<int> quantities (nbFaces);
+ for (int iFace = 0; iFace < nbFaces; iFace++) {
+ quantities[iFace] = anIndexes[iind++];
+ }
+ // change
+ theMesh->ChangePolyhedronNodes(elem, aNodes, quantities);
}
}
// purpose : Get type of VTK cell
//=================================================================================
static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
+ const bool thePoly,
const int theNbNodes )
{
switch( theType )
case SMDSAbs_Edge:
return theNbNodes == 2 ? VTK_LINE : VTK_EMPTY_CELL;
- case SMDSAbs_Face :
- if ( theNbNodes == 3 ) return VTK_TRIANGLE;
- else if ( theNbNodes == 4 ) return VTK_QUAD;
- else return VTK_EMPTY_CELL;
+ case SMDSAbs_Face :
+ if (thePoly && theNbNodes>2 ) return VTK_POLYGON;
+ else if ( theNbNodes == 3 ) return VTK_TRIANGLE;
+ else if ( theNbNodes == 4 ) return VTK_QUAD;
+ else return VTK_EMPTY_CELL;
- case SMDSAbs_Volume:
- if ( theNbNodes == 4 ) return VTK_TETRA;
- else if ( theNbNodes == 5 ) return VTK_PYRAMID;
- else if ( theNbNodes == 6 ) return VTK_WEDGE;
- else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
- else return VTK_EMPTY_CELL;
+ case SMDSAbs_Volume:
+ if (thePoly && theNbNodes>3 ) return VTK_CONVEX_POINT_SET;
+ else if ( theNbNodes == 4 ) return VTK_TETRA;
+ else if ( theNbNodes == 5 ) return VTK_PYRAMID;
+ else if ( theNbNodes == 6 ) return VTK_WEDGE;
+ else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
+ else return VTK_EMPTY_CELL;
default: return VTK_EMPTY_CELL;
}
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
switch(aType){
case SMDSAbs_Volume:{
- int* aConnectivities = NULL;
+ std::vector<int> aConnectivities;
GetConnect(aNodesIter,aConnect);
// Convertions connectivities from SMDS to VTK
- switch(aNbNodes){
- case 4:{
- static int anIds[] = {0,2,1,3};
- aConnectivities = anIds;
- break;
+ 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++){
+ aConnectivities.push_back(k);
+ if (MYDEBUG) cout << " "<<k;
+ }
+ if (MYDEBUG) cout << endl;
}
- case 5:{
+ 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};
- aConnectivities = anIds;
- break;
+ for (int k=0; k<aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
- case 6:{
+ else if (aNbNodes == 6){
static int anIds[] = {0,1,2,3,4,5};
- aConnectivities = anIds;
- break;
+ for (int k=0; k<aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
- case 8:{
+ else if (aNbNodes == 8){
static int anIds[] = {0,3,2,1,4,7,6,5};
- aConnectivities = anIds;
- break;
- }}
+ for (int k=0; k<aNbNodes; k++) aConnectivities.push_back(anIds[k]);
+ }
- if(aConnectivities)
+ if(aConnectivities.size()>0){
for( vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++ )
SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
-
+ }
break;
}
default:
}
aConnectivity->InsertNextCell( anIdList );
- aCellTypesArray->InsertNextValue( getCellType( aType, aNbNodes ) );
+ aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(),aNbNodes ) );
iElem++;
}
if( !aLength )
return;
-
+
for ( CORBA::Long anId = 0; anId < aLength; anId++)
{
const SMESH::double_array& aCoords = aSeq[anId].coords;
const SMESH::long_array& anIndexes = aSeq[anId].indexes;
CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number;
CORBA::Long aCommand = aSeq[anId].commandType;
-
+
switch(aCommand)
{
- case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break;
- case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break;
- case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break;
- case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break;
- case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break;
- case SMESH::ADD_PYRAMID : AddPiramidsWithID( myMesh, aSeq, anId ); break;
- case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break;
- case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break;
-
+ case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_POLYGON : AddPolygonsWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_PYRAMID : AddPiramidsWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break;
+ case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( myMesh, aSeq, anId ); break;
+
case SMESH::REMOVE_NODE:
for( ; anElemId < aNbElems; anElemId++ )
myMesh->RemoveNode( FindNode( myMesh, anIndexes[anElemId] ) );
}
break;
+ case SMESH::CHANGE_POLYHEDRON_NODES:
+ ChangePolyhedronNodes(myMesh, aSeq, anId);
+ break;
case SMESH::RENUMBER:
for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3)
{
SMDS_IteratorOfElements.cxx \
SMDS_VolumeOfFaces.cxx \
SMDS_VolumeOfNodes.cxx \
+ SMDS_PolyhedralVolumeOfNodes.cxx \
SMDS_FaceOfEdges.cxx \
SMDS_FaceOfNodes.cxx \
+ SMDS_PolygonalFaceOfNodes.cxx \
SMDS_VolumeTool.cxx
# SMDS_Tria3OfNodes.cxx \
# SMDS_HexahedronOfNodes.cxx
SMDS_IteratorOfElements.hxx \
SMDS_VolumeOfFaces.hxx \
SMDS_VolumeOfNodes.hxx \
+ SMDS_PolyhedralVolumeOfNodes.hxx \
SMDS_FaceOfEdges.hxx \
SMDS_FaceOfNodes.hxx \
+ SMDS_PolygonalFaceOfNodes.hxx \
SMDS_VolumeTool.hxx
# SMDS_Tria3OfNodes.hxx \
# SMDS_HexahedronOfNodes.hxx
#include "SMDS_VolumeOfFaces.hxx"
#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_FaceOfEdges.hxx"
+#include "SMDS_PolyhedralVolumeOfNodes.hxx"
+#include "SMDS_PolygonalFaceOfNodes.hxx"
#include <algorithm>
#include <map>
return volume;
}
+///////////////////////////////////////////////////////////////////////////////
+/// Add a polygon defined by its nodes IDs
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
+ const int ID)
+{
+ int nbNodes = nodes_ids.size();
+ std::vector<const SMDS_MeshNode*> nodes (nbNodes);
+ for (int i = 0; i < nbNodes; i++) {
+ nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]);
+ if (!nodes[i]) return NULL;
+ }
+ return SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a polygon defined by its nodes
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
+ (std::vector<const SMDS_MeshNode*> nodes,
+ const int ID)
+{
+ SMDS_MeshFace * face;
+
+ if (hasConstructionEdges())
+ {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else
+ {
+ face = new SMDS_PolygonalFaceOfNodes(nodes);
+ myFaces.Add(face);
+ }
+
+ if (!registerElement(ID, face)) {
+ RemoveElement(face, false);
+ face = NULL;
+ }
+ return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a polygon defined by its nodes.
+/// An ID is automatically affected to the created face.
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes)
+{
+ return SMDS_Mesh::AddPolygonalFaceWithID(nodes, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Create a new polyhedral volume and add it to the mesh.
+/// @param ID The ID of the new volume
+/// @return The created volume or NULL if an element with this ID already exists
+/// or if input nodes are not found.
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume * SMDS_Mesh::AddPolyhedralVolumeWithID
+ (std::vector<int> nodes_ids,
+ std::vector<int> quantities,
+ const int ID)
+{
+ int nbNodes = nodes_ids.size();
+ std::vector<const SMDS_MeshNode*> nodes (nbNodes);
+ for (int i = 0; i < nbNodes; i++) {
+ nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]);
+ if (!nodes[i]) return NULL;
+ }
+ return SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Create a new polyhedral volume and add it to the mesh.
+/// @param ID The ID of the new volume
+/// @return The created volume
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities,
+ const int ID)
+{
+ SMDS_MeshVolume* volume;
+ if (hasConstructionFaces()) {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ } else if (hasConstructionEdges()) {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ } else {
+ volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities);
+ myVolumes.Add(volume);
+ }
+
+ if (!registerElement(ID, volume)) {
+ RemoveElement(volume, false);
+ volume = NULL;
+ }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Create a new polyhedral volume and add it to the mesh.
+/// @return The created volume
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ SMDS_MeshVolume * v = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
+ if (v == NULL) myElementIDFactory->ReleaseID(ID);
+ return v;
+}
+
///////////////////////////////////////////////////////////////////////////////
/// Registers element with the given ID, maintains inverse connections
///////////////////////////////////////////////////////////////////////////////
}
case SMDSAbs_Face: {
const SMDS_FaceOfNodes* face = dynamic_cast<const SMDS_FaceOfNodes*>( elem );
- if ( face )
+ if ( face ) {
Ok = const_cast<SMDS_FaceOfNodes*>( face )->ChangeNodes( nodes, nbnodes );
+ } else {
+ /// ??? begin
+ const SMDS_PolygonalFaceOfNodes* face = dynamic_cast<const SMDS_PolygonalFaceOfNodes*>(elem);
+ if (face) {
+ Ok = const_cast<SMDS_PolygonalFaceOfNodes*>(face)->ChangeNodes(nodes, nbnodes);
+ }
+ /// ??? end
+ }
break;
}
+ //case SMDSAbs_PolygonalFace: {
+ // const SMDS_PolygonalFaceOfNodes* face = dynamic_cast<const SMDS_PolygonalFaceOfNodes*>(elem);
+ // if (face) {
+ // Ok = const_cast<SMDS_PolygonalFaceOfNodes*>(face)->ChangeNodes(nodes, nbnodes);
+ // }
+ // break;
+ //}
case SMDSAbs_Volume: {
const SMDS_VolumeOfNodes* vol = dynamic_cast<const SMDS_VolumeOfNodes*>( elem );
if ( vol )
return Ok;
}
+//=======================================================================
+//function : ChangePolyhedronNodes
+//purpose : to change nodes of polyhedral volume
+//=======================================================================
+bool SMDS_Mesh::ChangePolyhedronNodes (const SMDS_MeshElement * elem,
+ std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities)
+{
+ if (elem->GetType() != SMDSAbs_Volume) {
+ MESSAGE("WRONG ELEM TYPE");
+ return false;
+ }
+
+ const SMDS_PolyhedralVolumeOfNodes* vol = dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>(elem);
+ if (!vol) {
+ return false;
+ }
+
+ // keep current nodes of elem
+ set<const SMDS_MeshElement*> oldNodes;
+ SMDS_ElemIteratorPtr itn = elem->nodesIterator();
+ while (itn->more()) {
+ oldNodes.insert(itn->next());
+ }
+
+ // change nodes
+ bool Ok = const_cast<SMDS_PolyhedralVolumeOfNodes*>(vol)->ChangeNodes(nodes, quantities);
+ if (!Ok) {
+ return false;
+ }
+
+ // update InverseElements
+
+ // AddInverseElement to new nodes
+ int nbnodes = nodes.size();
+ for (int i = 0; i < nbnodes; i++) {
+ if (oldNodes.find(nodes[i]) == oldNodes.end()) {
+ // new node
+ const_cast<SMDS_MeshNode*>(nodes[i])->AddInverseElement(elem);
+ } else {
+ // remove from oldNodes a node that remains in elem
+ oldNodes.erase(nodes[i]);
+ }
+ }
+
+ // RemoveInverseElement from the nodes removed from elem
+ set<const SMDS_MeshElement*>::iterator it;
+ for (it = oldNodes.begin(); it != oldNodes.end(); it++) {
+ SMDS_MeshNode * n = static_cast<SMDS_MeshNode *>
+ (const_cast<SMDS_MeshElement *>( *it ));
+ n->RemoveInverseElement(elem);
+ }
+
+ return Ok;
+}
+
//=======================================================================
//function : FindEdge
//purpose :
const SMDS_MeshFace * f5,
const SMDS_MeshFace * f6);
+ virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
+ const int ID);
+
+ virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<const SMDS_MeshNode*> nodes,
+ const int ID);
+
+ virtual SMDS_MeshFace* AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes);
+
+ virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
+ (std::vector<int> nodes_ids,
+ std::vector<int> quantities,
+ const int ID);
+
+ virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities,
+ const int ID);
+
+ virtual SMDS_MeshVolume* AddPolyhedralVolume
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities);
+
virtual void RemoveElement(const SMDS_MeshElement * elem,
std::list<const SMDS_MeshElement *>& removedElems,
std::list<const SMDS_MeshElement *>& removedNodes,
static bool ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[],
const int nbnodes);
+ static bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
+ std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities);
virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
// Renumber all nodes or elements.
///Return the type of the current element
virtual SMDSAbs_ElementType GetType() const = 0;
+ virtual bool IsPoly() const { return false; };
+
friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);
// the type of the group is determined by the first element added
if (myElements.empty()) myType = theElem->GetType();
else if (theElem->GetType() != myType)
- MESSAGE("SMDS_MeshGroup::Add : Type Mismatch");
+ MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
myElements.insert(theElem);
}
--- /dev/null
+// SMESH SMDS : implementaion of Salome mesh data structure
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
+#include "SMDS_PolygonalFaceOfNodes.hxx"
+
+#include "SMDS_IteratorOfElements.hxx"
+//#include "SMDS_MeshNode.hxx"
+#include "utilities.h"
+
+using namespace std;
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+SMDS_PolygonalFaceOfNodes::SMDS_PolygonalFaceOfNodes
+ (std::vector<const SMDS_MeshNode *> nodes)
+{
+ myNodes = nodes;
+}
+
+//=======================================================================
+//function : GetType
+//purpose :
+//=======================================================================
+SMDSAbs_ElementType SMDS_PolygonalFaceOfNodes::GetType() const
+{
+ return SMDSAbs_Face;
+ //return SMDSAbs_PolygonalFace;
+}
+
+//=======================================================================
+//function : ChangeNodes
+//purpose :
+//=======================================================================
+bool SMDS_PolygonalFaceOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode *> nodes)
+{
+ if (nodes.size() < 3)
+ return false;
+
+ myNodes = nodes;
+
+ return true;
+}
+
+//=======================================================================
+//function : ChangeNodes
+//purpose : to support the same interface, as SMDS_FaceOfNodes
+//=======================================================================
+bool SMDS_PolygonalFaceOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],
+ const int nbNodes)
+{
+ if (nbNodes < 3)
+ return false;
+
+ myNodes.resize(nbNodes);
+ int i = 0;
+ for (; i < nbNodes; i++) {
+ myNodes[i] = nodes[i];
+ }
+
+ return true;
+}
+
+//=======================================================================
+//function : NbNodes
+//purpose :
+//=======================================================================
+int SMDS_PolygonalFaceOfNodes::NbNodes() const
+{
+ return myNodes.size();
+}
+
+//=======================================================================
+//function : NbEdges
+//purpose :
+//=======================================================================
+int SMDS_PolygonalFaceOfNodes::NbEdges() const
+{
+ return NbNodes();
+}
+
+//=======================================================================
+//function : NbFaces
+//purpose :
+//=======================================================================
+int SMDS_PolygonalFaceOfNodes::NbFaces() const
+{
+ return 1;
+}
+
+//=======================================================================
+//function : Print
+//purpose :
+//=======================================================================
+void SMDS_PolygonalFaceOfNodes::Print(ostream & OS) const
+{
+ OS << "polygonal face <" << GetID() << " > : ";
+ int i, nbNodes = myNodes.size();
+ for (i = 0; i < nbNodes - 1; i++)
+ OS << myNodes[i] << ",";
+ OS << myNodes[i] << ") " << endl;
+}
+
+//=======================================================================
+//function : elementsIterator
+//purpose :
+//=======================================================================
+class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_ElemIterator
+{
+ //const SMDS_MeshNode* const *mySet;
+ const std::vector<const SMDS_MeshNode *> mySet;
+ //int myLength;
+ int index;
+ public:
+ //SMDS_PolygonalFaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
+ // mySet(s),myLength(l),index(0) {}
+ SMDS_PolygonalFaceOfNodes_MyIterator(const std::vector<const SMDS_MeshNode *> s):
+ mySet(s),index(0) {}
+
+ bool more()
+ {
+ return index < mySet.size();
+ }
+
+ const SMDS_MeshElement* next()
+ {
+ index++;
+ return mySet[index-1];
+ }
+};
+
+SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator
+ (SMDSAbs_ElementType type) const
+{
+ switch(type)
+ {
+ case SMDSAbs_Face:
+ return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
+ case SMDSAbs_Node:
+ return SMDS_ElemIteratorPtr(new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes));
+ case SMDSAbs_Edge:
+ MESSAGE("Error : edge iterator for SMDS_PolygonalFaceOfNodes not implemented");
+ break;
+ default:
+ return SMDS_ElemIteratorPtr
+ (new SMDS_IteratorOfElements
+ (this,type,SMDS_ElemIteratorPtr
+ (new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes))));
+ }
+ return SMDS_ElemIteratorPtr();
+}
--- /dev/null
+// SMESH SMDS : implementaion of Salome mesh data structure
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+#ifndef _SMDS_PolygonalFaceOfNodes_HeaderFile
+#define _SMDS_PolygonalFaceOfNodes_HeaderFile
+
+#include "SMDS_MeshFace.hxx"
+//#include "SMDS_FaceOfNodes.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_Iterator.hxx"
+
+#include <iostream>
+
+//class SMDS_PolygonalFaceOfNodes:public SMDS_FaceOfNodes
+class SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace
+{
+ public:
+ SMDS_PolygonalFaceOfNodes (std::vector<const SMDS_MeshNode *> nodes);
+
+ virtual SMDSAbs_ElementType GetType() const;
+ virtual bool IsPoly() const { return true; };
+
+ bool ChangeNodes (std::vector<const SMDS_MeshNode *> nodes);
+
+ bool ChangeNodes (const SMDS_MeshNode* nodes[],
+ const int nbNodes);
+ // to support the same interface, as SMDS_FaceOfNodes
+
+ virtual int NbNodes() const;
+ virtual int NbEdges() const;
+ virtual int NbFaces() const;
+
+ virtual void Print (std::ostream & OS) const;
+
+ protected:
+ virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
+
+ private:
+ std::vector<const SMDS_MeshNode *> myNodes;
+};
+
+#endif
--- /dev/null
+// SMESH SMDS : implementaion of Salome mesh data structure
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
+#include "SMDS_PolyhedralVolumeOfNodes.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "utilities.h"
+
+#include <set>
+
+using namespace std;
+
+//=======================================================================
+//function : Constructor
+//purpose : Create a volume of many faces
+//=======================================================================
+SMDS_PolyhedralVolumeOfNodes::SMDS_PolyhedralVolumeOfNodes
+ (std::vector<const SMDS_MeshNode *> nodes,
+ std::vector<int> quantities)
+: SMDS_VolumeOfNodes(NULL, NULL, NULL, NULL)
+{
+ ChangeNodes(nodes, quantities);
+}
+
+//=======================================================================
+//function : GetType
+//purpose :
+//=======================================================================
+SMDSAbs_ElementType SMDS_PolyhedralVolumeOfNodes::GetType() const
+{
+// return SMDSAbs_PolyhedralVolume;
+ return SMDSAbs_Volume;
+}
+
+//=======================================================================
+//function : ChangeNodes
+//purpose :
+//=======================================================================
+bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode *> nodes,
+ std::vector<int> quantities)
+{
+ myNodesByFaces = nodes;
+ myQuantities = quantities;
+
+ // Init fields of parent class
+ int aNbNodes = 0;
+ std::set<const SMDS_MeshNode *> aSet;
+ int nodes_len = nodes.size();
+ for (int j = 0; j < nodes_len; j++) {
+ if (aSet.find(nodes[j]) == aSet.end()) {
+ aSet.insert(nodes[j]);
+ aNbNodes++;
+ }
+ }
+
+ int k = 0;
+ const SMDS_MeshNode* aNodes [aNbNodes];
+ std::set<const SMDS_MeshNode *>::iterator anIter = aSet.begin();
+ for (; anIter != aSet.end(); anIter++, k++) {
+ aNodes[k] = *anIter;
+ }
+
+ //SMDS_VolumeOfNodes::ChangeNodes(aNodes, aNbNodes);
+ delete [] myNodes;
+ myNbNodes = aNbNodes;
+ myNodes = new const SMDS_MeshNode* [myNbNodes];
+ for (int i = 0; i < myNbNodes; i++) {
+ myNodes[i] = aNodes[i];
+ }
+
+ return true;
+}
+
+//=======================================================================
+//function : NbEdges
+//purpose :
+//=======================================================================
+int SMDS_PolyhedralVolumeOfNodes::NbEdges() const
+{
+ int nbEdges = 0;
+
+ for (int ifa = 0; ifa < myQuantities.size(); ifa++) {
+ nbEdges += myQuantities[ifa];
+ }
+ nbEdges /= 2;
+
+ return nbEdges;
+}
+
+//=======================================================================
+//function : NbFaces
+//purpose :
+//=======================================================================
+int SMDS_PolyhedralVolumeOfNodes::NbFaces() const
+{
+ return myQuantities.size();
+}
+
+//=======================================================================
+//function : NbFaceNodes
+//purpose :
+//=======================================================================
+int SMDS_PolyhedralVolumeOfNodes::NbFaceNodes (const int face_ind) const
+{
+ if (face_ind < 1 || myQuantities.size() < face_ind)
+ return 0;
+ return myQuantities[face_ind - 1];
+}
+
+//=======================================================================
+//function : GetFaceNode
+//purpose :
+//=======================================================================
+const SMDS_MeshNode* SMDS_PolyhedralVolumeOfNodes::GetFaceNode (const int face_ind,
+ const int node_ind) const
+{
+ if (node_ind < 1 || NbFaceNodes(face_ind) < node_ind)
+ return NULL;
+
+ int i, first_node = 0;
+ for (i = 0; i < face_ind - 1; i++) {
+ first_node += myQuantities[i];
+ }
+
+ return myNodesByFaces[first_node + node_ind - 1];
+}
+
+//=======================================================================
+//function : Print
+//purpose :
+//=======================================================================
+void SMDS_PolyhedralVolumeOfNodes::Print (ostream & OS) const
+{
+ OS << "polyhedral volume <" << GetID() << "> : ";
+
+ int faces_len = myQuantities.size();
+ //int nodes_len = myNodesByFaces.size();
+ int cur_first_node = 0;
+
+ int i, j;
+ for (i = 0; i < faces_len; i++) {
+ OS << "face_" << i << " (";
+ for (j = 0; j < myQuantities[i] - 1; j++) {
+ OS << myNodesByFaces[cur_first_node + j] << ",";
+ }
+ OS << myNodesByFaces[cur_first_node + j] << ") ";
+ cur_first_node += myQuantities[i];
+ }
+}
+
+//=======================================================================
+//function : ChangeNodes
+//purpose : usage disabled
+//=======================================================================
+bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],
+ const int nbNodes)
+{
+ return false;
+}
--- /dev/null
+// SMESH SMDS : implementaion of Salome mesh data structure
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMDS_PolyhedralVolumeOfNodes.hxx
+// Module : SMESH
+
+#ifndef _SMDS_PolyhedralVolumeOfNodes_HeaderFile
+#define _SMDS_PolyhedralVolumeOfNodes_HeaderFile
+
+#include "SMDS_VolumeOfNodes.hxx"
+
+class SMDS_PolyhedralVolumeOfNodes:public SMDS_VolumeOfNodes
+{
+ public:
+ SMDS_PolyhedralVolumeOfNodes (std::vector<const SMDS_MeshNode *> nodes,
+ std::vector<int> quantities);
+
+ //virtual ~SMDS_PolyhedralVolumeOfNodes();
+
+ virtual SMDSAbs_ElementType GetType() const;
+ virtual bool IsPoly() const { return true; };
+
+ bool ChangeNodes (std::vector<const SMDS_MeshNode *> nodes,
+ std::vector<int> quantities);
+
+ //virtual int NbNodes() const;
+ virtual int NbEdges() const;
+ virtual int NbFaces() const;
+
+ int NbFaceNodes (const int face_ind) const;
+ // 1 <= face_ind <= NbFaces()
+
+ const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
+ // 1 <= face_ind <= NbFaces()
+ // 1 <= node_ind <= NbFaceNodes()
+
+ virtual void Print (std::ostream & OS) const;
+
+ protected:
+ //virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
+
+ private:
+ // usage disabled
+ bool ChangeNodes (const SMDS_MeshNode* nodes[],
+ const int nbNodes);
+
+ private:
+ std::vector<const SMDS_MeshNode *> myNodesByFaces;
+ std::vector<int> myQuantities;
+};
+
+#endif
myNumber++;
}
+//=======================================================================
+//function : AddPolygonalFace
+//purpose :
+//=======================================================================
+void SMESHDS_Command::AddPolygonalFace (const int ElementID,
+ std::vector<int> nodes_ids)
+{
+ if (!myType == SMESHDS_AddPolygon) {
+ MESSAGE("SMESHDS_Command::AddPolygonalFace : Bad Type");
+ return;
+ }
+ myIntegers.push_back(ElementID);
+
+ int i, nbNodes = nodes_ids.size();
+ myIntegers.push_back(nbNodes);
+ for (i = 0; i < nbNodes; i++) {
+ myIntegers.push_back(nodes_ids[i]);
+ }
+
+ myNumber++;
+}
+
+//=======================================================================
+//function : AddPolyhedralVolume
+//purpose :
+//=======================================================================
+void SMESHDS_Command::AddPolyhedralVolume (const int ElementID,
+ std::vector<int> nodes_ids,
+ std::vector<int> quantities)
+{
+ if (!myType == SMESHDS_AddPolyhedron) {
+ MESSAGE("SMESHDS_Command::AddPolyhedralVolume : Bad Type");
+ return;
+ }
+ myIntegers.push_back(ElementID);
+
+ int i, nbNodes = nodes_ids.size();
+ myIntegers.push_back(nbNodes);
+ for (i = 0; i < nbNodes; i++) {
+ myIntegers.push_back(nodes_ids[i]);
+ }
+
+ int nbFaces = quantities.size();
+ myIntegers.push_back(nbFaces);
+ for (i = 0; i < nbFaces; i++) {
+ myIntegers.push_back(quantities[i]);
+ }
+
+ myNumber++;
+}
+
//=======================================================================
//function :
//purpose :
{
if (!myType == SMESHDS_ChangeElementNodes)
{
- MESSAGE("SMESHDS_Command::RemoveElement : Bad Type");
+ MESSAGE("SMESHDS_Command::ChangeElementNodes : Bad Type");
return;
}
myIntegers.push_back(ElementID);
myNumber++;
}
+//=======================================================================
+//function : ChangePolyhedronNodes
+//purpose :
+//=======================================================================
+void SMESHDS_Command::ChangePolyhedronNodes (const int ElementID,
+ std::vector<int> nodes_ids,
+ std::vector<int> quantities)
+{
+ if (myType != SMESHDS_ChangePolyhedronNodes)
+ {
+ MESSAGE("SMESHDS_Command::ChangePolyhedronNodes : Bad Type");
+ return;
+ }
+ myIntegers.push_back(ElementID);
+
+ int i, nbNodes = nodes_ids.size();
+ myIntegers.push_back(nbNodes);
+ for (i = 0; i < nbNodes; i++) {
+ myIntegers.push_back(nodes_ids[i]);
+ }
+
+ int nbFaces = quantities.size();
+ myIntegers.push_back(nbFaces);
+ for (i = 0; i < nbFaces; i++) {
+ myIntegers.push_back(quantities[i]);
+ }
+
+ myNumber++;
+}
+
//=======================================================================
//function : Renumber
//purpose :
#include "SMESHDS_CommandType.hxx"
#include <list>
+#include <vector>
class SMESHDS_Command
{
int idnode4, int idnode5, int idnode6);
void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6, int idnode7, int idnode8);
+ void AddPolygonalFace (const int ElementID,
+ std::vector<int> nodes_ids);
+ void AddPolyhedralVolume (const int ElementID,
+ std::vector<int> nodes_ids,
+ std::vector<int> quantities);
void MoveNode(int NewNodeID, double x, double y, double z);
void RemoveNode(int NodeID);
void RemoveElement(int ElementID);
void ChangeElementNodes(int ElementID, int nodes[], int nbnodes);
+ void ChangePolyhedronNodes(const int ElementID,
+ std::vector<int> nodes_ids,
+ std::vector<int> quantities);
void Renumber (const bool isNodes, const int startID, const int deltaID);
SMESHDS_CommandType GetType();
int GetNumber();
SMESHDS_AddEdge,
SMESHDS_AddTriangle,
SMESHDS_AddQuadrangle,
+ SMESHDS_AddPolygon,
SMESHDS_AddTetrahedron,
SMESHDS_AddPyramid,
SMESHDS_AddPrism,
SMESHDS_AddHexahedron,
+ SMESHDS_AddPolyhedron,
SMESHDS_RemoveNode,
SMESHDS_RemoveElement,
SMESHDS_MoveNode,
SMESHDS_ChangeElementNodes,
+ SMESHDS_ChangePolyhedronNodes,
SMESHDS_Renumber
};
if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
return false;
- ASSERT( nbnodes < 9 );
- int i, IDs[ 8 ];
+ //ASSERT( nbnodes < 9 );
+ //int i, IDs[ 8 ];
+ int i, IDs[ nbnodes ];
for ( i = 0; i < nbnodes; i++ )
IDs [ i ] = nodes[ i ]->GetID();
myScript->ChangeElementNodes( elem->GetID(), IDs, nbnodes);
return true;
}
+//=======================================================================
+//function : ChangePolyhedronNodes
+//purpose :
+//=======================================================================
+bool SMESHDS_Mesh::ChangePolyhedronNodes
+ (const SMDS_MeshElement * elem,
+ std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities)
+{
+ ASSERT(nodes.size() > 3);
+
+ if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
+ return false;
+
+ int i, len = nodes.size();
+ std::vector<int> nodes_ids (len);
+ for (i = 0; i < len; i++) {
+ nodes_ids[i] = nodes[i]->GetID();
+ }
+ myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
+
+ return true;
+}
+
//=======================================================================
//function : Renumber
//purpose :
n8->GetID());
return anElem;
}
+
+//=======================================================================
+//function : AddPolygonalFace
+//purpose :
+//=======================================================================
+SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
+ const int ID)
+{
+ SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
+ if (anElem) {
+ myScript->AddPolygonalFace(ID, nodes_ids);
+ }
+ return anElem;
+}
+
+SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
+ (std::vector<const SMDS_MeshNode*> nodes,
+ const int ID)
+{
+ SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
+ if (anElem) {
+ int i, len = nodes.size();
+ std::vector<int> nodes_ids (len);
+ for (i = 0; i < len; i++) {
+ nodes_ids[i] = nodes[i]->GetID();
+ }
+ myScript->AddPolygonalFace(ID, nodes_ids);
+ }
+ return anElem;
+}
+
+SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
+ (std::vector<const SMDS_MeshNode*> nodes)
+{
+ SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
+ if (anElem) {
+ int i, len = nodes.size();
+ std::vector<int> nodes_ids (len);
+ for (i = 0; i < len; i++) {
+ nodes_ids[i] = nodes[i]->GetID();
+ }
+ myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
+ }
+ return anElem;
+}
+
+//=======================================================================
+//function : AddPolyhedralVolume
+//purpose :
+//=======================================================================
+SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
+ std::vector<int> quantities,
+ const int ID)
+{
+ SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
+ if (anElem) {
+ myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
+ }
+ return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities,
+ const int ID)
+{
+ SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
+ if (anElem) {
+ int i, len = nodes.size();
+ std::vector<int> nodes_ids (len);
+ for (i = 0; i < len; i++) {
+ nodes_ids[i] = nodes[i]->GetID();
+ }
+ myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
+ }
+ return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities)
+{
+ SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
+ if (anElem) {
+ int i, len = nodes.size();
+ std::vector<int> nodes_ids (len);
+ for (i = 0; i < len; i++) {
+ nodes_ids[i] = nodes[i]->GetID();
+ }
+ myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
+ }
+ return anElem;
+}
+
//=======================================================================
//function : removeFromContainers
//purpose :
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8);
+ virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
+ const int ID);
+
+ virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<const SMDS_MeshNode*> nodes,
+ const int ID);
+
+ virtual SMDS_MeshFace* AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes);
+
+ virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
+ (std::vector<int> nodes_ids,
+ std::vector<int> quantities,
+ const int ID);
+
+ virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities,
+ const int ID);
+
+ virtual SMDS_MeshVolume* AddPolyhedralVolume
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities);
+
void MoveNode(const SMDS_MeshNode *, double x, double y, double z);
virtual void RemoveNode(const SMDS_MeshNode *);
void RemoveElement(const SMDS_MeshElement *);
bool ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[],
const int nbnodes);
+ bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
+ std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities);
void Renumber (const bool isNodes, const int startID=1, const int deltaID=1);
void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S);
idnode5, idnode6, idnode7, idnode8);
}
+//=======================================================================
+//function : AddPolygonalFace
+//purpose :
+//=======================================================================
+void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
+{
+ getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
+}
+
+//=======================================================================
+//function : AddPolyhedralVolume
+//purpose :
+//=======================================================================
+void SMESHDS_Script::AddPolyhedralVolume (int NewID,
+ std::vector<int> nodes_ids,
+ std::vector<int> quantities)
+{
+ getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
+ (NewID, nodes_ids, quantities);
+}
+
//=======================================================================
//function :
//purpose :
getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
}
+//=======================================================================
+//function : ChangePolyhedronNodes
+//purpose :
+//=======================================================================
+void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
+ std::vector<int> nodes_ids,
+ std::vector<int> quantities)
+{
+ getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
+ (ElementID, nodes_ids, quantities);
+}
+
//=======================================================================
//function : Renumber
//purpose :
#include "SMESHDS_Command.hxx"
#include <list>
+#include <vector>
class SMESHDS_Script
int idnode4, int idnode5, int idnode6);
void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6, int idnode7, int idnode8);
- void MoveNode(int NewNodeID, double x, double y, double z);
+
+ void AddPolygonalFace (const int NewFaceID,
+ std::vector<int> nodes_ids);
+ void AddPolyhedralVolume (const int NewVolID,
+ std::vector<int> nodes_ids,
+ std::vector<int> quantities);
+
+ void MoveNode(int NewNodeID, double x, double y, double z);
void RemoveNode(int NodeID);
void RemoveElement(int ElementID);
void ChangeElementNodes(int ElementID, int nodes[], int nbnodes);
+ void ChangePolyhedronNodes(const int ElementID,
+ std::vector<int> nodes_ids,
+ std::vector<int> quantities);
void Renumber (const bool isNodes, const int startID, const int deltaID);
void Clear();
const std::list<SMESHDS_Command*> & GetCommands();
case 401: // GEOM::EDGE
case 4021: // TRIANGLE
case 4022: // QUAD
+ case 4023: // POLYGON
case 4031: // TETRA
case 4032: // HEXA
+ case 4033: // POLYHEDRON
{
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
type = SMDSAbs_Face; nbNodes = 3; break;
case 4022: // QUAD
type = SMDSAbs_Face; nbNodes = 4; break;
+ case 4023: // POLYGON
+ type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
case 4031: // TETRA
type = SMDSAbs_Volume; nbNodes = 4; break;
case 4032: // HEXA
type = SMDSAbs_Volume; nbNodes = 8; break;
+ case 4033: // POLYHEDRE
+ type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
default:;
}
new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
Qt::WDestructiveClose)
{
+ myIsPoly = false;
mySimulation = new SMESH::TElementSimulation(SMESH::GetActiveStudy());
-
+
// verify nb nodes and type
myNbNodes = nbNodes;
myElementType = ElementType;
switch ( ElementType ) {
case SMDSAbs_Face:
- if ( myNbNodes != 3 && myNbNodes != 4 )
- myNbNodes = 3;
- break;
case SMDSAbs_Volume:
- if ( myNbNodes != 4 && myNbNodes != 8 ) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
- myNbNodes = 4;
break;
default:
myElementType = SMDSAbs_Edge;
}
QString elemName;
- switch ( myNbNodes ) {
- case 2: elemName = "EDGE"; break;
- case 3: elemName = "TRIANGLE"; break;
- case 4: elemName =
- myElementType == SMDSAbs_Face ? elemName = "QUADRANGLE" : elemName = "TETRAS"; break;
-// case 5:
-// case 6:
- default: // 8
+ if (myNbNodes == 2)
+ elemName = "EDGE";
+ else if (myNbNodes == 3)
+ elemName = "TRIANGLE";
+ else if (myNbNodes == 4)
+ if (myElementType == SMDSAbs_Face)
+ elemName = "QUADRANGLE";
+ else
+ elemName = "TETRAS";
+ else if (myNbNodes == 8)
elemName = "HEXAS";
+ else if (myElementType == SMDSAbs_Face){
+ elemName = "POLYGON";
+ myIsPoly = true;
}
+ else {
+ elemName = "POLYHEDRON";
+ myIsPoly = true;
+ }
+
QString iconName = tr( QString("ICON_DLG_%1").arg(elemName) );
QString buttonGrTitle = tr( QString("SMESH_%1").arg(elemName) );
QString caption = tr( QString("SMESH_ADD_%1_TITLE").arg(elemName) );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
// LineEditC1A1->setReadOnly( TRUE );
- LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator", myNbNodes ));
+ if (elemName != "POLYGON" && elemName != "POLYHEDRON")
+ LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator", myNbNodes));
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
if ( myElementType == SMDSAbs_Face ) {
else
allOk = false;
}
- myOkNodes = (allOk && myNbNodes == aListId.count() );
+
+ bool aNodesOK = false;
+ if (myIsPoly && myElementType == SMDSAbs_Face && aListId.count() >=3 ){
+ myNbNodes = aListId.count();
+ cout << __LINE__<<": ENK::DEBUG myNbNodes" << myNbNodes << endl;
+ aNodesOK = true;
+ } else if (myIsPoly && myElementType == SMDSAbs_Volume && aListId.count() >=4 ){
+ myNbNodes = aListId.count();
+ cout << __LINE__<<": ENK::DEBUG myNbNodes" << myNbNodes << endl;
+ aNodesOK = true;
+ } else if (!myIsPoly){
+ aNodesOK = (myNbNodes == aListId.count());
+ }
+ myOkNodes = (allOk && aNodesOK);//myNbNodes == aListId.count() );
if ( myOkNodes ) {
buttonOk->setEnabled( true );
myBusy = true;
myEditCurrentArgument->setText( aString );
myBusy = false;
- if ( myNbNodes != nbNodes )
+ if (myIsPoly && myElementType == SMDSAbs_Face && nbNodes>=3 ) {
+ } else if (myIsPoly && myElementType == SMDSAbs_Volume && nbNodes>=4){
+ } else if (myNbNodes != nbNodes)
return;
// OK
reverse(anIds.begin(),anIds.end());
vtkIdType aType = 0;
- switch ( myNbNodes ) {
- case 2: aType = VTK_LINE; break;
- case 3: aType = VTK_TRIANGLE; break;
- case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break;
- case 8: aType = VTK_HEXAHEDRON; break;
- default: return;
+ if (myIsPoly)
+ switch ( myElementType ) {
+ case SMDSAbs_Face : aType = VTK_POLYGON; break;
+ case SMDSAbs_Volume: aType = VTK_CONVEX_POINT_SET; break;
+ default: return;
+ }
+ else {
+ switch ( myNbNodes ) {
+ case 2: aType = VTK_LINE; break;
+ case 3: aType = VTK_TRIANGLE; break;
+ case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break;
+ case 8: aType = VTK_HEXAHEDRON; break;
+ default: return;
+ }
}
mySimulation->SetPosition(myActor,aType,anIds);
int myElementType ;
int myNbNodes;
+ bool myIsPoly;
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
QLabel* myMeshNbQuadranglesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_QUADRANGLES" ) ), myMeshFacesGroup, "myMeshNbQuadranglesLab" );
myMeshNbQuadrangles = new QLabel( myMeshFacesGroup, "myMeshNbQuadrangles" );
myMeshNbQuadrangles->setMinimumWidth( 100 );
+
+ // --> faces --> quadrangles
+ QLabel* myMeshNbPolygonesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_POLYGONES" ) ), myMeshFacesGroup, "myMeshNbPolygonesLab" );
+ myMeshNbPolygones = new QLabel( myMeshFacesGroup, "myMeshNbPolygones" );
+ myMeshNbPolygones->setMinimumWidth( 100 );
myMeshFacesGroupLayout->addWidget( myMeshNbFacesLab, 0, 0 );
myMeshFacesGroupLayout->addWidget( myMeshNbFaces, 0, 1 );
myMeshFacesGroupLayout->addWidget( myMeshNbTriangles, 1, 1 );
myMeshFacesGroupLayout->addWidget( myMeshNbQuadranglesLab, 2, 0 );
myMeshFacesGroupLayout->addWidget( myMeshNbQuadrangles, 2, 1 );
+ myMeshFacesGroupLayout->addWidget( myMeshNbPolygonesLab, 3, 0 );
+ myMeshFacesGroupLayout->addWidget( myMeshNbPolygones, 3, 1 );
// --> volumes
myMeshVolumesGroup = new QGroupBox( tr( "SMESH_MESHINFO_VOLUMES" ), myMeshWidget, "myMeshVolumesGroup" );
QLabel* myMeshNbPyraLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_PYRAS" ) ), myMeshVolumesGroup, "myMeshNbPyraLab" );
myMeshNbPyra = new QLabel( myMeshVolumesGroup, "myMeshNbPyra" );
myMeshNbPyra->setMinimumWidth( 100 );
+
+ // --> volumes --> polyherones
+ QLabel* myMeshNbPolyhedronesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_POLYEDRES" ) ), myMeshVolumesGroup, "myMeshNbPolyhedronLab" );
+ myMeshNbPolyhedrones = new QLabel( myMeshVolumesGroup, "myMeshNbPolyhedrones" );
+ myMeshNbPolyhedrones->setMinimumWidth( 100 );
myMeshVolumesGroupLayout->addWidget( myMeshNbVolumesLab, 0, 0 );
myMeshVolumesGroupLayout->addWidget( myMeshNbVolumes, 0, 1 );
myMeshVolumesGroupLayout->addWidget( myMeshNbPrism, 3, 1 );
myMeshVolumesGroupLayout->addWidget( myMeshNbPyraLab, 4, 0 );
myMeshVolumesGroupLayout->addWidget( myMeshNbPyra, 4, 1 );
+ myMeshVolumesGroupLayout->addWidget( myMeshNbPolyhedronesLab, 5, 0 );
+ myMeshVolumesGroupLayout->addWidget( myMeshNbPolyhedrones, 5, 1 );
aMeshLayout->addWidget( myMeshNameLab, 0, 0 );
aMeshLayout->addWidget( myMeshName, 0, 1 );
myMeshNbFaces->setNum( (int)aMesh->NbFaces() );
myMeshNbTriangles->setNum( (int)aMesh->NbTriangles() );
myMeshNbQuadrangles->setNum( (int)aMesh->NbQuadrangles() );
+ myMeshNbPolygones->setNum( (int)aMesh->NbPolygones() );
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() );
return;
}
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( anObject );
QLabel* myMeshNbFaces;
QLabel* myMeshNbTriangles;
QLabel* myMeshNbQuadrangles;
+ QLabel* myMeshNbPolygones;
QGroupBox* myMeshVolumesGroup;
QLabel* myMeshNbVolumes;
QLabel* myMeshNbTetra;
QLabel* myMeshNbHexa;
QLabel* myMeshNbPyra;
QLabel* myMeshNbPrism;
+ QLabel* myMeshNbPolyhedrones;
QWidget* mySubMeshWidget;
QLabel* mySubMeshName;
msgid "ICON_DLG_QUADRANGLE"
msgstr "mesh_quad.png"
+#Polygone
+msgid "ICON_DLG_POLYGON"
+msgstr "mesh_polygon.png"
+
#triangle
msgid "ICON_DLG_TETRAS"
msgstr "mesh_tetra.png"
msgid "ICON_DLG_HEXAS"
msgstr "mesh_hexa.png"
+#Polyhedre
+msgid "ICON_DLG_POLYHEDRON"
+msgstr "mesh_polyhedron.png"
+
#-----------------------------------------------------------
# ObjectBrowser
msgid "SMESH_ADD_TETRAS"
msgstr "Add Tetrahedron"
+#Add Polygone
+msgid "SMESH_ADD_POLYGONE"
+msgstr "Add Polygone"
+
+#Add Polyedre
+msgid "SMESH_ADD_POLYEDRE"
+msgstr "Add Polyedre"
+
#Add Hexahedron
msgid "SMESH_ADD_HEXAS"
msgstr "Add Hexahedron"
msgid "SMESH_MESHINFO_PYRAS"
msgstr "Pyramids"
+#Polygones :
+msgid "SMESH_MESHINFO_POLYGONES"
+msgstr "Polygones"
+
+#Polyedres :
+msgid "SMESH_MESHINFO_POLYEDRES"
+msgstr "Polyedres"
+
#Prisms :
msgid "SMESH_MESHINFO_PRISMS"
msgstr "Prisms"