-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019 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
#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"
#include <stdexcept>
#include <set>
-#include "utilities.h"
+#include <utilities.h>
using namespace std;
#endif
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;//1;
#else
static int MYDEBUG = 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();
}
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();
}
if( this->GetMesh() ) {
aNode = this->GetMesh()->FindNode(theObjID);
}
- return aNode ? aNode->getVtkId() : -1;
+ return aNode ? aNode->GetVtkID() : -1;
}
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 )
if ( this->GetMesh() )
e = this->GetMesh()->FindElement(theObjID);
- return e ? e->getVtkId() : -1;
+ return e ? e->GetVtkID() : -1;
}
//=================================================================================
//=================================================================================
void SMESH_VisualObjDef::buildPrs(bool buildGrid)
{
- MESSAGE("----------------------------------------------------------SMESH_VisualObjDef::buildPrs " << buildGrid);
+ if ( MYDEBUG ) MESSAGE("---------------------------SMESH_VisualObjDef::buildPrs " << buildGrid);
if (buildGrid)
{
myLocalGrid = true;
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<SMESHDS_Mesh*>( 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());
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<const SMDS_VtkVolume*>(*anIter) ) {
+ if ( const SMDS_MeshVolume* ph = SMDS_Mesh::DownCast<SMDS_MeshVolume>( *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);
- }
}
}
}
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<const SMDS_VtkVolume*>(anElem) ) {
+ if ( const SMDS_MeshVolume* ph = SMDS_Mesh::DownCast<SMDS_MeshVolume>( 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() ]);
}
}
}
//Store diameters of the balls
if(aScalars) {
double aDiam = 0;
- if(aType == SMDSAbs_Ball) {
- if (const SMDS_BallElement* ball = dynamic_cast<const SMDS_BallElement*>(anElem) ) {
- aDiam = ball->GetDiameter();
- }
- }
+ if (const SMDS_BallElement* ball = SMDS_Mesh::DownCast<SMDS_BallElement>(anElem) )
+ aDiam = ball->GetDiameter();
aScalars->SetTuple(aCurId,&aDiam);
}
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<SMESHDS_Mesh*>( 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;
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;
}
bool SMESH_MeshObj::NulData()
{
- MESSAGE ("SMESH_MeshObj::NulData() ==================================================================================");
+ if ( MYDEBUG ) MESSAGE ("SMESH_MeshObj::NulData() =============================================");
if (!myEmptyGrid)
{
myEmptyGrid = SMDS_UnstructuredGrid::New();
points->SetNumberOfPoints(0);
myEmptyGrid->SetPoints( points );
points->Delete();
- myEmptyGrid->BuildLinks();
+ //myEmptyGrid->BuildLinks();
}
myGrid->ShallowCopy(myEmptyGrid);
return true;
//=================================================================================
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;