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=c7014f268ac10d11a5683586aecff77c9694c0fa;hb=a274ade365bd0f0e19d56c577acc4a13aa1972a7;hpb=b5e94caaa397f2f5d4bf3b001d743b1525786b76 diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index c7014f268..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,6 @@ #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" @@ -81,54 +80,6 @@ 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 @@ -178,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 ) @@ -188,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 ) @@ -203,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; } //================================================================================= @@ -280,15 +231,15 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid) else { myLocalGrid = false; - if (!GetMesh()->isCompacted()) + if (!GetMesh()->IsCompacted()) { NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh() if ( MYDEBUG ) MESSAGE("*** buildPrs ==> compactMesh!"); - GetMesh()->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()); @@ -395,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); - } } } } @@ -463,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() ]); } } } @@ -504,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); } @@ -527,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 ); @@ -573,14 +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() )) { - NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh() - 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() + m->GetScript()->SetModified(false); // drop IsModified set in CompactMesh() updateEntitiesFlags(); - vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); + vtkUnstructuredGrid *theGrid = GetMesh()->GetGrid(); myGrid->ShallowCopy(theGrid); } return myGrid;