#include <SMESH_Client.hxx>
Public Member Functions | |
| SMESH_Client (CORBA::ORB_ptr theORB, SMESH::SMESH_Mesh_ptr theMesh) | |
| ~SMESH_Client () | |
| bool | Update (bool theIsClear) |
| SMDS_Mesh * | GetMesh () const |
| SMDS_Mesh * | operator-> () const |
| SMESH::SMESH_Mesh_ptr | GetMeshServer () |
Static Public Member Functions | |
| static SMESH::SMESH_Gen_var | GetSMESHGen (CORBA::ORB_ptr theORB, CORBA::Boolean &theIsEmbeddedMode) |
Protected Attributes | |
| SMESH::SMESH_Mesh_var | myMeshServer |
| SMESHDS_Mesh * | mySMESHDSMesh |
| SMDS_Mesh * | mySMDSMesh |
Definition at line 52 of file SMESH_Client.hxx.
| SMESH_Client::SMESH_Client | ( | CORBA::ORB_ptr | theORB, |
| SMESH::SMESH_Mesh_ptr | theMesh | ||
| ) |
Definition at line 630 of file SMESH_Client.cxx.
References SMESH_Mesh.GetMeshDS(), GetSMESHGen(), MESSAGE, myMeshServer, mySMDSMesh, and mySMESHDSMesh.
: myMeshServer(SMESH::SMESH_Mesh::_duplicate(theMesh)), mySMESHDSMesh(NULL), mySMDSMesh(NULL) { MESSAGE("SMESH_Client::SMESH_Client"); myMeshServer->Register(); CORBA::Boolean anIsEmbeddedMode; GetSMESHGen(theORB,anIsEmbeddedMode); if(anIsEmbeddedMode){ 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<SMESH_Mesh*>(theMesh->GetMeshPtr()); CORBA::LongLong pointeur = theMesh->GetMeshPtr(); if( MYDEBUG ) MESSAGE("SMESH_Client::SMESH_Client pointeur "<<pointeur); SMESH_Mesh* aMesh = reinterpret_cast<SMESH_Mesh*> (pointeur); if ( MYDEBUG ) MESSAGE("SMESH_Client::SMESH_Client aMesh "<<aMesh); //if(aMesh->GetMeshDS()->IsEmbeddedMode()){ if(anIsEmbeddedMode){ mySMESHDSMesh = aMesh->GetMeshDS(); mySMDSMesh = mySMESHDSMesh; } } if(!mySMDSMesh) mySMDSMesh = new SMDS_Mesh(); }
| SMESH_Client::~SMESH_Client | ( | ) |
Definition at line 667 of file SMESH_Client.cxx.
References myMeshServer, mySMDSMesh, and mySMESHDSMesh.
{
myMeshServer->UnRegister();
if(!mySMESHDSMesh)
delete mySMDSMesh;
}
| SMDS_Mesh * SMESH_Client::GetMesh | ( | ) | const |
Definition at line 677 of file SMESH_Client.cxx.
References mySMDSMesh.
Referenced by operator->().
{
return mySMDSMesh;
}
| SMESH::SMESH_Mesh_ptr SMESH_Client::GetMeshServer | ( | ) |
Definition at line 693 of file SMESH_Client.cxx.
References myMeshServer.
{
return myMeshServer.in();
}
| SMESH::SMESH_Gen_var SMESH_Client::GetSMESHGen | ( | CORBA::ORB_ptr | theORB, |
| CORBA::Boolean & | theIsEmbeddedMode | ||
| ) | [static] |
Definition at line 597 of file SMESH_Client.cxx.
Referenced by SMESH_Client().
{
static SMESH::SMESH_Gen_var aMeshGen;
if(CORBA::is_nil(aMeshGen.in())){
#ifdef WNT
long aClientPID = (long)_getpid();
#else
long aClientPID = (long)getpid();
#endif
SALOME_NamingService aNamingService(theORB);
SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService);
Engines::EngineComponent_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH");
aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent);
std::string aClientHostName = Kernel_Utils::GetHostname();
Engines::Container_var aServerContainer = aMeshGen->GetContainerRef();
CORBA::String_var aServerHostName = aServerContainer->getHostName();
CORBA::Long aServerPID = aServerContainer->getPID();
aMeshGen->SetEmbeddedMode((aClientPID == aServerPID) && (aClientHostName == aServerHostName.in()));
}
theIsEmbeddedMode = aMeshGen->IsEmbeddedMode();
return aMeshGen;
}
| SMDS_Mesh * SMESH_Client::operator-> | ( | ) | const |
Definition at line 704 of file SMESH_Client.cxx.
References SMESH.ADD_EDGE, SMESH.ADD_ELEM0D, SMESH.ADD_HEXAHEDRON, SMESH.ADD_NODE, SMESH.ADD_POLYGON, SMESH.ADD_POLYHEDRON, SMESH.ADD_PRISM, SMESH.ADD_PYRAMID, SMESH.ADD_QUADEDGE, SMESH.ADD_QUADHEXAHEDRON, SMESH.ADD_QUADPENTAHEDRON, SMESH.ADD_QUADPYRAMID, SMESH.ADD_QUADQUADRANGLE, SMESH.ADD_QUADRANGLE, SMESH.ADD_QUADTETRAHEDRON, SMESH.ADD_QUADTRIANGLE, SMESH.ADD_TETRAHEDRON, SMESH.ADD_TRIANGLE, SMESH.CHANGE_ELEMENT_NODES, SMESH.CHANGE_POLYHEDRON_NODES, SMDS_Mesh.ChangeElementNodes(), SMDS_Mesh.Clear(), SMESH.CLEAR_MESH, FindNode(), SMESHDS_Mesh.GetScript(), SMESHDS_Script.IsModified(), MESSAGE, SMESH.MOVE_NODE, myMeshServer, mySMDSMesh, mySMESHDSMesh, SMDS_Mesh.Nb0DElements(), SMDS_Mesh.NbEdges(), SMDS_Mesh.NbFaces(), SMDS_Mesh.NbNodes(), SMDS_Mesh.NbVolumes(), ex29_refine.node(), SMESH.REMOVE_ELEMENT, SMESH.REMOVE_NODE, SMDS_Mesh.RemoveElement(), SMDS_Mesh.RemoveNode(), SMDS_Mesh.Renumber(), SMESH.RENUMBER, SMESHDS_Script.SetModified(), and SMDS_MeshNode.setXYZ().
Referenced by SMESH_MeshObj.Update().
{
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;
if( MYDEBUG )
MESSAGE( "Update: length of the script is "<<aLength );
if(!anIsModified)
return false;
// update client mesh structure by logged changes commands
try
{
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 ( 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;
case SMESH::ADD_POLYGON : AddPolygonsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_PYRAMID : AddPiramidsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_PRISM : AddPrismsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_QUADEDGE : AddQuadEdgesWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_QUADTRIANGLE : AddQuadTriasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_QUADQUADRANGLE : AddQuadQuadsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_QUADTETRAHEDRON: AddQuadTetrasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_QUADPYRAMID : AddQuadPiramidsWithID( mySMDSMesh, aSeq, anId ); break;
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] ) );
break;
case SMESH::REMOVE_ELEMENT:
for( ; anElemId < aNbElems; anElemId++ )
mySMDSMesh->RemoveElement( FindElement( mySMDSMesh, anIndexes[anElemId] ) );
break;
case SMESH::MOVE_NODE:
for(CORBA::Long aCoordId=0; anElemId < aNbElems; anElemId++, aCoordId+=3)
{
SMDS_MeshNode* node =
const_cast<SMDS_MeshNode*>( FindNode( mySMDSMesh, anIndexes[anElemId] ));
node->setXYZ( aCoords[aCoordId], aCoords[aCoordId+1], aCoords[aCoordId+2] );
}
break;
case SMESH::CHANGE_ELEMENT_NODES:
for ( CORBA::Long i = 0; anElemId < aNbElems; anElemId++ )
{
// find element
const SMDS_MeshElement* elem = FindElement( mySMDSMesh, anIndexes[i++] );
// nb nodes
int nbNodes = anIndexes[i++];
// nodes
//ASSERT( nbNodes < 9 );
vector<const SMDS_MeshNode*> aNodes( nbNodes );
for ( int iNode = 0; iNode < nbNodes; iNode++ )
aNodes[ iNode ] = FindNode( mySMDSMesh, anIndexes[i++] );
// change
mySMDSMesh->ChangeElementNodes( elem, &aNodes[0], nbNodes );
}
break;
case SMESH::CHANGE_POLYHEDRON_NODES:
ChangePolyhedronNodes(mySMDSMesh, aSeq, anId);
break;
case SMESH::RENUMBER:
for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3)
{
mySMDSMesh->Renumber( anIndexes[i], anIndexes[i+1], anIndexes[i+2] );
}
break;
default:;
}
}
}
catch ( SALOME::SALOME_Exception& exc )
{
INFOS("Following exception was cought:\n\t"<<exc.details.text);
}
catch( const std::exception& exc)
{
INFOS("Following exception was cought:\n\t"<<exc.what());
}
catch(...)
{
INFOS("Unknown exception was cought !!!");
}
if ( MYDEBUG && mySMDSMesh )
{
MESSAGE("Update - mySMDSMesh->NbNodes() = "<<mySMDSMesh->NbNodes());
MESSAGE("Update - mySMDSMesh->Nb0DElements() = "<<mySMDSMesh->Nb0DElements());
MESSAGE("Update - mySMDSMesh->NbEdges() = "<<mySMDSMesh->NbEdges());
MESSAGE("Update - mySMDSMesh->NbFaces() = "<<mySMDSMesh->NbFaces());
MESSAGE("Update - mySMDSMesh->NbVolumes() = "<<mySMDSMesh->NbVolumes());
}
} // end of update mesh by log script
return anIsModified;
}
SMESH::SMESH_Mesh_var SMESH_Client.myMeshServer [protected] |
Definition at line 77 of file SMESH_Client.hxx.
Referenced by GetMeshServer(), SMESH_Client(), Update(), and ~SMESH_Client().
SMDS_Mesh* SMESH_Client.mySMDSMesh [protected] |
Definition at line 79 of file SMESH_Client.hxx.
Referenced by GetMesh(), SMESH_Client(), Update(), and ~SMESH_Client().
SMESHDS_Mesh* SMESH_Client.mySMESHDSMesh [protected] |
Definition at line 78 of file SMESH_Client.hxx.
Referenced by SMESH_Client(), Update(), and ~SMESH_Client().