X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHClient%2FSMESH_Client.cxx;h=061028c303c7acc452a79627d5bcab39ad170983;hb=refs%2Ftags%2Fsmds_memimp_V5_1_4rc1;hp=bd52bc0428ce0c69386ac598d4806c0981aa6308;hpb=c63ee099ad2b149bd70136839c973e8910137bc5;p=modules%2Fsmesh.git diff --git a/src/SMESHClient/SMESH_Client.cxx b/src/SMESHClient/SMESH_Client.cxx index bd52bc042..061028c30 100644 --- a/src/SMESHClient/SMESH_Client.cxx +++ b/src/SMESHClient/SMESH_Client.cxx @@ -1,30 +1,30 @@ -// SMESH SMESHClient : tool to update client mesh structure by mesh from server +// Copyright (C) 2007-2010 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 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 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 -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// 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. // +// 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 +// + +// SMESH SMESHClient : tool to update client mesh structure by mesh from server // File : SMESH_Client.cxx // Author : Pavel TELKOV // Module : SMESH - +// #include "SMESH_Client.hxx" #include "SMESH_Mesh.hxx" @@ -35,7 +35,7 @@ #include CORBA_SERVER_HEADER(SALOME_Component) #include CORBA_SERVER_HEADER(SALOME_Exception) -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" #include "utilities.h" #ifdef WNT @@ -55,7 +55,7 @@ #endif #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif @@ -85,8 +85,8 @@ namespace //function : AddNodesWithID //======================================================================= inline void AddNodesWithID(SMDS_Mesh* theMesh, - SMESH::log_array_var& theSeq, - CORBA::Long theId) + SMESH::log_array_var& theSeq, + CORBA::Long theId) { const SMESH::double_array& aCoords = theSeq[theId].coords; const SMESH::long_array& anIndexes = theSeq[theId].indexes; @@ -95,11 +95,33 @@ namespace EXCEPTION(runtime_error,"AddNodesWithID - 3*aNbElems != aCoords.length()"); for(CORBA::Long aCoordId = 0; anElemId < aNbElems; anElemId++, aCoordId+=3){ SMDS_MeshElement* anElem = theMesh->AddNodeWithID(aCoords[aCoordId], - aCoords[aCoordId+1], - aCoords[aCoordId+2], - anIndexes[anElemId]); + aCoords[aCoordId+1], + aCoords[aCoordId+2], + anIndexes[anElemId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddNodeWithID for ID = "<Add0DElementWithID(anIndexes[anIndexId+1], + anIndexes[anIndexId]); + if (!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot Add0DElementWithID for ID = "<AddEdgeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddEdgeWithID for ID = "<AddFaceWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddFaceWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId+6], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId+6], - anIndexes[anIndexId+7], - anIndexes[anIndexId+8], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId+7], + anIndexes[anIndexId+8], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<AddEdgeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddEdgeWithID for ID = "<AddFaceWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId+6], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddFaceWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId+6], - anIndexes[anIndexId+7], - anIndexes[anIndexId+8], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId+7], + anIndexes[anIndexId+8], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId+6], - anIndexes[anIndexId+7], - anIndexes[anIndexId+8], - anIndexes[anIndexId+9], - anIndexes[anIndexId+10], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId+7], + anIndexes[anIndexId+8], + anIndexes[anIndexId+9], + anIndexes[anIndexId+10], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId+6], - anIndexes[anIndexId+7], - anIndexes[anIndexId+8], - anIndexes[anIndexId+9], - anIndexes[anIndexId+10], - anIndexes[anIndexId+11], - anIndexes[anIndexId+12], - anIndexes[anIndexId+13], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId+7], + anIndexes[anIndexId+8], + anIndexes[anIndexId+9], + anIndexes[anIndexId+10], + anIndexes[anIndexId+11], + anIndexes[anIndexId+12], + anIndexes[anIndexId+13], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId+6], - anIndexes[anIndexId+7], - anIndexes[anIndexId+8], - anIndexes[anIndexId+9], - anIndexes[anIndexId+10], - anIndexes[anIndexId+11], - anIndexes[anIndexId+12], - anIndexes[anIndexId+13], - anIndexes[anIndexId+14], - anIndexes[anIndexId+15], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId+7], + anIndexes[anIndexId+8], + anIndexes[anIndexId+9], + anIndexes[anIndexId+10], + anIndexes[anIndexId+11], + anIndexes[anIndexId+12], + anIndexes[anIndexId+13], + anIndexes[anIndexId+14], + anIndexes[anIndexId+15], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], - anIndexes[anIndexId+2], - anIndexes[anIndexId+3], - anIndexes[anIndexId+4], - anIndexes[anIndexId+5], - anIndexes[anIndexId+6], - anIndexes[anIndexId+7], - anIndexes[anIndexId+8], - anIndexes[anIndexId+9], - anIndexes[anIndexId+10], - anIndexes[anIndexId+11], - anIndexes[anIndexId+12], - anIndexes[anIndexId+13], - anIndexes[anIndexId+14], - anIndexes[anIndexId+15], - anIndexes[anIndexId+16], - anIndexes[anIndexId+17], - anIndexes[anIndexId+18], - anIndexes[anIndexId+19], - anIndexes[anIndexId+20], - anIndexes[anIndexId]); + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId+7], + anIndexes[anIndexId+8], + anIndexes[anIndexId+9], + anIndexes[anIndexId+10], + anIndexes[anIndexId+11], + anIndexes[anIndexId+12], + anIndexes[anIndexId+13], + anIndexes[anIndexId+14], + anIndexes[anIndexId+15], + anIndexes[anIndexId+16], + anIndexes[anIndexId+17], + anIndexes[anIndexId+18], + anIndexes[anIndexId+19], + anIndexes[anIndexId+20], + anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<GetContainerRef(); CORBA::String_var aServerHostName = aServerContainer->getHostName(); CORBA::Long aServerPID = aServerContainer->getPID(); @@ -608,11 +630,12 @@ SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB, // purpose : //======================================================================= SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB, - SMESH::SMESH_Mesh_ptr theMesh): + SMESH::SMESH_Mesh_ptr theMesh): myMeshServer(SMESH::SMESH_Mesh::_duplicate(theMesh)), mySMESHDSMesh(NULL), mySMDSMesh(NULL) { + MESSAGE("SMESH_Client::SMESH_Client"); myMeshServer->Register(); CORBA::Boolean anIsEmbeddedMode; @@ -621,8 +644,15 @@ SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB, if ( MYDEBUG ) MESSAGE("Info: The same process, update mesh by pointer "); // just set client mesh pointer to server mesh pointer - SMESH_Mesh* aMesh = reinterpret_cast(theMesh->GetMeshPtr()); - if(aMesh->GetMeshDS()->IsEmbeddedMode()){ + //SMESH_Mesh* aMesh = reinterpret_cast(theMesh->GetMeshPtr()); + CORBA::LongLong pointeur = theMesh->GetMeshPtr(); + if( MYDEBUG ) + MESSAGE("SMESH_Client::SMESH_Client pointeur "< (pointeur); + if ( MYDEBUG ) + MESSAGE("SMESH_Client::SMESH_Client aMesh "<GetMeshDS()->IsEmbeddedMode()){ + if(anIsEmbeddedMode){ mySMESHDSMesh = aMesh->GetMeshDS(); mySMDSMesh = mySMESHDSMesh; } @@ -677,10 +707,12 @@ SMESH_Client::Update(bool theIsClear) { bool anIsModified = true; if(mySMESHDSMesh){ + MESSAGE("Update mySMESHDSMesh"); SMESHDS_Script* aScript = mySMESHDSMesh->GetScript(); anIsModified = aScript->IsModified(); aScript->SetModified(false); }else{ + MESSAGE("Update CORBA"); SMESH::log_array_var aSeq = myMeshServer->GetLog( theIsClear ); CORBA::Long aLength = aSeq->length(); anIsModified = aLength > 0; @@ -695,14 +727,15 @@ SMESH_Client::Update(bool theIsClear) { 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; + 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) + switch(aCommand) { - case SMESH::ADD_NODE : AddNodesWithID ( mySMDSMesh, aSeq, anId ); break; + case SMESH::ADD_NODE : AddNodesWithID ( mySMDSMesh, aSeq, anId ); break; + case SMESH::ADD_ELEM0D : Add0DElementsWithID ( mySMDSMesh, aSeq, anId ); break; case SMESH::ADD_EDGE : AddEdgesWithID ( mySMDSMesh, aSeq, anId ); break; case SMESH::ADD_TRIANGLE : AddTriasWithID ( mySMDSMesh, aSeq, anId ); break; case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( mySMDSMesh, aSeq, anId ); break; @@ -721,6 +754,10 @@ SMESH_Client::Update(bool theIsClear) case SMESH::ADD_QUADPENTAHEDRON: AddQuadPentasWithID ( mySMDSMesh, aSeq, anId ); break; case SMESH::ADD_QUADHEXAHEDRON : AddQuadHexasWithID ( mySMDSMesh, aSeq, anId ); break; + case SMESH::CLEAR_MESH: + mySMDSMesh->Clear(); + break; + case SMESH::REMOVE_NODE: for( ; anElemId < aNbElems; anElemId++ ) mySMDSMesh->RemoveNode( FindNode( mySMDSMesh, anIndexes[anElemId] ) ); @@ -749,11 +786,11 @@ SMESH_Client::Update(bool theIsClear) int nbNodes = anIndexes[i++]; // nodes //ASSERT( nbNodes < 9 ); - const SMDS_MeshNode* aNodes[ nbNodes ]; + vector aNodes( nbNodes ); for ( int iNode = 0; iNode < nbNodes; iNode++ ) aNodes[ iNode ] = FindNode( mySMDSMesh, anIndexes[i++] ); // change - mySMDSMesh->ChangeElementNodes( elem, aNodes, nbNodes ); + mySMDSMesh->ChangeElementNodes( elem, &aNodes[0], nbNodes ); } break; @@ -768,7 +805,7 @@ SMESH_Client::Update(bool theIsClear) break; default:; - } + } } } catch ( SALOME::SALOME_Exception& exc ) @@ -787,6 +824,7 @@ SMESH_Client::Update(bool theIsClear) if ( MYDEBUG && mySMDSMesh ) { MESSAGE("Update - mySMDSMesh->NbNodes() = "<NbNodes()); + MESSAGE("Update - mySMDSMesh->Nb0DElements() = "<Nb0DElements()); MESSAGE("Update - mySMDSMesh->NbEdges() = "<NbEdges()); MESSAGE("Update - mySMDSMesh->NbFaces() = "<NbFaces()); MESSAGE("Update - mySMDSMesh->NbVolumes() = "<NbVolumes());