-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 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
+// Copyright (C) 2003-2007 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 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.
+// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH OBJECT : interactive object for SMESH visualization
#ifdef _DEBUG_
static int MYDEBUG = 1;
-static int MYDEBUGWITHFILES = 1;
+static int MYDEBUGWITHFILES = 0;//1;
#else
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
else return VTK_EMPTY_CELL;
case SMDSAbs_Volume:
- if (thePoly && theNbNodes>3 ) return VTK_CONVEX_POINT_SET;
+ 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;
//=================================================================================
vtkIdType SMESH_VisualObjDef::GetNodeObjId( int theVTKID )
{
- if (myLocalGrid)
- {
- TMapOfIds::const_iterator i = myVTK2SMDSNodes.find(theVTKID);
- return i == myVTK2SMDSNodes.end() ? -1 : i->second;
- }
+ if (myLocalGrid)
+ {
+ TMapOfIds::const_iterator i = myVTK2SMDSNodes.find(theVTKID);
+ return i == myVTK2SMDSNodes.end() ? -1 : i->second;
+ }
return this->GetMesh()->FindNodeVtk(theVTKID)->GetID();
}
vtkIdType SMESH_VisualObjDef::GetNodeVTKId( int theObjID )
{
- if (myLocalGrid)
- {
- TMapOfIds::const_iterator i = mySMDS2VTKNodes.find(theObjID);
+ if (myLocalGrid)
+ {
+ TMapOfIds::const_iterator i = mySMDS2VTKNodes.find(theObjID);
return i == mySMDS2VTKNodes.end() ? -1 : i->second;
- }
- return this->GetMesh()->FindNode(theObjID)->getVtkId();
+ }
+
+ const SMDS_MeshNode* aNode = 0;
+ if( this->GetMesh() ) {
+ aNode = this->GetMesh()->FindNode(theObjID);
+ }
+ return aNode ? aNode->getVtkId() : -1;
}
vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID )
{
- if (myLocalGrid)
- {
- TMapOfIds::const_iterator i = myVTK2SMDSElems.find(theVTKID);
- return i == myVTK2SMDSElems.end() ? -1 : i->second;
- }
+ if (myLocalGrid)
+ {
+ TMapOfIds::const_iterator i = myVTK2SMDSElems.find(theVTKID);
+ return i == myVTK2SMDSElems.end() ? -1 : i->second;
+ }
return this->GetMesh()->fromVtkToSmds(theVTKID);
}
vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID )
{
- if (myLocalGrid)
- {
- TMapOfIds::const_iterator i = mySMDS2VTKElems.find(theObjID);
- return i == mySMDS2VTKElems.end() ? -1 : i->second;
- }
+ if (myLocalGrid)
+ {
+ TMapOfIds::const_iterator i = mySMDS2VTKElems.find(theObjID);
+ return i == mySMDS2VTKElems.end() ? -1 : i->second;
+ }
return this->GetMesh()->FindElement(theObjID)->getVtkId();
//return this->GetMesh()->fromSmdsToVtk(theObjID);
}
MESSAGE("----------------------------------------------------------SMESH_VisualObjDef::buildPrs " << buildGrid);
if (buildGrid)
{
- myLocalGrid = true;
- try
- {
- mySMDS2VTKNodes.clear();
- myVTK2SMDSNodes.clear();
- mySMDS2VTKElems.clear();
- myVTK2SMDSElems.clear();
-
- if ( IsNodePrs() )
- buildNodePrs();
- else
- buildElemPrs();
- }
- catch(...)
- {
- mySMDS2VTKNodes.clear();
- myVTK2SMDSNodes.clear();
- mySMDS2VTKElems.clear();
- myVTK2SMDSElems.clear();
-
- myGrid->SetPoints( 0 );
- myGrid->SetCells( 0, 0, 0, 0, 0 );
- throw;
- }
+ myLocalGrid = true;
+ try
+ {
+ mySMDS2VTKNodes.clear();
+ myVTK2SMDSNodes.clear();
+ mySMDS2VTKElems.clear();
+ myVTK2SMDSElems.clear();
+
+ if ( IsNodePrs() )
+ buildNodePrs();
+ else
+ buildElemPrs();
+ }
+ catch(...)
+ {
+ mySMDS2VTKNodes.clear();
+ myVTK2SMDSNodes.clear();
+ mySMDS2VTKElems.clear();
+ myVTK2SMDSElems.clear();
+
+ myGrid->SetPoints( 0 );
+ myGrid->SetCells( 0, 0, 0, 0, 0 );
+ throw;
+ }
}
else
{
- myLocalGrid = false;
- if (!GetMesh()->isCompacted())
- {
- MESSAGE("*** buildPrs ==> compactMesh!");
- GetMesh()->compactMesh();
- }
- vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
- myGrid->ShallowCopy(theGrid);
- //MESSAGE(myGrid->GetReferenceCount());
- //MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
- //MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<<myGrid->GetNumberOfPoints() );
- if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"buildPrs.vtu" );
+ myLocalGrid = false;
+ if (!GetMesh()->isCompacted())
+ {
+ MESSAGE("*** buildPrs ==> compactMesh!");
+ GetMesh()->compactMesh();
+ }
+ vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
+ myGrid->ShallowCopy(theGrid);
+ //MESSAGE(myGrid->GetReferenceCount());
+ //MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
+ //MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<<myGrid->GetNumberOfPoints() );
+ if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"buildPrs.vtu" );
}
}
{
// PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead,
// so check remaining memory size for safety
- // SMDS_Mesh::CheckMemory(); // PAL16631
+ SMDS_Mesh::CheckMemory(); // PAL16631
vtkPoints* aPoints = vtkPoints::New();
createPoints( aPoints );
- // SMDS_Mesh::CheckMemory();
+ SMDS_Mesh::CheckMemory();
myGrid->SetPoints( aPoints );
aPoints->Delete();
// PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead,
// so check remaining memory size for safety
- // SMDS_Mesh::CheckMemory(); // PAL16631
+ SMDS_Mesh::CheckMemory(); // PAL16631
vtkIdType aCellsSize = 2 * nbEnts[ SMDSAbs_0DElement ] + 3 * nbEnts[ SMDSAbs_Edge ];
{
const TEntityList& aList = anEnts[ aTypes[ i ] ];
TEntityList::const_iterator anIter;
- for ( anIter = aList.begin(); anIter != aList.end(); ++anIter )
- aCellsSize += (*anIter)->NbNodes() + 1;
+ for ( anIter = aList.begin(); anIter != aList.end(); ++anIter ) {
+ 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, ...]
+ else {
+ if( const SMDS_VtkVolume* ph = dynamic_cast<const SMDS_VtkVolume*>(*anIter) ) {
+ int nbFaces = ph->NbFaces();
+ aCellsSize += (1 + ph->NbFaces());
+ for( int i = 1; i <= nbFaces; i++ ) {
+ aCellsSize += ph->NbFaceNodes(i);
+ }
+ }
+ }
+ }
}
}
-
+
vtkIdType aNbCells = nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Edge ] +
nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate( aCellsSize, 0 );
- // SMDS_Mesh::CheckMemory(); // PAL16631
+ SMDS_Mesh::CheckMemory(); // PAL16631
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents( 1 );
aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
- // SMDS_Mesh::CheckMemory(); // PAL16631
+ SMDS_Mesh::CheckMemory(); // PAL16631
vtkIdList *anIdList = vtkIdList::New();
vtkIdType iElem = 0;
TConnect aConnect;
aConnect.reserve(VTK_CELL_SIZE);
- // SMDS_Mesh::CheckMemory(); // PAL16631
+ SMDS_Mesh::CheckMemory(); // PAL16631
for ( int i = 0; i <= 3; i++ ) // iterate through 0d elements, edges, faces and volumes
{
- if ( nbEnts[ aTypes[ i ] ] > 0 )
- {
+ if ( nbEnts[ aTypes[ i ] ] > 0 ) {
+
const SMDSAbs_ElementType& aType = aTypes[ i ];
const TEntityList& aList = anEnts[ aType ];
TEntityList::const_iterator anIter;
for ( anIter = aList.begin(); anIter != aList.end(); ++anIter )
{
const SMDS_MeshElement* anElem = *anIter;
-
+
vtkIdType aNbNodes = anElem->NbNodes();
anIdList->SetNumberOfIds( aNbNodes );
-
+
int anId = anElem->GetID();
-
+
mySMDS2VTKElems.insert( TMapOfIds::value_type( anId, iElem ) );
myVTK2SMDSElems.insert( TMapOfIds::value_type( iElem, anId ) );
-
+
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
switch (aType) {
- case SMDSAbs_Volume:{
+ case SMDSAbs_Volume: {
aConnect.clear();
std::vector<int> aConnectivities;
// Convertions connectivities from SMDS to VTK
+
if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
-
- if ( const SMDS_VtkVolume* ph =
- dynamic_cast<const SMDS_VtkVolume*> (anElem))
- {
- aNbNodes = GetConnect(ph->uniqueNodesIterator(),aConnect);
- anIdList->SetNumberOfIds( aNbNodes );
+ anIdList->Reset();
+ if ( const SMDS_VtkVolume* ph = dynamic_cast<const SMDS_VtkVolume*>(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()]);
+ }
+ }
+ }
}
- for (int k = 0; k < aNbNodes; k++)
- aConnectivities.push_back(k);
-
+
} 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};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
else {
}
- if ( aConnect.empty() )
- GetConnect(aNodesIter,aConnect);
+ if (!(anElem->IsPoly() && aNbNodes > 3)) {
+ if ( aConnect.empty() )
+ GetConnect(aNodesIter,aConnect);
- if (aConnectivities.size() > 0) {
- for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++)
- SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
- }
- break;
+ if (aConnectivities.size() > 0) {
+ for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++)
+ SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
+ }
+ }
+ break;
}
default:
for( vtkIdType aNodeId = 0; aNodesIter->more(); aNodeId++ ){
}
}
+
aConnectivity->InsertNextCell( anIdList );
aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) );
iElem++;
}
}
- // SMDS_Mesh::CheckMemory(); // PAL16631
+ SMDS_Mesh::CheckMemory(); // PAL16631
}
// Insert cells in grid
aCellLocationsArray->SetNumberOfComponents( 1 );
aCellLocationsArray->SetNumberOfTuples( aNbCells );
- // SMDS_Mesh::CheckMemory(); // PAL16631
+ SMDS_Mesh::CheckMemory(); // PAL16631
aConnectivity->InitTraversal();
for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
aConnectivity->Delete();
anIdList->Delete();
- // SMDS_Mesh::CheckMemory(); // PAL16631
+ SMDS_Mesh::CheckMemory(); // PAL16631
}
//=================================================================================
int nbNodes = anElem->NbNodes();
- if ( theEdgeNum < 0 || theEdgeNum > 3 || nbNodes != 3 && nbNodes != 4 || theEdgeNum > nbNodes )
+ if ( theEdgeNum < 0 || theEdgeNum > 3 || (nbNodes != 3 && nbNodes != 4) || theEdgeNum > nbNodes )
return false;
vector<int> anIds( nbNodes );
vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
{
- //MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid);
- return myGrid;
+ if ( !myLocalGrid && !GetMesh()->isCompacted() )
+ {
+ GetMesh()->compactMesh();
+ vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
+ myGrid->ShallowCopy(theGrid);
+ }
+ return myGrid;
}
//=================================================================================
bool SMESH_VisualObjDef::IsValid() const
{
- //MESSAGE("SMESH_VisualObjDef::IsValid");
+ //MESSAGE("SMESH_VisualObjDef::IsValid");
return GetNbEntities(SMDSAbs_Node) > 0 ||
GetNbEntities(SMDSAbs_0DElement) > 0 ||
GetNbEntities(SMDSAbs_Edge) > 0 ||
SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh):
myClient(SalomeApp_Application::orb(),theMesh)
{
- myEmptyGrid = 0;
+ myEmptyGrid = 0;
if ( MYDEBUG )
MESSAGE("SMESH_MeshObj - this = "<<this<<"; theMesh->_is_nil() = "<<theMesh->_is_nil());
}
bool SMESH_MeshObj::NulData()
{
- MESSAGE ("SMESH_MeshObj::NulData() ==================================================================================");
- if (!myEmptyGrid)
- {
- myEmptyGrid = SMDS_UnstructuredGrid::New();
- myEmptyGrid->Initialize();
- myEmptyGrid->Allocate();
- vtkPoints* points = vtkPoints::New();
- points->SetNumberOfPoints(0);
- myEmptyGrid->SetPoints( points );
- points->Delete();
- myEmptyGrid->BuildLinks();
- }
- myGrid->ShallowCopy(myEmptyGrid);
+ MESSAGE ("SMESH_MeshObj::NulData() ==================================================================================");
+ if (!myEmptyGrid)
+ {
+ myEmptyGrid = SMDS_UnstructuredGrid::New();
+ myEmptyGrid->Initialize();
+ myEmptyGrid->Allocate();
+ vtkPoints* points = vtkPoints::New();
+ points->SetNumberOfPoints(0);
+ myEmptyGrid->SetPoints( points );
+ points->Delete();
+ myEmptyGrid->BuildLinks();
+ }
+ myGrid->ShallowCopy(myEmptyGrid);
+ return true;
}
//=================================================================================
// function : GetElemDimension
//=================================================================================
bool SMESH_SubMeshObj::Update( int theIsClear )
{
- MESSAGE("SMESH_SubMeshObj::Update " << this)
+ MESSAGE("SMESH_SubMeshObj::Update " << this)
bool changed = myMeshObj->Update( theIsClear );
buildPrs(true);
return changed;
SMESH_GroupObj::~SMESH_GroupObj()
{
if ( MYDEBUG ) MESSAGE("~SMESH_GroupObj");
- myGroupServer->Destroy();
+ myGroupServer->UnRegister();
}
//=================================================================================
SMESH_subMeshObj::~SMESH_subMeshObj()
{
if ( MYDEBUG ) MESSAGE( "~SMESH_subMeshObj" );
- mySubMeshServer->Destroy();
+ mySubMeshServer->UnRegister();
}
//=================================================================================