X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_Object.cxx;h=885ee3de35b4b66aed1a34dcc8e1166956a27870;hb=b99281785418b27fd87472f97840a888b7c78437;hp=24023bacf401ea6bc438647eaea39e03ce2b216d;hpb=83f19818fce494a77ddf10b70493abdd9f73e4e0;p=modules%2Fsmesh.git diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 24023bacf..885ee3de3 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -31,7 +31,7 @@ #include "SMDS_Mesh.hxx" #include "SMESH_Actor.h" #include "SMESH_ControlsDef.hxx" -#include "SALOME_ExtractUnstructuredGrid.h" +#include #include CORBA_SERVER_HEADER(SALOME_Exception) @@ -160,6 +160,30 @@ namespace{ } + inline void AddPolygonsWithID(SMDS_Mesh* theMesh, + SMESH::log_array_var& theSeq, + CORBA::Long theId) + { + const SMESH::long_array& anIndexes = theSeq[theId].indexes; + CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number; + + for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) { + int aFaceId = anIndexes[anIndexId++]; + + int aNbNodes = anIndexes[anIndexId++]; + std::vector nodes_ids (aNbNodes); + for (int i = 0; i < aNbNodes; i++) { + nodes_ids[i] = anIndexes[anIndexId++]; + } + + SMDS_MeshElement* anElem = theMesh->AddPolygonalFaceWithID(nodes_ids, aFaceId); + if (!anElem) + EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolygonalFaceWithID for ID = " + << anElemId); + } + } + + inline void AddTetrasWithID(SMDS_Mesh* theMesh, SMESH::log_array_var& theSeq, CORBA::Long theId) @@ -175,7 +199,7 @@ namespace{ anIndexes[anIndexId+4], anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<DebugOn(); - } + if ( MYDEBUG ) + MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() ); myGrid->Delete(); } @@ -545,35 +631,37 @@ void SMESH_VisualObjDef::buildElemPrs() SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); switch(aType){ case SMDSAbs_Volume:{ - int* aConnectivities = NULL; + std::vector aConnectivities; GetConnect(aNodesIter,aConnect); // Convertions connectivities from SMDS to VTK - switch(aNbNodes){ - case 4:{ + if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE + for (int k = 0; k < aNbNodes; k++) { + aConnectivities.push_back(k); + } + + } else if (aNbNodes == 4) { static int anIds[] = {0,2,1,3}; - aConnectivities = anIds; - break; - } - case 5:{ + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + + } else if (aNbNodes == 5) { static int anIds[] = {0,3,2,1,4}; - aConnectivities = anIds; - break; - } - case 6:{ + 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}; - aConnectivities = anIds; - break; - } - case 8:{ + 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}; - aConnectivities = anIds; - break; - }} + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); - if(aConnectivities) - for( vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++ ) + } else { + } + + if (aConnectivities.size() > 0) { + for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++) SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]); - + } break; } default: @@ -584,7 +672,7 @@ void SMESH_VisualObjDef::buildElemPrs() } aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( getCellType( aType, aNbNodes ) ); + aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) ); iElem++; } @@ -628,7 +716,7 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, int nbNodes = anElem->NbNodes(); - if ( theEdgeNum < 1 || theEdgeNum > 4 || nbNodes != 3 && nbNodes != 4 || theEdgeNum > nbNodes ) + if ( theEdgeNum < 0 || theEdgeNum > 3 || nbNodes != 3 && nbNodes != 4 || theEdgeNum > nbNodes ) return false; int anIds[ nbNodes ]; @@ -637,10 +725,10 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, while( anIter->more() ) anIds[ i++ ] = anIter->next()->GetID(); - if ( nbNodes != theEdgeNum ) + if ( theEdgeNum < nbNodes - 1 ) { - theNodeId1 = anIds[ theEdgeNum - 1 ]; - theNodeId2 = anIds[ theEdgeNum ]; + theNodeId1 = anIds[ theEdgeNum ]; + theNodeId2 = anIds[ theEdgeNum + 1 ]; } else { @@ -697,25 +785,27 @@ void SMESH_MeshObj::Update( int theIsClear ) if( !aLength ) return; - + for ( CORBA::Long anId = 0; anId < aLength; anId++) { const SMESH::double_array& aCoords = aSeq[anId].coords; const SMESH::long_array& anIndexes = aSeq[anId].indexes; CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number; CORBA::Long aCommand = aSeq[anId].commandType; - + switch(aCommand) { - case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_PYRAMID : AddPiramidsWithID( myMesh, aSeq, anId ); break; - case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break; - + case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_POLYGON : AddPolygonsWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_PYRAMID : AddPiramidsWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( myMesh, aSeq, anId ); break; + case SMESH::REMOVE_NODE: for( ; anElemId < aNbElems; anElemId++ ) myMesh->RemoveNode( FindNode( myMesh, anIndexes[anElemId] ) ); @@ -743,8 +833,8 @@ void SMESH_MeshObj::Update( int theIsClear ) // nb nodes int nbNodes = anIndexes[i++]; // nodes - ASSERT( nbNodes < 9 ); - const SMDS_MeshNode* aNodes[ 8 ]; + //ASSERT( nbNodes < 9 ); + const SMDS_MeshNode* aNodes[ nbNodes ]; for ( int iNode = 0; iNode < nbNodes; iNode++ ) aNodes[ iNode ] = FindNode( myMesh, anIndexes[i++] ); // change @@ -752,6 +842,9 @@ void SMESH_MeshObj::Update( int theIsClear ) } break; + case SMESH::CHANGE_POLYHEDRON_NODES: + ChangePolyhedronNodes(myMesh, aSeq, anId); + break; case SMESH::RENUMBER: for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3) {