From 75d0234b452659c44159aaf33ed833af89a0ff4c Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 3 Nov 2016 18:55:09 +0300 Subject: [PATCH] IMP 23373: [CEA 1170] Optimization of a 3D mesh using MG-Tetra SMESHGUI_* - treat an algo that can work w/o geom only + fix a crash at mesh modif just after visualization SMDS_* - assure that grid->Links exist before grid->InsertNextLinkedCell() --- resources/StdMeshers.xml.in | 3 +- src/SMDS/SMDS_BallElement.cxx | 5 +- src/SMDS/SMDS_Mesh.hxx | 4 +- src/SMDS/SMDS_MeshElementIDFactory.cxx | 62 +++-- src/SMDS/SMDS_UnstructuredGrid.cxx | 89 ++++--- src/SMDS/SMDS_UnstructuredGrid.hxx | 5 - src/SMDS/SMDS_VtkEdge.cxx | 23 +- src/SMDS/SMDS_VtkFace.cxx | 54 ++--- src/SMDS/SMDS_VtkVolume.cxx | 269 ++++++++++------------ src/SMESH/SMESH_subMesh.cxx | 10 +- src/SMESHGUI/SMESHGUI_Hypotheses.cxx | 28 +-- src/SMESHGUI/SMESHGUI_Hypotheses.h | 10 +- src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx | 9 +- src/SMESHGUI/SMESHGUI_MeshOp.cxx | 14 +- src/SMESHGUI/SMESHGUI_XmlHandler.cxx | 5 +- src/SMESH_I/SMESH_DumpPython.cxx | 7 + src/SMESH_I/SMESH_Gen_i.cxx | 15 +- src/SMESH_I/SMESH_PythonDump.hxx | 3 + 18 files changed, 283 insertions(+), 332 deletions(-) diff --git a/resources/StdMeshers.xml.in b/resources/StdMeshers.xml.in index 3baade391..dc80071a7 100644 --- a/resources/StdMeshers.xml.in +++ b/resources/StdMeshers.xml.in @@ -45,7 +45,8 @@ input - geometry of elements accepted by algorithm input. Used to define compatible algos of different dimensions. Compatible algos have equal geometries in "input" and "output". need-hyp - (optional) Boolean. Does the algo require a hypothesis or not. Default is "false". - need-geom - (optional) Boolean. Can the algo work w/o geometry or not. Default is "true". + need-geom - (optional) [true, fasle, never]. Can the algo work w/o geometry or not. + Default is "true" "never" means that the algo can't work with geometry. support-submeshes - (optional) Boolean. Does an multi-dimensional algo support sub-meshes. Default is "false". diff --git a/src/SMDS/SMDS_BallElement.cxx b/src/SMDS/SMDS_BallElement.cxx index 22d2d0407..8cf426a91 100644 --- a/src/SMDS/SMDS_BallElement.cxx +++ b/src/SMDS/SMDS_BallElement.cxx @@ -47,10 +47,9 @@ SMDS_BallElement::SMDS_BallElement(vtkIdType nodeId, double diameter, SMDS_Mesh* void SMDS_BallElement::init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh) { SMDS_MeshCell::init(); - SMDS_UnstructuredGrid* grid = mesh->getGrid(); - myVtkID = grid->InsertNextLinkedCell( GetVtkType(), 1, &nodeId ); myMeshId = mesh->getMeshId(); - grid->SetBallDiameter( myVtkID, diameter ); + myVtkID = mesh->getGrid()->InsertNextLinkedCell( GetVtkType(), 1, &nodeId ); + mesh->getGrid()->SetBallDiameter( myVtkID, diameter ); mesh->setMyModified(); } diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index c0dc013b4..42777ffe9 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -73,8 +73,8 @@ public: static std::vector _meshList; //! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid - inline SMDS_UnstructuredGrid* getGrid() {return myGrid; } - inline int getMeshId() {return myMeshId; } + inline SMDS_UnstructuredGrid* getGrid() { return myGrid; } + inline int getMeshId() { return myMeshId; } virtual SMDS_NodeIteratorPtr nodesIterator (bool idInceasingOrder=false) const; virtual SMDS_EdgeIteratorPtr edgesIterator (bool idInceasingOrder=false) const; diff --git a/src/SMDS/SMDS_MeshElementIDFactory.cxx b/src/SMDS/SMDS_MeshElementIDFactory.cxx index 710be521b..a029b101e 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.cxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.cxx @@ -53,33 +53,29 @@ SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory(): int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem) { - // --- retrieve nodes ID + // --- retrieve nodes ID SMDS_MeshCell *cell = dynamic_cast(elem); assert(cell); - vector nodeIds; + vector nodeIds( elem->NbNodes() ); SMDS_ElemIteratorPtr it = elem->nodesIterator(); - while(it->more()) + for( int i = 0; it->more(); ++i ) { - int nodeId = (static_cast(it->next()))->getVtkId(); - MESSAGE(" node in cell " << cell->getVtkId() << " : " << nodeId) - nodeIds.push_back(nodeId); + int nodeId = (static_cast(it->next()))->getVtkId(); + nodeIds[i] = nodeId; } // --- insert cell in vtkUnstructuredGrid - vtkUnstructuredGrid * grid = myMesh->getGrid(); - //int locType = elem->GetType(); - int typ = VTK_VERTEX;//GetVtkCellType(locType); - int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]); - cell->setVtkId(cellId); - //MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId); + int typ = VTK_VERTEX; + int cellId = myMesh->getGrid()->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]); + cell->setVtkId(cellId); return cellId; } //======================================================================= //function : BindID -//purpose : +//purpose : //======================================================================= bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) @@ -122,17 +118,16 @@ int SMDS_MeshElementIDFactory::GetFreeID() void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId) { if (ID < 1) // TODO check case ID == O - { - MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID); - return; - } - //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId); + { + MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID); + return; + } if (vtkId >= 0) - { - assert(vtkId < (int)myMesh->myCellIdVtkToSmds.size()); - myMesh->myCellIdVtkToSmds[vtkId] = -1; - myMesh->setMyModified(); - } + { + assert(vtkId < (int)myMesh->myCellIdVtkToSmds.size()); + myMesh->myCellIdVtkToSmds[vtkId] = -1; + myMesh->setMyModified(); + } SMDS_MeshIDFactory::ReleaseID(ID); if (ID == myMax) myMax = 0; @@ -142,7 +137,7 @@ void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId) //======================================================================= //function : updateMinMax -//purpose : +//purpose : //======================================================================= void SMDS_MeshElementIDFactory::updateMinMax() const @@ -150,16 +145,16 @@ void SMDS_MeshElementIDFactory::updateMinMax() const myMin = INT_MAX; myMax = 0; for (size_t i = 0; i < myMesh->myCells.size(); i++) + { + if (myMesh->myCells[i]) { - if (myMesh->myCells[i]) - { - int id = myMesh->myCells[i]->GetID(); - if (id > myMax) - myMax = id; - if (id < myMin) - myMin = id; - } + int id = myMesh->myCells[i]->GetID(); + if (id > myMax) + myMax = id; + if (id < myMin) + myMin = id; } + } if (myMin == INT_MAX) myMin = 0; } @@ -171,12 +166,11 @@ void SMDS_MeshElementIDFactory::updateMinMax() const SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const { - return myMesh->elementsIterator(SMDSAbs_All); + return myMesh->elementsIterator(SMDSAbs_All); } void SMDS_MeshElementIDFactory::Clear() { - //myMesh->myCellIdSmdsToVtk.clear(); myMesh->myCellIdVtkToSmds.clear(); myMin = myMax = 0; SMDS_MeshIDFactory::Clear(); diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index 1f0f79941..e32eb798c 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -130,27 +130,18 @@ unsigned long SMDS_UnstructuredGrid::GetMTime() unsigned long mtime = vtkUnstructuredGrid::GetMTime(); return mtime; } -// OUV_PORTING_VTK6: seems to be useless -/* -void SMDS_UnstructuredGrid::Update() -{ - return vtkUnstructuredGrid::Update(); -} -void SMDS_UnstructuredGrid::UpdateInformation() -{ - return vtkUnstructuredGrid::UpdateInformation(); -} -*/ vtkPoints* SMDS_UnstructuredGrid::GetPoints() { // TODO erreur incomprehensible de la macro vtk GetPoints apparue avec la version paraview de fin aout 2010 return this->Points; } -//#ifdef VTK_HAVE_POLYHEDRON int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *pts) { + if ( !this->Links ) + BuildLinks(); + if (type != VTK_POLYHEDRON) return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts); @@ -162,26 +153,25 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p int nbfaces = npts; int i = 0; for (int nf = 0; nf < nbfaces; nf++) + { + int nbnodes = pts[i]; + i++; + for (int k = 0; k < nbnodes; k++) { - int nbnodes = pts[i]; + setOfNodes.insert(pts[i]); i++; - for (int k = 0; k < nbnodes; k++) - { - setOfNodes.insert(pts[i]); - i++; - } } + } set::iterator it = setOfNodes.begin(); for (; it != setOfNodes.end(); ++it) - { - this->Links->ResizeCellList(*it, 1); - this->Links->AddCellReference(cellid, *it); - } + { + this->Links->ResizeCellList(*it, 1); + this->Links->AddCellReference(cellid, *it); + } return cellid; } -//#endif void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh) { @@ -191,7 +181,6 @@ void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh) void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int newNodeSize, std::vector& idCellsOldToNew, int newCellSize) { - //MESSAGE("------------------------- compactGrid " << newNodeSize << " " << newCellSize);//CHRONO(1); int alreadyCopied = 0; this->DeleteLinks(); @@ -234,8 +223,16 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n int oldCellSize = this->Types->GetNumberOfTuples(); - if ( oldCellSize == newCellSize ) + if ( oldCellSize == newCellSize ) // no holes in elements { + this->Connectivity->Squeeze(); + this->Locations->Squeeze(); + this->Types->Squeeze(); + if ( this->FaceLocations ) + { + this->FaceLocations->Squeeze(); + this->Faces->Squeeze(); + } for ( int i = 0; i < oldCellSize; ++i ) idCellsOldToNew[i] = i; return; @@ -352,11 +349,11 @@ void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints, void *source = this->Points->GetVoidPointer(3 * start); int nbPoints = end - start; if (nbPoints > 0) - { - memcpy(target, source, 3 * sizeof(double) * nbPoints); - for (int j = start; j < end; j++) - idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId - } + { + memcpy(target, source, 3 * sizeof(double) * nbPoints); + for (int j = start; j < end; j++) + idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId + } } void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, @@ -370,24 +367,24 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, int end) { for (int j = start; j < end; j++) + { + newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); + idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId + vtkIdType oldLoc = this->Locations->GetValue(j); + vtkIdType nbpts; + vtkIdType *oldPtsCell = 0; + this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell); + assert(nbpts < NBMAXNODESINCELL); + for (int l = 0; l < nbpts; l++) { - newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); - idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId - vtkIdType oldLoc = this->Locations->GetValue(j); - vtkIdType nbpts; - vtkIdType *oldPtsCell = 0; - this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell); - assert(nbpts < NBMAXNODESINCELL); - for (int l = 0; l < nbpts; l++) - { - int oldval = oldPtsCell[l]; - pointsCell[l] = idNodesOldToNew[oldval]; - } - /*int newcnt = */newConnectivity->InsertNextCell(nbpts, pointsCell); - int newLoc = newConnectivity->GetInsertLocation(nbpts); - newLocations->SetValue(alreadyCopied, newLoc); - alreadyCopied++; + int oldval = oldPtsCell[l]; + pointsCell[l] = idNodesOldToNew[oldval]; } + /*int newcnt = */newConnectivity->InsertNextCell(nbpts, pointsCell); + int newLoc = newConnectivity->GetInsertLocation(nbpts); + newLocations->SetValue(alreadyCopied, newLoc); + alreadyCopied++; + } } int SMDS_UnstructuredGrid::CellIdToDownId(int vtkCellId) diff --git a/src/SMDS/SMDS_UnstructuredGrid.hxx b/src/SMDS/SMDS_UnstructuredGrid.hxx index d34095d9a..67dada6c9 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.hxx +++ b/src/SMDS/SMDS_UnstructuredGrid.hxx @@ -70,14 +70,9 @@ public: std::vector& idCellsOldToNew, int newCellSize); virtual unsigned long GetMTime(); - // OUV_PORTING_VTK6: seems to be useless - //virtual void Update(); - //virtual void UpdateInformation(); virtual vtkPoints *GetPoints(); - //#ifdef VTK_HAVE_POLYHEDRON int InsertNextLinkedCell(int type, int npts, vtkIdType *pts); - //#endif int CellIdToDownId(int vtkCellId); void setCellIdToDownId(int vtkCellId, int downId); diff --git a/src/SMDS/SMDS_VtkEdge.cxx b/src/SMDS/SMDS_VtkEdge.cxx index f365a30f2..edf40f78f 100644 --- a/src/SMDS/SMDS_VtkEdge.cxx +++ b/src/SMDS/SMDS_VtkEdge.cxx @@ -45,14 +45,10 @@ SMDS_VtkEdge::~SMDS_VtkEdge() void SMDS_VtkEdge::init(std::vector& nodeIds, SMDS_Mesh* mesh) { SMDS_MeshEdge::init(); - vtkUnstructuredGrid* grid = mesh->getGrid(); myMeshId = mesh->getMeshId(); - vtkIdType aType = VTK_LINE; - if (nodeIds.size() == 3) - aType = VTK_QUADRATIC_EDGE; - myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); + vtkIdType aType = ( nodeIds.size() == 3 ) ? VTK_QUADRATIC_EDGE : VTK_LINE; + myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); mesh->setMyModified(); - //MESSAGE("SMDS_VtkEdge::init myVtkID " << myVtkID); } bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2) @@ -69,14 +65,14 @@ bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) vtkIdType* pts = 0; grid->GetCellPoints(myVtkID, npts, pts); if (nbNodes != npts) - { - MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); - return false; - } + { + MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); + return false; + } for (int i = 0; i < nbNodes; i++) - { - pts[i] = nodes[i]->getVtkId(); - } + { + pts[i] = nodes[i]->getVtkId(); + } SMDS_Mesh::_meshList[myMeshId]->setMyModified(); return true; } @@ -87,7 +83,6 @@ bool SMDS_VtkEdge::IsMediumNode(const SMDS_MeshNode* node) const vtkIdType npts = 0; vtkIdType* pts = 0; grid->GetCellPoints(myVtkID, npts, pts); - //MESSAGE("IsMediumNode " << npts << " " << (node->getVtkId() == pts[npts-1])); return ((npts == 3) && (node->getVtkId() == pts[2])); } diff --git a/src/SMDS/SMDS_VtkFace.cxx b/src/SMDS/SMDS_VtkFace.cxx index a8a9b28ff..724a7ec21 100644 --- a/src/SMDS/SMDS_VtkFace.cxx +++ b/src/SMDS/SMDS_VtkFace.cxx @@ -44,53 +44,37 @@ SMDS_VtkFace::~SMDS_VtkFace() void SMDS_VtkFace::init(const std::vector& nodeIds, SMDS_Mesh* mesh) { SMDS_MeshFace::init(); - vtkUnstructuredGrid* grid = mesh->getGrid(); myMeshId = mesh->getMeshId(); vtkIdType aType = VTK_TRIANGLE; switch (nodeIds.size()) { - case 3: - aType = VTK_TRIANGLE; - break; - case 4: - aType = VTK_QUAD; - break; - case 6: - aType = VTK_QUADRATIC_TRIANGLE; - break; - case 8: - aType = VTK_QUADRATIC_QUAD; - break; - case 9: - aType = VTK_BIQUADRATIC_QUAD; - break; - case 7: - aType = VTK_BIQUADRATIC_TRIANGLE; - break; - default: - aType = VTK_POLYGON; - break; + case 3: aType = VTK_TRIANGLE; break; + case 4: aType = VTK_QUAD; break; + case 6: aType = VTK_QUADRATIC_TRIANGLE; break; + case 8: aType = VTK_QUADRATIC_QUAD; break; + case 9: aType = VTK_BIQUADRATIC_QUAD; break; + case 7: aType = VTK_BIQUADRATIC_TRIANGLE;break; + default: aType = VTK_POLYGON; } - myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]); + myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]); mesh->setMyModified(); - //MESSAGE("SMDS_VtkFace::init myVtkID " << myVtkID); } void SMDS_VtkFace::initPoly(const std::vector& nodeIds, SMDS_Mesh* mesh) { SMDS_MeshFace::init(); - vtkUnstructuredGrid* grid = mesh->getGrid(); myMeshId = mesh->getMeshId(); - myVtkID = grid->InsertNextLinkedCell(VTK_POLYGON, nodeIds.size(), (vtkIdType*) &nodeIds[0]); + vtkIdType aType = VTK_POLYGON; + myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]); mesh->setMyModified(); } void SMDS_VtkFace::initQuadPoly(const std::vector& nodeIds, SMDS_Mesh* mesh) { SMDS_MeshFace::init(); - vtkUnstructuredGrid* grid = mesh->getGrid(); myMeshId = mesh->getMeshId(); - myVtkID = grid->InsertNextLinkedCell(VTK_QUADRATIC_POLYGON, nodeIds.size(), (vtkIdType*) &nodeIds[0]); + vtkIdType aType = VTK_QUADRATIC_POLYGON; + myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]); mesh->setMyModified(); } @@ -101,14 +85,14 @@ bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) vtkIdType* pts = 0; grid->GetCellPoints(myVtkID, npts, pts); if (nbNodes != npts) - { - MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); - return false; - } + { + MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); + return false; + } for (int i = 0; i < nbNodes; i++) - { - pts[i] = nodes[i]->getVtkId(); - } + { + pts[i] = nodes[i]->getVtkId(); + } SMDS_Mesh::_meshList[myMeshId]->setMyModified(); return true; } diff --git a/src/SMDS/SMDS_VtkVolume.cxx b/src/SMDS/SMDS_VtkVolume.cxx index 2b717fc26..8f66ff084 100644 --- a/src/SMDS/SMDS_VtkVolume.cxx +++ b/src/SMDS/SMDS_VtkVolume.cxx @@ -41,57 +41,31 @@ SMDS_VtkVolume::SMDS_VtkVolume(const std::vector& nodeIds, SMDS_Mesh* void SMDS_VtkVolume::init(const std::vector& nodeIds, SMDS_Mesh* mesh) { SMDS_MeshVolume::init(); - vtkUnstructuredGrid* grid = mesh->getGrid(); myMeshId = mesh->getMeshId(); vtkIdType aType = VTK_TETRA; switch (nodeIds.size()) // cases are in order of usage frequency { - case 4: - aType = VTK_TETRA; - break; - case 8: - aType = VTK_HEXAHEDRON; - break; - case 5: - aType = VTK_PYRAMID; - break; - case 6: - aType = VTK_WEDGE; - break; - case 10: - aType = VTK_QUADRATIC_TETRA; - break; - case 20: - aType = VTK_QUADRATIC_HEXAHEDRON; - break; - case 13: - aType = VTK_QUADRATIC_PYRAMID; - break; - case 15: - aType = VTK_QUADRATIC_WEDGE; - break; - case 12: - aType = VTK_HEXAGONAL_PRISM; - break; - case 27: - aType = VTK_TRIQUADRATIC_HEXAHEDRON; - break; - default: - aType = VTK_HEXAHEDRON; - break; + case 4: aType = VTK_TETRA; break; + case 8: aType = VTK_HEXAHEDRON; break; + case 5: aType = VTK_PYRAMID; break; + case 6: aType = VTK_WEDGE; break; + case 10: aType = VTK_QUADRATIC_TETRA; break; + case 20: aType = VTK_QUADRATIC_HEXAHEDRON; break; + case 13: aType = VTK_QUADRATIC_PYRAMID; break; + case 15: aType = VTK_QUADRATIC_WEDGE; break; + case 12: aType = VTK_HEXAGONAL_PRISM; break; + case 27: aType = VTK_TRIQUADRATIC_HEXAHEDRON;break; + default: aType = VTK_HEXAHEDRON; } - myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType *) &nodeIds[0]); + myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType *) &nodeIds[0]); mesh->setMyModified(); - //MESSAGE("SMDS_VtkVolume::init myVtkID " << myVtkID); } -//#ifdef VTK_HAVE_POLYHEDRON void SMDS_VtkVolume::initPoly(const std::vector& nodeIds, const std::vector& nbNodesPerFace, SMDS_Mesh* mesh) { SMDS_MeshVolume::init(); - //MESSAGE("SMDS_VtkVolume::initPoly"); SMDS_UnstructuredGrid* grid = mesh->getGrid(); //double center[3]; //this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), ¢er[0]); @@ -99,36 +73,34 @@ void SMDS_VtkVolume::initPoly(const std::vector& nodeIds, vtkIdType nbFaces = nbNodesPerFace.size(); int k = 0; for (int i = 0; i < nbFaces; i++) - { - int nf = nbNodesPerFace[i]; - ptIds.push_back(nf); - // EAP: a right approach is: - // - either the user should care of order of nodes or - // - the user should use a service method arranging nodes if he - // don't want or can't to do it by him-self - // The method below works OK only with planar faces and convex polyhedrones - // - // double a[3]; - // double b[3]; - // double c[3]; - // grid->GetPoints()->GetPoint(nodeIds[k], a); - // grid->GetPoints()->GetPoint(nodeIds[k + 1], b); - // grid->GetPoints()->GetPoint(nodeIds[k + 2], c); - // bool isFaceForward = this->isForward(a, b, c, center); - //MESSAGE("isFaceForward " << i << " " << isFaceForward); - const vtkIdType *facePts = &nodeIds[k]; - //if (isFaceForward) - for (int n = 0; n < nf; n++) - ptIds.push_back(facePts[n]); - // else - // for (int n = nf - 1; n >= 0; n--) - // ptIds.push_back(facePts[n]); - k += nf; - } + { + int nf = nbNodesPerFace[i]; + ptIds.push_back(nf); + // EAP: a right approach is: + // - either the user should care of order of nodes or + // - the user should use a service method arranging nodes if he + // don't want or can't to do it by him-self + // The method below works OK only with planar faces and convex polyhedrones + // + // double a[3]; + // double b[3]; + // double c[3]; + // grid->GetPoints()->GetPoint(nodeIds[k], a); + // grid->GetPoints()->GetPoint(nodeIds[k + 1], b); + // grid->GetPoints()->GetPoint(nodeIds[k + 2], c); + // bool isFaceForward = this->isForward(a, b, c, center); + const vtkIdType *facePts = &nodeIds[k]; + //if (isFaceForward) + for (int n = 0; n < nf; n++) + ptIds.push_back(facePts[n]); + // else + // for (int n = nf - 1; n >= 0; n--) + // ptIds.push_back(facePts[n]); + k += nf; + } myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]); mesh->setMyModified(); } -//#endif bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) { @@ -137,14 +109,14 @@ bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes vtkIdType* pts = 0; grid->GetCellPoints(myVtkID, npts, pts); if (nbNodes != npts) - { - MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); - return false; - } + { + MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); + return false; + } for (int i = 0; i < nbNodes; i++) - { - pts[i] = nodes[i]->getVtkId(); - } + { + pts[i] = nodes[i]->getVtkId(); + } SMDS_Mesh::_meshList[myMeshId]->setMyModified(); return true; } @@ -156,10 +128,10 @@ bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes bool SMDS_VtkVolume::vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes) { if (nbNodes != this->NbNodes()) - { - MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes()); - return false; - } + { + MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes()); + return false; + } vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); vtkIdType aVtkType = grid->GetCellType(this->myVtkID); const std::vector& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( aVtkType )); @@ -230,23 +202,23 @@ int SMDS_VtkVolume::NbNodes() const vtkIdType aVtkType = grid->GetCellType(this->myVtkID); vtkIdType nbPoints = 0; if (aVtkType != VTK_POLYHEDRON) - { - vtkIdType *pts; - grid->GetCellPoints( myVtkID, nbPoints, pts ); - } + { + vtkIdType *pts; + grid->GetCellPoints( myVtkID, nbPoints, pts ); + } else + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0; + for (int i = 0; i < nFaces; i++) { - vtkIdType nFaces = 0; - vtkIdType* ptIds = 0; - grid->GetFaceStream(this->myVtkID, nFaces, ptIds); - int id = 0; - for (int i = 0; i < nFaces; i++) - { - int nodesInFace = ptIds[id]; - nbPoints += nodesInFace; - id += (nodesInFace + 1); - } + int nodesInFace = ptIds[id]; + nbPoints += nodesInFace; + id += (nodesInFace + 1); } + } return nbPoints; } @@ -311,22 +283,22 @@ int SMDS_VtkVolume::NbFaceNodes(const int face_ind) const vtkIdType aVtkType = grid->GetCellType(this->myVtkID); int nbNodes = 0; if (aVtkType == VTK_POLYHEDRON) + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0; + for (int i = 0; i < nFaces; i++) { - vtkIdType nFaces = 0; - vtkIdType* ptIds = 0; - grid->GetFaceStream(this->myVtkID, nFaces, ptIds); - int id = 0; - for (int i = 0; i < nFaces; i++) - { - int nodesInFace = ptIds[id]; - id += (nodesInFace + 1); - if (i == face_ind - 1) - { - nbNodes = nodesInFace; - break; - } - } + int nodesInFace = ptIds[id]; + id += (nodesInFace + 1); + if (i == face_ind - 1) + { + nbNodes = nodesInFace; + break; + } } + } return nbNodes; } @@ -341,23 +313,23 @@ const SMDS_MeshNode* SMDS_VtkVolume::GetFaceNode(const int face_ind, const int n vtkIdType aVtkType = grid->GetCellType(this->myVtkID); const SMDS_MeshNode* node = 0; if (aVtkType == VTK_POLYHEDRON) + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0; + for (int i = 0; i < nFaces; i++) { - vtkIdType nFaces = 0; - vtkIdType* ptIds = 0; - grid->GetFaceStream(this->myVtkID, nFaces, ptIds); - int id = 0; - for (int i = 0; i < nFaces; i++) - { - int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] - if (i == face_ind - 1) // first face is number 1 - { - if ((node_ind > 0) && (node_ind <= nodesInFace)) - node = mesh->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node - break; - } - id += (nodesInFace + 1); - } + int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] + if (i == face_ind - 1) // first face is number 1 + { + if ((node_ind > 0) && (node_ind <= nodesInFace)) + node = mesh->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node + break; + } + id += (nodesInFace + 1); } + } return node; } @@ -371,18 +343,18 @@ std::vector SMDS_VtkVolume::GetQuantities() const vtkUnstructuredGrid* grid = mesh->getGrid(); vtkIdType aVtkType = grid->GetCellType(this->myVtkID); if (aVtkType == VTK_POLYHEDRON) + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0; + for (int i = 0; i < nFaces; i++) { - vtkIdType nFaces = 0; - vtkIdType* ptIds = 0; - grid->GetFaceStream(this->myVtkID, nFaces, ptIds); - int id = 0; - for (int i = 0; i < nFaces; i++) - { - int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] - quantities.push_back(nodesInFace); - id += (nodesInFace + 1); - } + int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] + quantities.push_back(nodesInFace); + id += (nodesInFace + 1); } + } return quantities; } @@ -539,16 +511,15 @@ bool SMDS_VtkVolume::IsMediumNode(const SMDS_MeshNode* node) const grid->GetCellPoints(myVtkID, npts, pts); vtkIdType nodeId = node->getVtkId(); for (int rank = 0; rank < npts; rank++) + { + if (pts[rank] == nodeId) { - if (pts[rank] == nodeId) - { - if (rank < rankFirstMedium) - return false; - else - return true; - } + if (rank < rankFirstMedium) + return false; + else + return true; } - //throw SALOME_Exception(LOCALIZED("node does not belong to this element")); + } MESSAGE("======================================================"); MESSAGE("= IsMediumNode: node does not belong to this element ="); MESSAGE("======================================================"); @@ -609,11 +580,9 @@ SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const case VTK_HEXAGONAL_PRISM: aType = SMDSEntity_Hexagonal_Prism; break; -//#ifdef VTK_HAVE_POLYHEDRON case VTK_POLYHEDRON: aType = SMDSEntity_Polyhedra; break; -//#endif default: aType = SMDSEntity_Polyhedra; break; @@ -649,11 +618,9 @@ SMDSAbs_GeometryType SMDS_VtkVolume::GetGeomType() const case VTK_HEXAGONAL_PRISM: aType = SMDSGeom_HEXAGONAL_PRISM; break; -//#ifdef VTK_HAVE_POLYHEDRON case VTK_POLYHEDRON: aType = SMDSGeom_POLYHEDRA; break; -//#endif default: aType = SMDSGeom_POLYHEDRA; break; @@ -685,7 +652,6 @@ void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid, } for (int j = 0; j < 3; j++) result[j] = result[j] / nbNodes; - //MESSAGE("center " << result[0] << " " << result[1] << " " << result[2]); return; } @@ -693,16 +659,14 @@ bool SMDS_VtkVolume::isForward(double* a, double* b, double* c, double* d) { double u[3], v[3], w[3]; for (int j = 0; j < 3; j++) - { - //MESSAGE("a,b,c,d " << a[j] << " " << b[j] << " " << c[j] << " " << d[j]); - u[j] = b[j] - a[j]; - v[j] = c[j] - a[j]; - w[j] = d[j] - a[j]; - //MESSAGE("u,v,w " << u[j] << " " << v[j] << " " << w[j]); - } - double prodmixte = (u[1]*v[2] - u[2]*v[1]) * w[0] - + (u[2]*v[0] - u[0]*v[2]) * w[1] - + (u[0]*v[1] - u[1]*v[0]) * w[2]; + { + u[j] = b[j] - a[j]; + v[j] = c[j] - a[j]; + w[j] = d[j] - a[j]; + } + double prodmixte = ((u[1]*v[2] - u[2]*v[1]) * w[0] + + (u[2]*v[0] - u[0]*v[2]) * w[1] + + (u[0]*v[1] - u[1]*v[0]) * w[2] ); return (prodmixte < 0); } @@ -720,6 +684,5 @@ int SMDS_VtkVolume::NbUniqueNodes() const */ SMDS_ElemIteratorPtr SMDS_VtkVolume::uniqueNodesIterator() const { - //MESSAGE("uniqueNodesIterator"); return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); } diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index 128316dcf..8b44bcf17 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -1499,7 +1499,6 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) MESSAGE("std::bad_alloc thrown inside algo->Compute()"); if ( _computeError ) { _computeError->myName = COMPERR_MEMORY_PB; - //_computeError->myComment = exc.what(); } cleanSubMesh( this ); throw exc; @@ -1508,7 +1507,6 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) MESSAGE("Standard_OutOfMemory thrown inside algo->Compute()"); if ( _computeError ) { _computeError->myName = COMPERR_MEMORY_PB; - //_computeError->myComment = exc.what(); } cleanSubMesh( this ); throw std::bad_alloc(); @@ -1549,7 +1547,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) ret = false; // check if anything was built TopExp_Explorer subS(shape, _subShape.ShapeType()); - if (ret) + if ( ret ) { for (; ret && subS.More(); subS.Next()) if ( !_father->GetSubMesh( subS.Current() )->IsMeshComputed() && @@ -1558,9 +1556,9 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) ret = false; } // Set _computeError - if (!ret && !isComputeErrorSet) + if ( !ret && !isComputeErrorSet ) { - for (subS.ReInit(); subS.More(); subS.Next()) + for ( subS.ReInit(); subS.More(); subS.Next() ) { SMESH_subMesh* sm = _father->GetSubMesh( subS.Current() ); if ( !sm->IsMeshComputed() ) @@ -1574,7 +1572,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) } } } - if (ret && _computeError && _computeError->myName != COMPERR_WARNING ) + if ( ret && _computeError && _computeError->myName != COMPERR_WARNING ) { _computeError.reset(); } diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx index b1f0e20fa..446a9b67d 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx @@ -742,23 +742,23 @@ void SMESHGUI_HypothesisDlg::setType( const QString& t ) myTypeLabel->setText( t ); } -HypothesisData::HypothesisData( const QString& theTypeName, - const QString& thePluginName, - const QString& theServerLibName, - const QString& theClientLibName, - const QString& theLabel, - const QString& theIconId, - const QString& theContext, - const int theGroupID, - const int thePriority, - const QList& theDim, - const bool theIsAuxOrNeedHyp, +HypothesisData::HypothesisData( const QString& theTypeName, + const QString& thePluginName, + const QString& theServerLibName, + const QString& theClientLibName, + const QString& theLabel, + const QString& theIconId, + const QString& theContext, + const int theGroupID, + const int thePriority, + const QList& theDim, + const bool theIsAuxOrNeedHyp, const QStringList& theBasicHypos, const QStringList& theOptionalHypos, const QStringList& theInputTypes, const QStringList& theOutputTypes, - const bool theIsNeedGeometry, - const bool supportSub) + const int theIsNeedGeometry, + const bool theSupportSub) : TypeName( theTypeName ), PluginName( thePluginName ), ServerLibName( theServerLibName ), @@ -771,7 +771,7 @@ HypothesisData::HypothesisData( const QString& theTypeName, Dim( theDim ), IsAuxOrNeedHyp( theIsAuxOrNeedHyp ), IsNeedGeometry( theIsNeedGeometry ), - IsSupportSubmeshes( supportSub ), + IsSupportSubmeshes( theSupportSub ), BasicHypos( theBasicHypos ), OptionalHypos( theOptionalHypos ), InputTypes( theInputTypes ), diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.h b/src/SMESHGUI/SMESHGUI_Hypotheses.h index 0852bc60e..f989a49ff 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.h +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.h @@ -72,6 +72,9 @@ public: QString getMainShapeEntry() const { return myMainShapeEntry; } void setMainShapeEntry( const QString& theEntry ) { myMainShapeEntry = theEntry; } + void setNoGeomMesh( const bool noGeom ) { myNoGeomMesh = noGeom; } + bool getNoGeomMesh() const { return myNoGeomMesh; } + signals: void finished( int ); @@ -138,6 +141,7 @@ private: ListOfWidgets myParamWidgets; ListOfWidgets myParamLabels; bool myIsCreate; + bool myNoGeomMesh; //!< true for a mesh not based on geometry QtxDialog* myDlg; QString myShapeEntry; QString myMainShapeEntry; @@ -177,7 +181,7 @@ struct HypothesisData const QList&, const bool, const QStringList&, const QStringList&, const QStringList&, const QStringList&, - const bool=true, const bool supportSub=false ); + const int, const bool supportSub ); QString TypeName; //!< hypothesis type name QString PluginName; //!< plugin name @@ -191,7 +195,9 @@ struct HypothesisData QList Dim; //!< list of supported dimensions (see SMESH::Dimension enumeration) bool IsAuxOrNeedHyp; //!< TRUE if given HYPOTHESIS is auxiliary one, FALSE otherwise //!< TRUE if given ALGORITHM can't work w/o hypotheses - bool IsNeedGeometry; //!< TRUE if the algorithm works with shapes only, FALSE otherwise + int IsNeedGeometry; //!< 1 if the algorithm works with shapes only, + //!< -1 if the algorithm works without shapes only, + //!< 0 if the algorithm works in both cases bool IsSupportSubmeshes; //!< TRUE if the algorithm building all-dim elems supports sub-meshes // for algorithm only: dependencies algo <-> algo and algo -> hypos diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 71b812566..c1fc49bee 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -282,14 +282,14 @@ namespace SMESH QStringList GetAvailableHypotheses( const bool isAlgo, const int theDim, const bool isAux, - const bool isNeedGeometry, + const bool hasGeometry, const bool isSubMesh) { QStringList aHypList; // Init list of available hypotheses, if needed InitAvailableHypotheses(); - bool checkGeometry = ( !isNeedGeometry && isAlgo ); + bool checkGeometry = ( isAlgo ); const char* context = isSubMesh ? "LOCAL" : "GLOBAL"; // fill list of hypotheses/algorithms THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap; @@ -301,7 +301,8 @@ namespace SMESH ( theDim < 0 || aData->Dim.contains( theDim )) && ( isAlgo || aData->IsAuxOrNeedHyp == isAux ) && ( aData->Context == "ANY" || aData->Context == context ) && - ( !checkGeometry || aData->IsNeedGeometry == isNeedGeometry )) + ( !checkGeometry || (!aData->IsNeedGeometry || + ( aData->IsNeedGeometry > 0 ) == hasGeometry))) { aHypList.append(anIter.key()); } @@ -386,7 +387,7 @@ namespace SMESH QList dummyIL; dummyIL << 1; QStringList dummySL; HypothesisData group( dummyS,dummyS,dummyS,dummyS,dummyS,dummyS,dummyS,-1,-1, - dummyIL, 0, dummySL,dummySL,dummySL,dummySL ); + dummyIL, 0, dummySL,dummySL,dummySL,dummySL,0,0 ); // no group int key = 0; theGroups[ key ].push_back( group ); diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 8adb02804..52920773b 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -1192,12 +1192,9 @@ void SMESHGUI_MeshOp::initHypCreator( SMESHGUI_GenericHypothesisCreator* theCrea // Set shapes, of mesh and sub-mesh if any // get Entry of the Geom object - QString aGeomEntry = ""; - QString aMeshEntry = ""; - QString anObjEntry = ""; - aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom ); - aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ); - anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); + QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom ); + QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ); + QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); if ( myToCreate && myIsMesh ) aMeshEntry = aGeomEntry; @@ -1242,6 +1239,8 @@ void SMESHGUI_MeshOp::initHypCreator( SMESHGUI_GenericHypothesisCreator* theCrea theCreator->setShapeEntry( aGeomEntry ); if ( aMeshEntry != "" ) theCreator->setMainShapeEntry( aMeshEntry ); + + theCreator->setNoGeomMesh( !myIsOnGeometry && myIsMesh && !myToCreate ); } //================================================================================ @@ -1368,7 +1367,8 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim, aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) ); dialog = true; } - else { + else + { SMESH::SMESH_Hypothesis_var aHyp = SMESH::CreateHypothesis(theTypeName, aHypName, false); aHyp.out(); diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx index f164f4fe5..3482d7672 100644 --- a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx @@ -128,10 +128,11 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&, bool isAuxOrNeedHyp = ( qName == "hypothesis" ? atts.value("auxiliary") == "true" : atts.value("need-hyp" ) == "true" ); - bool isNeedGeom = true, isSupportSubmeshes = false; + int isNeedGeom = 1; + bool isSupportSubmeshes = false; QString aNeedGeom = atts.value("need-geom"); if ( !aNeedGeom.isEmpty() ) - isNeedGeom = (aNeedGeom == "true"); + isNeedGeom = (aNeedGeom == "true") ? 1 : (aNeedGeom == "never") ? -1 : 0; QString suppSub = atts.value("support-submeshes"); if ( !suppSub.isEmpty() ) isSupportSubmeshes = (suppSub == "true"); diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index 1beee9b48..e22a87c77 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -162,6 +162,13 @@ namespace SMESH return *this; } + TPythonDump& + TPythonDump:: + operator<<(const std::string& theArg){ + myStream<_is_nil() ) // not a sole mesh { - GEOM::GEOM_Object_var s1 = mesh_i ->GetShapeToMesh(); - GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh(); - if ( ! ( isSole = s1->IsSame( s2 ))) - break; + if ( !foundMesh->HasShapeToMesh() || + !mesh_i ->HasShapeToMesh() ) + { + isSole = ( foundMesh->HasShapeToMesh() == mesh_i->HasShapeToMesh() ); + } + else + { + GEOM::GEOM_Object_var s1 = mesh_i ->GetShapeToMesh(); + GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh(); + isSole = s1->IsSame( s2 ); + } } foundMesh = SMESH::SMESH_Mesh::_narrow( obj ); } diff --git a/src/SMESH_I/SMESH_PythonDump.hxx b/src/SMESH_I/SMESH_PythonDump.hxx index 8f1a79715..7fb82c564 100644 --- a/src/SMESH_I/SMESH_PythonDump.hxx +++ b/src/SMESH_I/SMESH_PythonDump.hxx @@ -234,6 +234,9 @@ namespace SMESH TPythonDump& operator<<(const SMESH::CoincidentFreeBorders& theCFB); + TPythonDump& + operator<<(const std::string& theArg); + static const char* SMESHGenName() { return "smeshgen"; } static const char* MeshEditorName() { return "mesh_editor"; } static const char* NotPublishedObjectName(); -- 2.39.2