X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_Object.cxx;h=af6410d1792d3864aede72d9e4cfccb9f8eecb79;hp=2997063e5ace9f902c3de26869090a20c0bf25c9;hb=a274ade365bd0f0e19d56c577acc4a13aa1972a7;hpb=c98d9fcd7f02c1f1f5c24dd3e709ed75228d66c4 diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 2997063e5..af6410d17 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -31,7 +31,8 @@ #include "SMDS_BallElement.hxx" #include "SMDS_Mesh.hxx" #include "SMDS_MeshCell.hxx" -#include "SMDS_PolyhedralVolumeOfNodes.hxx" +#include "SMESHDS_Mesh.hxx" +#include "SMESHDS_Script.hxx" #include "SMESH_Actor.h" #include "SMESH_ControlsDef.hxx" @@ -54,7 +55,7 @@ #include #include -#include "utilities.h" +#include using namespace std; @@ -67,7 +68,7 @@ using namespace std; #endif #ifdef _DEBUG_ -static int MYDEBUG = 1; +static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0;//1; #else static int MYDEBUG = 0; @@ -79,61 +80,13 @@ static int MYDEBUGWITHFILES = 0; Class : SMESH_VisualObjDef Description : Base class for all mesh objects to be visuilised */ - -//================================================================================= -// function : getCellType -// purpose : Get type of VTK cell -//================================================================================= -// static inline vtkIdType getCellType( const SMDSAbs_ElementType theType, -// const bool thePoly, -// const int theNbNodes ) -// { -// switch( theType ) -// { -// case SMDSAbs_0DElement: return VTK_VERTEX; - -// case SMDSAbs_Ball: return VTK_POLY_VERTEX; - -// case SMDSAbs_Edge: -// if( theNbNodes == 2 ) return VTK_LINE; -// else if ( theNbNodes == 3 ) return VTK_QUADRATIC_EDGE; -// 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 if ( theNbNodes == 6 ) return VTK_QUADRATIC_TRIANGLE; -// else if ( theNbNodes == 8 ) return VTK_QUADRATIC_QUAD; -// else if ( theNbNodes == 9 ) return VTK_BIQUADRATIC_QUAD; -// else if ( theNbNodes == 7 ) return VTK_BIQUADRATIC_TRIANGLE; -// else return VTK_EMPTY_CELL; - -// case SMDSAbs_Volume: -// if (thePoly && theNbNodes>3 ) return VTK_POLYHEDRON; //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 if ( theNbNodes == 12 ) return VTK_HEXAGONAL_PRISM; -// else if ( theNbNodes == 10 ) return VTK_QUADRATIC_TETRA; -// else if ( theNbNodes == 20 ) return VTK_QUADRATIC_HEXAHEDRON; -// else if ( theNbNodes == 27 ) return VTK_TRIQUADRATIC_HEXAHEDRON; -// else if ( theNbNodes == 15 ) return VTK_QUADRATIC_WEDGE; -// else if ( theNbNodes == 13 ) return VTK_QUADRATIC_PYRAMID; //VTK_CONVEX_POINT_SET; -// else return VTK_EMPTY_CELL; - -// default: return VTK_EMPTY_CELL; -// } -// } - //================================================================================= // functions : SMESH_VisualObjDef // purpose : Constructor //================================================================================= SMESH_VisualObjDef::SMESH_VisualObjDef() { - MESSAGE("---------------------------------------------SMESH_VisualObjDef::SMESH_VisualObjDef"); + if ( MYDEBUG ) MESSAGE("-------------------------------SMESH_VisualObjDef::SMESH_VisualObjDef"); myGrid = vtkUnstructuredGrid::New(); myLocalGrid = false; ClearEntitiesFlags(); @@ -141,9 +94,8 @@ SMESH_VisualObjDef::SMESH_VisualObjDef() } SMESH_VisualObjDef::~SMESH_VisualObjDef() { - MESSAGE("---------------------------------------------SMESH_VisualObjDef::~SMESH_VisualObjDef"); - //if ( MYDEBUG ) - MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() ); + if ( MYDEBUG ) MESSAGE("--------------------------------SMESH_VisualObjDef::~SMESH_VisualObjDef"); + if ( MYDEBUG ) MESSAGE( "myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() ); myGrid->Delete(); } @@ -177,7 +129,7 @@ vtkIdType SMESH_VisualObjDef::GetNodeVTKId( int theObjID ) if( this->GetMesh() ) { aNode = this->GetMesh()->FindNode(theObjID); } - return aNode ? aNode->getVtkId() : -1; + return aNode ? aNode->GetVtkID() : -1; } vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID ) @@ -187,7 +139,7 @@ vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID ) TMapOfIds::const_iterator i = myVTK2SMDSElems.find(theVTKID); return i == myVTK2SMDSElems.end() ? -1 : i->second; } - return this->GetMesh()->fromVtkToSmds(theVTKID); + return this->GetMesh()->FromVtkToSmds(theVTKID); } vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID ) @@ -202,7 +154,7 @@ vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID ) if ( this->GetMesh() ) e = this->GetMesh()->FindElement(theObjID); - return e ? e->getVtkId() : -1; + return e ? e->GetVtkID() : -1; } //================================================================================= @@ -248,7 +200,7 @@ void SMESH_VisualObjDef::createPoints( vtkPoints* thePoints ) //================================================================================= void SMESH_VisualObjDef::buildPrs(bool buildGrid) { - MESSAGE("----------------------------------------------------------SMESH_VisualObjDef::buildPrs " << buildGrid); + if ( MYDEBUG ) MESSAGE("---------------------------SMESH_VisualObjDef::buildPrs " << buildGrid); if (buildGrid) { myLocalGrid = true; @@ -279,12 +231,15 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid) else { myLocalGrid = false; - if (!GetMesh()->isCompacted()) + if (!GetMesh()->IsCompacted()) { - MESSAGE("*** buildPrs ==> compactMesh!"); - GetMesh()->compactMesh(); + NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh() + if ( MYDEBUG ) MESSAGE("*** buildPrs ==> compactMesh!"); + GetMesh()->CompactMesh(); + if ( SMESHDS_Mesh* m = dynamic_cast( GetMesh() )) // IPAL53915 + m->GetScript()->SetModified(false); // drop IsModified set in compactMesh() } - vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); + vtkUnstructuredGrid *theGrid = GetMesh()->GetGrid(); updateEntitiesFlags(); myGrid->ShallowCopy(theGrid); //MESSAGE(myGrid->GetReferenceCount()); @@ -391,17 +346,16 @@ void SMESH_VisualObjDef::buildElemPrs() if((*anIter)->GetEntityType() != SMDSEntity_Polyhedra && (*anIter)->GetEntityType() != SMDSEntity_Quad_Polyhedra) { aCellsSize += (*anIter)->NbNodes() + 1; - } + } // Special case for the VTK_POLYHEDRON: // itsinput cellArray is of special format. - // [nCellFaces, nFace0Pts, i, j, k, nFace1Pts, i, j, k, ...] + // [nCellFaces, nFace0Pts, i, j, k, nFace1Pts, i, j, k, ...] else { - if( const SMDS_VtkVolume* ph = dynamic_cast(*anIter) ) { + if ( const SMDS_MeshVolume* ph = SMDS_Mesh::DownCast( *anIter )) { int nbFaces = ph->NbFaces(); aCellsSize += (1 + ph->NbFaces()); - for( int i = 1; i <= nbFaces; i++ ) { + for( int i = 1; i <= nbFaces; i++ ) aCellsSize += ph->NbFaceNodes(i); - } } } } @@ -459,20 +413,18 @@ void SMESH_VisualObjDef::buildElemPrs() SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); { - // Convertions connectivities from SMDS to VTK + // Convert connectivities from SMDS to VTK if (aType == SMDSAbs_Volume && anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE anIdList->Reset(); - if ( const SMDS_VtkVolume* ph = dynamic_cast(anElem) ) { + if ( const SMDS_MeshVolume* ph = SMDS_Mesh::DownCast( anElem )) { int nbFaces = ph->NbFaces(); anIdList->InsertNextId(nbFaces); for( int i = 1; i <= nbFaces; i++ ) { anIdList->InsertNextId(ph->NbFaceNodes(i)); for(int j = 1; j <= ph->NbFaceNodes(i); j++) { - const SMDS_MeshNode* n = ph->GetFaceNode(i,j); - if(n) { - anIdList->InsertNextId(mySMDS2VTKNodes[n->GetID()]); - } + if ( const SMDS_MeshNode* n = ph->GetFaceNode( i, j )) + anIdList->InsertNextId( mySMDS2VTKNodes[ n->GetID() ]); } } } @@ -500,11 +452,8 @@ void SMESH_VisualObjDef::buildElemPrs() //Store diameters of the balls if(aScalars) { double aDiam = 0; - if(aType == SMDSAbs_Ball) { - if (const SMDS_BallElement* ball = dynamic_cast(anElem) ) { - aDiam = ball->GetDiameter(); - } - } + if (const SMDS_BallElement* ball = SMDS_Mesh::DownCast(anElem) ) + aDiam = ball->GetDiameter(); aScalars->SetTuple(aCurId,&aDiam); } @@ -523,7 +472,8 @@ void SMESH_VisualObjDef::buildElemPrs() SMDS_Mesh::CheckMemory(); // PAL16631 aConnectivity->InitTraversal(); - for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) + vtkIdType const *pts(nullptr); + for( vtkIdType idType = 0, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); myGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); @@ -569,11 +519,15 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid() { - if ( !myLocalGrid && !GetMesh()->isCompacted() ) + if ( !myLocalGrid && ( !GetMesh()->IsCompacted() || // !IsCompacted() is needed ??? + GetMesh()->GetGrid()->GetMTime() > myGrid->GetMTime() )) { - GetMesh()->compactMesh(); + NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in CompactMesh() + GetMesh()->CompactMesh(); + if ( SMESHDS_Mesh* m = dynamic_cast( GetMesh() )) // IPAL53915 + m->GetScript()->SetModified(false); // drop IsModified set in CompactMesh() updateEntitiesFlags(); - vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); + vtkUnstructuredGrid *theGrid = GetMesh()->GetGrid(); myGrid->ShallowCopy(theGrid); } return myGrid; @@ -697,9 +651,9 @@ SMESH_MeshObj::~SMESH_MeshObj() bool SMESH_MeshObj::Update( int theIsClear ) { // Update SMDS_Mesh on client part - MESSAGE("SMESH_MeshObj::Update " << this); + if ( MYDEBUG ) MESSAGE("SMESH_MeshObj::Update " << this); if ( myClient.Update(theIsClear) || GetUnstructuredGrid()->GetNumberOfPoints()==0) { - MESSAGE("buildPrs"); + if ( MYDEBUG ) MESSAGE("buildPrs"); buildPrs(); // Fill unstructured grid return true; } @@ -708,7 +662,7 @@ bool SMESH_MeshObj::Update( int theIsClear ) bool SMESH_MeshObj::NulData() { - MESSAGE ("SMESH_MeshObj::NulData() =================================================================================="); + if ( MYDEBUG ) MESSAGE ("SMESH_MeshObj::NulData() ============================================="); if (!myEmptyGrid) { myEmptyGrid = SMDS_UnstructuredGrid::New(); @@ -718,7 +672,7 @@ bool SMESH_MeshObj::NulData() points->SetNumberOfPoints(0); myEmptyGrid->SetPoints( points ); points->Delete(); - myEmptyGrid->BuildLinks(); + //myEmptyGrid->BuildLinks(); } myGrid->ShallowCopy(myEmptyGrid); return true; @@ -901,7 +855,7 @@ void SMESH_SubMeshObj::UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunc //================================================================================= bool SMESH_SubMeshObj::Update( int theIsClear ) { - MESSAGE("SMESH_SubMeshObj::Update " << this) + if ( MYDEBUG ) MESSAGE("SMESH_SubMeshObj::Update " << this) bool changed = myMeshObj->Update( theIsClear ); buildPrs(true); return changed;