X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_Object.cxx;h=e7ef139a4a2d3b88b12c5fe1b78ade97652bfab8;hp=943f0896d712cf52163efd1da8b9c17a76baa616;hb=2daa321efae3d0c6ce41199fa5a2482630d505d9;hpb=2ed875d56d133c56ca7cd9d68504a2c12c94120b diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 943f0896d..e7ef139a4 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include @@ -81,7 +81,7 @@ static int MYDEBUGWITHFILES = 0; // purpose : Get type of VTK cell //================================================================================= static inline vtkIdType getCellType( const SMDSAbs_ElementType theType, - const bool thePoly, + const bool thePoly, const int theNbNodes ) { switch( theType ) @@ -263,7 +263,7 @@ namespace{ typedef std::vector TConnect; int GetConnect(const SMDS_ElemIteratorPtr& theNodesIter, - TConnect& theConnect) + TConnect& theConnect) { theConnect.clear(); for(; theNodesIter->more();) @@ -273,10 +273,10 @@ namespace{ inline void SetId(vtkIdList *theIdList, - const SMESH_VisualObjDef::TMapOfIds& theSMDS2VTKNodes, - const TConnect& theConnect, - int thePosition, - int theId) + const SMESH_VisualObjDef::TMapOfIds& theSMDS2VTKNodes, + const TConnect& theConnect, + int thePosition, + int theId) { theIdList->SetId(thePosition,theSMDS2VTKNodes.find(theConnect[theId]->GetID())->second); } @@ -372,12 +372,12 @@ void SMESH_VisualObjDef::buildElemPrs() myVTK2SMDSElems.insert( TMapOfIds::value_type( iElem, anId ) ); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); - switch (aType) { - case SMDSAbs_Volume:{ + switch (aType) { + case SMDSAbs_Volume:{ aConnect.clear(); - std::vector aConnectivities; - // Convertions connectivities from SMDS to VTK - if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE + std::vector aConnectivities; + // Convertions connectivities from SMDS to VTK + if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE if ( const SMDS_PolyhedralVolumeOfNodes* ph = dynamic_cast (anElem)) @@ -385,67 +385,67 @@ void SMESH_VisualObjDef::buildElemPrs() aNbNodes = GetConnect(ph->uniqueNodesIterator(),aConnect); anIdList->SetNumberOfIds( aNbNodes ); } - for (int k = 0; k < aNbNodes; k++) - aConnectivities.push_back(k); + 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]); + 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 (aNbNodes == 5) { + static int anIds[] = {0,3,2,1,4}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); - } else if (aNbNodes == 6) { - static int anIds[] = {0,1,2,3,4,5}; - for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + } else if (aNbNodes == 6) { + static int anIds[] = {0,1,2,3,4,5}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); - } + } else if (aNbNodes == 8) { - static int anIds[] = {0,3,2,1,4,7,6,5}; - for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + static int anIds[] = {0,3,2,1,4,7,6,5}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); - } + } else if (aNbNodes == 10) { - static int anIds[] = {0,2,1,3,6,5,4,7,9,8}; - for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); - } + static int anIds[] = {0,2,1,3,6,5,4,7,9,8}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + } else if (aNbNodes == 13) { - static int anIds[] = {0,3,2,1,4,8,7,6,5,9,12,11,10}; - for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); - } + static int anIds[] = {0,3,2,1,4,8,7,6,5,9,12,11,10}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + } else if (aNbNodes == 15) { //static int anIds[] = {0,2,1,3,5,4,8,7,6,11,10,9,12,14,13}; static int anIds[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}; - for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); - //for (int k = 0; k < aNbNodes; k++) { + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + //for (int k = 0; k < aNbNodes; k++) { // int nn = aConnectivities[k]; // const SMDS_MeshNode* N = static_cast (aConnect[nn]); // cout<<"k="<X()<<","<Y()<<","<Z()<<")"< 0) { - for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++) - SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]); - } - break; - } - default: - for( vtkIdType aNodeId = 0; aNodesIter->more(); aNodeId++ ){ - const SMDS_MeshElement* aNode = aNodesIter->next(); - anIdList->SetId( aNodeId, mySMDS2VTKNodes[aNode->GetID()] ); - } - } + 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++ ){ + const SMDS_MeshElement* aNode = aNodesIter->next(); + anIdList->SetId( aNodeId, mySMDS2VTKNodes[aNode->GetID()] ); + } + } aConnectivity->InsertNextCell( anIdList ); aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) ); @@ -483,9 +483,9 @@ void SMESH_VisualObjDef::buildElemPrs() // purpose : Retrieve ids of nodes from edge of elements ( edge is numbered from 1 ) //================================================================================= bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, - const int theEdgeNum, - int& theNodeId1, - int& theNodeId2 ) const + const int theEdgeNum, + int& theNodeId1, + int& theNodeId2 ) const { const SMDS_Mesh* aMesh = GetMesh(); if ( aMesh == 0 ) @@ -520,6 +520,19 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, return true; } +//================================================================================= +// function : IsValid +// purpose : Return true if there are some entities +//================================================================================= +bool SMESH_VisualObjDef::IsValid() const +{ + return GetNbEntities(SMDSAbs_Node) > 0 || + GetNbEntities(SMDSAbs_0DElement) > 0 || + GetNbEntities(SMDSAbs_Edge) > 0 || + GetNbEntities(SMDSAbs_Face) > 0 || + GetNbEntities(SMDSAbs_Volume) > 0 ; +} + /* Class : SMESH_MeshObj Description : Class for visualisation of mesh @@ -905,7 +918,7 @@ int SMESH_subMeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const case SMDSAbs_Volume: { SMESH::long_array_var anIds = - mySubMeshServer->GetElementsByType( SMESH::ElementType(theType) ); + mySubMeshServer->GetElementsByType( SMESH::ElementType(theType) ); return anIds->length(); } default: @@ -942,7 +955,7 @@ int SMESH_subMeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityLis else { SMESH::long_array_var anIds = - mySubMeshServer->GetElementsByType( SMESH::ElementType(theType) ); + mySubMeshServer->GetElementsByType( SMESH::ElementType(theType) ); return getPointers( theType, anIds, aMesh, theResList ); } }