Apply additional improvement of the performance in case of usage of the SMESH module in the embedded mode

This commit is contained in:
apo 2006-03-07 07:23:30 +00:00
parent 043724167d
commit ed6f49f1ec
20 changed files with 493 additions and 264 deletions

View File

@ -59,6 +59,16 @@ module SMESH
SMESH_Pattern GetPattern(); SMESH_Pattern GetPattern();
/*!
Set the current mode
*/
void SetEmbeddedMode( in boolean theMode );
/*!
Get the current mode
*/
boolean IsEmbeddedMode();
/*! /*!
Set the current study Set the current study
*/ */

View File

@ -31,14 +31,22 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
@COMMENCE@ @COMMENCE@
EXPORT_HEADERS = SMESH_Actor.h SMESH_Object.h SMESH_ObjectDef.h SMESH_ActorUtils.h EXPORT_HEADERS = \
SMESH_Actor.h \
SMESH_Object.h \
SMESH_ObjectDef.h \
SMESH_ActorUtils.h
# Libraries targets # Libraries targets
LIB = libSMESHObject.la LIB = libSMESHObject.la
LIB_SRC = SMESH_Object.cxx SMESH_DeviceActor.cxx SMESH_Actor.cxx \ LIB_SRC = \
SMESH_ExtractGeometry.cxx SMESH_ActorUtils.cxx SMESH_Object.cxx \
SMESH_DeviceActor.cxx \
SMESH_Actor.cxx \
SMESH_ExtractGeometry.cxx \
SMESH_ActorUtils.cxx
LIB_CLIENT_IDL = SALOME_Exception.idl \ LIB_CLIENT_IDL = SALOME_Exception.idl \
SALOME_GenericObj.idl \ SALOME_GenericObj.idl \
@ -54,10 +62,75 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \
BIN = BIN =
BIN_SRC = BIN_SRC =
CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \ CPPFLAGS+= \
$(BOOST_CPPFLAGS) $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lSMDS \ -I${GUI_ROOT_DIR}/include/salome \
-lSMESHClient -lSalomeApp -lSalomeObject -lSMESHControls -lSalomeLifeCycleCORBA -lSalomeDS -lCASCatch -lSalomeSession $(OCC_INCLUDES) \
LDFLAGSFORBIN += $(LDFLAGS) $(VTK_INCLUDES) \
$(BOOST_CPPFLAGS) \
$(QT_INCLUDES)
LDFLAGS+= \
-L${KERNEL_ROOT_DIR}/lib/salome \
-L${GUI_ROOT_DIR}/lib/salome \
$(OCC_KERNEL_LIBS) \
$(VTK_LIBS) \
-lSMDS \
-lSMESHClient \
-lSalomeApp \
-lSalomeObject \
-lSMESHControls \
-lCASCatch
LDFLAGSFORBIN += \
-L${GEOM_ROOT_DIR}/lib/salome \
-L${MED_ROOT_DIR}/lib/salome \
$(LDFLAGS) \
-lqtx \
-lsuit \
-lstd \
-lCAM \
-lLightApp \
-lObjBrowser \
-lSalomePrs \
-lSalomeDS \
-lTOOLSDS \
-lSalomeDSImpl \
-lSalomeDSClient \
-lSalomeHDFPersist \
-lSalomeResourcesManager \
-lSalomeLifeCycleCORBA \
-lSalomeNotification \
-lSalomeContainer \
-lSalomeCatalog \
-lSalomeSession \
-lRegistry \
-lNMTTools \
-lNMTDS \
-lmed_V2_1 \
-lMEDWrapper \
-lMEDWrapperBase \
-lMEDWrapper_V2_1 \
-lMEDWrapper_V2_2 \
-lPlot2d \
-lGLViewer \
-lOCCViewer \
-lVTKViewer \
-lSVTK \
-lSOCC \
-lSPlot2d \
-lSUPERVGraph \
-lPyInterp \
-lPythonConsole \
-lLogWindow \
-lLightApp \
-lSalomeContainer \
-lToolsGUI \
-lSalomeNS \
-lEvent \
-lSalomeGenericObj \
-lSALOMELocalTrace \
-lwith_loggerTraceCollector \
-lSALOMEBasics \
-lOpUtil
@CONCLUDE@ @CONCLUDE@

View File

@ -31,15 +31,12 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
#include "SMESH_Client.hxx" #include "SalomeApp_Application.h"
#include "VTKViewer_ExtractUnstructuredGrid.h" #include "VTKViewer_ExtractUnstructuredGrid.h"
#include CORBA_SERVER_HEADER(SMESH_Gen) #include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SALOME_Exception) #include CORBA_SERVER_HEADER(SALOME_Exception)
#include "SALOME_LifeCycleCORBA.hxx"
#include "SalomeApp_Application.h"
#include <vtkCell.h> #include <vtkCell.h>
#include <vtkIdList.h> #include <vtkIdList.h>
#include <vtkIntArray.h> #include <vtkIntArray.h>
@ -238,42 +235,6 @@ void SMESH_VisualObjDef::buildNodePrs()
aPoints->Delete(); aPoints->Delete();
myGrid->SetCells( 0, 0, 0 ); myGrid->SetCells( 0, 0, 0 );
// Create cells
/*
int nbPoints = aPoints->GetNumberOfPoints();
vtkIdList *anIdList = vtkIdList::New();
anIdList->SetNumberOfIds( 1 );
vtkCellArray *aCells = vtkCellArray::New();
aCells->Allocate( 2 * nbPoints, 0 );
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents( 1 );
aCellTypesArray->Allocate( nbPoints );
for( vtkIdType aCellId = 0; aCellId < nbPoints; aCellId++ )
{
anIdList->SetId( 0, aCellId );
aCells->InsertNextCell( anIdList );
aCellTypesArray->InsertNextValue( VTK_VERTEX );
}
vtkIntArray* aCellLocationsArray = vtkIntArray::New();
aCellLocationsArray->SetNumberOfComponents( 1 );
aCellLocationsArray->SetNumberOfTuples( nbPoints );
aCells->InitTraversal();
for( vtkIdType i = 0, *pts, npts; aCells->GetNextCell( npts, pts ); i++ )
aCellLocationsArray->SetValue( i, aCells->GetTraversalLocation( npts ) );
myGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
aCellLocationsArray->Delete();
aCellTypesArray->Delete();
aCells->Delete();
anIdList->Delete();
*/
} }
//================================================================================= //=================================================================================
@ -524,15 +485,11 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
// function : SMESH_MeshObj // function : SMESH_MeshObj
// purpose : Constructor // purpose : Constructor
//================================================================================= //=================================================================================
SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh) SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh):
myClient(SalomeApp_Application::orb(),theMesh)
{ {
if ( MYDEBUG ) if ( MYDEBUG )
MESSAGE("SMESH_MeshObj - theMesh->_is_nil() = "<<theMesh->_is_nil()); MESSAGE("SMESH_MeshObj - this = "<<this<<"; theMesh->_is_nil() = "<<theMesh->_is_nil());
myMeshServer = SMESH::SMESH_Mesh::_duplicate( theMesh );
myMeshServer->Register();
myMesh = new SMDS_Mesh();
myIsMeshFromServer = 0;
} }
//================================================================================= //=================================================================================
@ -541,9 +498,8 @@ SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh)
//================================================================================= //=================================================================================
SMESH_MeshObj::~SMESH_MeshObj() SMESH_MeshObj::~SMESH_MeshObj()
{ {
myMeshServer->Destroy(); if ( MYDEBUG )
if ( !myIsMeshFromServer ) MESSAGE("SMESH_MeshObj - this = "<<this<<"\n");
delete myMesh;
} }
//================================================================================= //=================================================================================
@ -553,23 +509,8 @@ SMESH_MeshObj::~SMESH_MeshObj()
void SMESH_MeshObj::Update( int theIsClear ) void SMESH_MeshObj::Update( int theIsClear )
{ {
// Update SMDS_Mesh on client part // Update SMDS_Mesh on client part
SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( SalomeApp_Application::namingService() ); if ( myClient.Update(theIsClear) )
Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" ); buildPrs(); // Fill unstructured grid
SMESH::SMESH_Gen_ptr smesh = SMESH::SMESH_Gen::_narrow( comp );
int isUpdated = 0;
SMESH_Client client;
SMDS_Mesh* meshPtr = client.Update( smesh, myMeshServer, myMesh, theIsClear, isUpdated );
if ( meshPtr && myMesh != meshPtr )
{
delete myMesh;
myMesh = meshPtr;
myIsMeshFromServer = 1;
}
// Fill unstructured grid
if ( isUpdated )
{
buildPrs();
}
} }
//================================================================================= //=================================================================================
@ -578,7 +519,7 @@ void SMESH_MeshObj::Update( int theIsClear )
//================================================================================= //=================================================================================
int SMESH_MeshObj::GetElemDimension( const int theObjId ) int SMESH_MeshObj::GetElemDimension( const int theObjId )
{ {
const SMDS_MeshElement* anElem = myMesh->FindElement( theObjId ); const SMDS_MeshElement* anElem = myClient->FindElement( theObjId );
if ( anElem == 0 ) if ( anElem == 0 )
return 0; return 0;
@ -602,22 +543,22 @@ int SMESH_MeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{ {
case SMDSAbs_Node: case SMDSAbs_Node:
{ {
return myMesh->NbNodes(); return myClient->NbNodes();
} }
break; break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
{ {
return myMesh->NbEdges(); return myClient->NbEdges();
} }
break; break;
case SMDSAbs_Face: case SMDSAbs_Face:
{ {
return myMesh->NbFaces(); return myClient->NbFaces();
} }
break; break;
case SMDSAbs_Volume: case SMDSAbs_Volume:
{ {
return myMesh->NbVolumes(); return myClient->NbVolumes();
} }
break; break;
default: default:
@ -634,25 +575,25 @@ int SMESH_MeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList&
{ {
case SMDSAbs_Node: case SMDSAbs_Node:
{ {
SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator(); SMDS_NodeIteratorPtr anIter = myClient->nodesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
{ {
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); SMDS_EdgeIteratorPtr anIter = myClient->edgesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMDSAbs_Face: case SMDSAbs_Face:
{ {
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); SMDS_FaceIteratorPtr anIter = myClient->facesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMDSAbs_Volume: case SMDSAbs_Volume:
{ {
SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator(); SMDS_VolumeIteratorPtr anIter = myClient->volumesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
@ -678,7 +619,7 @@ void SMESH_MeshObj::UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor
//================================================================================= //=================================================================================
bool SMESH_MeshObj::IsNodePrs() const bool SMESH_MeshObj::IsNodePrs() const
{ {
return myMesh->NbEdges() == 0 &&myMesh->NbFaces() == 0 &&myMesh->NbVolumes() == 0 ; return myClient->NbEdges() == 0 &&myClient->NbFaces() == 0 && myClient->NbVolumes() == 0 ;
} }

View File

@ -29,6 +29,10 @@
#ifndef SMESH_OBJECTDEF_H #ifndef SMESH_OBJECTDEF_H
#define SMESH_OBJECTDEF_H #define SMESH_OBJECTDEF_H
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
#include "SMESH_Client.hxx"
// IDL Headers // IDL Headers
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
@ -37,9 +41,6 @@
#include <map> #include <map>
#include <list> #include <list>
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
class vtkPoints; class vtkPoints;
class SALOME_ExtractUnstructuredGrid; class SALOME_ExtractUnstructuredGrid;
@ -121,13 +122,11 @@ public:
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ); virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); } SMESH::SMESH_Mesh_ptr GetMeshServer() { return myClient.GetMeshServer(); }
SMDS_Mesh* GetMesh() const { return myMesh; } SMDS_Mesh* GetMesh() const { return myClient.GetMesh(); }
protected: protected:
int myIsMeshFromServer; SMESH_Client myClient;
SMESH::SMESH_Mesh_var myMeshServer;
SMDS_Mesh* myMesh;
}; };

View File

@ -102,33 +102,24 @@ SMESH_Gen::~SMESH_Gen()
*/ */
//============================================================================= //=============================================================================
SMESH_Mesh* SMESH_Gen::CreateMesh(int studyId) SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
throw(SALOME_Exception) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
MESSAGE("SMESH_Gen::CreateMesh"); MESSAGE("SMESH_Gen::CreateMesh");
// if (aShape.ShapeType() == TopAbs_COMPOUND)
// {
// INFOS("Mesh Compound not yet implemented!");
// throw(SALOME_Exception(LOCALIZED("Mesh Compound not yet implemented!")));
// }
// Get studyContext, create it if it does'nt exist, with a SMESHDS_Document // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
StudyContextStruct *myStudyContext = GetStudyContext(studyId);
// create a new SMESH_mesh object // create a new SMESH_mesh object
SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
SMESH_Mesh *mesh = new SMESH_Mesh(_localId++, theStudyId,
studyId,
this, this,
myStudyContext->myDocument); theIsEmbeddedMode,
myStudyContext->mapMesh[_localId] = mesh; aStudyContext->myDocument);
aStudyContext->mapMesh[_localId] = aMesh;
// associate a TopoDS_Shape to the mesh return aMesh;
//mesh->ShapeToMesh(aShape);
return mesh;
} }
//============================================================================= //=============================================================================

View File

@ -60,7 +60,7 @@ class SMESH_Gen
// SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId) // SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId)
// throw(SALOME_Exception); // throw(SALOME_Exception);
SMESH_Mesh* CreateMesh(int studyId) SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
throw(SALOME_Exception); throw(SALOME_Exception);
bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);

View File

@ -79,16 +79,20 @@ static int MYDEBUG = 0;
*/ */
//============================================================================= //=============================================================================
SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument) SMESH_Mesh::SMESH_Mesh(int theLocalId,
: _groupId( 0 ) int theStudyId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument):
_groupId( 0 )
{ {
INFOS("SMESH_Mesh::SMESH_Mesh(int localId)"); INFOS("SMESH_Mesh::SMESH_Mesh(int localId)");
_id = localId; _id = theLocalId;
_studyId = studyId; _studyId = theStudyId;
_gen = gen; _gen = theGen;
_myDocument = myDocument; _myDocument = theDocument;
_idDoc = _myDocument->NewMesh(); _idDoc = theDocument->NewMesh(theIsEmbeddedMode);
_myMeshDS = _myDocument->GetMesh(_idDoc); _myMeshDS = theDocument->GetMesh(_idDoc);
_isShapeToMesh = false; _isShapeToMesh = false;
} }

View File

@ -79,8 +79,11 @@ class SMESH_Mesh
SMESH_Mesh(); SMESH_Mesh();
SMESH_Mesh(const SMESH_Mesh&); SMESH_Mesh(const SMESH_Mesh&);
public: public:
SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESH_Mesh(int theLocalId,
SMESHDS_Document * myDocument); int theStudyId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument);
virtual ~SMESH_Mesh(); virtual ~SMESH_Mesh();

View File

@ -81,6 +81,12 @@ LDFLAGS += $(OCC_KERNEL_LIBS) \
-lMEDWrapperBase \ -lMEDWrapperBase \
-lMEDWrapper_V2_1 \ -lMEDWrapper_V2_1 \
-lMEDWrapper_V2_2 \ -lMEDWrapper_V2_2 \
-lSalomeResourcesManager \
-lSalomeLifeCycleCORBA \
-lSalomeNotification \
-lSalomeContainer \
-lRegistry \
-lSalomeNS \
-lSALOMELocalTrace \ -lSALOMELocalTrace \
-lSALOMEBasics \ -lSALOMEBasics \
-lOpUtil -lOpUtil

View File

@ -26,15 +26,18 @@
// Module : SMESH // Module : SMESH
#include "SMESH_Client.hxx" #include "SMESH_Client.hxx"
#include "SMESH_Mesh.hxx"
#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Component)
#include CORBA_SERVER_HEADER(SALOME_Exception)
#include "OpUtil.hxx" #include "OpUtil.hxx"
#include "utilities.h" #include "utilities.h"
#include <SMESH_Mesh.hxx>
#include CORBA_SERVER_HEADER(SALOME_Exception)
#ifdef WNT #ifdef WNT
#include <process.h> #include <process.h>
#else #else
@ -57,30 +60,8 @@ static int MYDEBUG = 0;
static int MYDEBUG = 0; static int MYDEBUG = 0;
#endif #endif
//======================================================================= namespace
// function : Create()
// purpose : Create in client not in a container
//=======================================================================
SMESH_Client::SMESH_Client()
{ {
pid_client =
#ifdef WNT
(long)_getpid();
#else
(long)getpid();
#endif
}
//=======================================================================
// function : Create()
// purpose :
//=======================================================================
SMESH_Client::SMESH_Client(Engines::Container_ptr client)
{
pid_client = client->getPID();
}
namespace{
inline const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, int theId){ inline const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, int theId){
if(const SMDS_MeshNode* anElem = theMesh->FindNode(theId)) return anElem; if(const SMDS_MeshNode* anElem = theMesh->FindNode(theId)) return anElem;
@ -344,42 +325,121 @@ namespace{
} }
} }
//================================================================================= //=======================================================================
// function : Update SMESH::SMESH_Gen_var
// purpose : Update mesh SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB,
//================================================================================= CORBA::Boolean& theIsEmbeddedMode)
SMDS_Mesh* SMESH_Client::Update( SMESH::SMESH_Gen_ptr smesh,
SMESH::SMESH_Mesh_ptr theMeshServer,
SMDS_Mesh* theMesh,
int theIsClear,
int& theIsUpdated )
{ {
SMDS_Mesh* meshPtr = theMesh; static SMESH::SMESH_Gen_var aMeshGen;
theIsUpdated = 0;
SMESH::log_array_var aSeq = theMeshServer->GetLog( theIsClear ); if(CORBA::is_nil(aMeshGen.in())){
CORBA::Long aLength = aSeq->length(); #ifdef WNT
long aClientPID = (long)_getpid();
#else
long aClientPID = (long)getpid();
#endif
if( MYDEBUG ) SALOME_NamingService aNamingService(theORB);
MESSAGE( "Update: length of the script is "<<aLength ); SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService);
Engines::Component_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH");
aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent);
if( !aLength ) std::string aClientHostName = GetHostname();
return meshPtr; // nothing to update 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();
string hst_client = GetHostname(); return aMeshGen;
Engines::Container_var ctn_server = smesh->GetContainerRef(); }
long pid_server = ctn_server->getPID();
if ( (pid_client==pid_server) && (strcmp(hst_client.c_str(), ctn_server->getHostName())==0) )
{ //=======================================================================
// function : Create()
// purpose :
//=======================================================================
SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB,
SMESH::SMESH_Mesh_ptr theMesh):
myMeshServer(SMESH::SMESH_Mesh::_duplicate(theMesh)),
mySMESHDSMesh(NULL),
mySMDSMesh(NULL)
{
myMeshServer->Register();
CORBA::Boolean anIsEmbeddedMode;
GetSMESHGen(theORB,anIsEmbeddedMode);
if(anIsEmbeddedMode){
if ( MYDEBUG ) if ( MYDEBUG )
MESSAGE("Info: The same process, update mesh by pointer "); MESSAGE("Info: The same process, update mesh by pointer ");
// just set client mesh pointer to server mesh pointer // just set client mesh pointer to server mesh pointer
meshPtr = ((SMESH_Mesh*)theMeshServer->GetMeshPtr())->GetMeshDS(); SMESH_Mesh* aMesh = reinterpret_cast<SMESH_Mesh*>(theMesh->GetMeshPtr());
if ( meshPtr ) mySMESHDSMesh = aMesh->GetMeshDS();
theIsUpdated = 1; mySMDSMesh = mySMESHDSMesh;
} }else
else mySMDSMesh = new SMDS_Mesh();
{ }
//=================================================================================
// function : ~SMESH_Client
// purpose : Destructor
//=================================================================================
SMESH_Client::~SMESH_Client()
{
myMeshServer->Destroy();
if(!mySMESHDSMesh)
delete mySMDSMesh;
}
//=================================================================================
SMDS_Mesh*
SMESH_Client::GetMesh() const
{
return mySMDSMesh;
}
//=================================================================================
SMDS_Mesh*
SMESH_Client::operator->() const
{
return GetMesh();
}
//=================================================================================
SMESH::SMESH_Mesh_ptr
SMESH_Client::GetMeshServer()
{
return myMeshServer.in();
}
//=================================================================================
// function : SMESH_Client
// purpose : Update mesh
//=================================================================================
bool
SMESH_Client::Update(bool theIsClear)
{
bool anIsModified = true;
if(mySMESHDSMesh){
SMESHDS_Script* aScript = mySMESHDSMesh->GetScript();
anIsModified = aScript->IsModified();
aScript->SetModified(false);
}else{
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 // update client mesh structure by logged changes commands
try try
{ {
@ -392,32 +452,32 @@ SMDS_Mesh* SMESH_Client::Update( SMESH::SMESH_Gen_ptr smesh,
switch(aCommand) switch(aCommand)
{ {
case SMESH::ADD_NODE : AddNodesWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_NODE : AddNodesWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_EDGE : AddEdgesWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_EDGE : AddEdgesWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_TRIANGLE : AddTriasWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_TRIANGLE : AddTriasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_POLYGON : AddPolygonsWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_POLYGON : AddPolygonsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_PYRAMID : AddPiramidsWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_PYRAMID : AddPiramidsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_PRISM : AddPrismsWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_PRISM : AddPrismsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( meshPtr, aSeq, anId ); break; case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( meshPtr, aSeq, anId ); break; case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( mySMDSMesh, aSeq, anId ); break;
case SMESH::REMOVE_NODE: case SMESH::REMOVE_NODE:
for( ; anElemId < aNbElems; anElemId++ ) for( ; anElemId < aNbElems; anElemId++ )
meshPtr->RemoveNode( FindNode( meshPtr, anIndexes[anElemId] ) ); mySMDSMesh->RemoveNode( FindNode( mySMDSMesh, anIndexes[anElemId] ) );
break; break;
case SMESH::REMOVE_ELEMENT: case SMESH::REMOVE_ELEMENT:
for( ; anElemId < aNbElems; anElemId++ ) for( ; anElemId < aNbElems; anElemId++ )
meshPtr->RemoveElement( FindElement( meshPtr, anIndexes[anElemId] ) ); mySMDSMesh->RemoveElement( FindElement( mySMDSMesh, anIndexes[anElemId] ) );
break; break;
case SMESH::MOVE_NODE: case SMESH::MOVE_NODE:
for(CORBA::Long aCoordId=0; anElemId < aNbElems; anElemId++, aCoordId+=3) for(CORBA::Long aCoordId=0; anElemId < aNbElems; anElemId++, aCoordId+=3)
{ {
SMDS_MeshNode* node = SMDS_MeshNode* node =
const_cast<SMDS_MeshNode*>( FindNode( meshPtr, anIndexes[anElemId] )); const_cast<SMDS_MeshNode*>( FindNode( mySMDSMesh, anIndexes[anElemId] ));
node->setXYZ( aCoords[aCoordId], aCoords[aCoordId+1], aCoords[aCoordId+2] ); node->setXYZ( aCoords[aCoordId], aCoords[aCoordId+1], aCoords[aCoordId+2] );
} }
break; break;
@ -426,33 +486,32 @@ SMDS_Mesh* SMESH_Client::Update( SMESH::SMESH_Gen_ptr smesh,
for ( CORBA::Long i = 0; anElemId < aNbElems; anElemId++ ) for ( CORBA::Long i = 0; anElemId < aNbElems; anElemId++ )
{ {
// find element // find element
const SMDS_MeshElement* elem = FindElement( meshPtr, anIndexes[i++] ); const SMDS_MeshElement* elem = FindElement( mySMDSMesh, anIndexes[i++] );
// nb nodes // nb nodes
int nbNodes = anIndexes[i++]; int nbNodes = anIndexes[i++];
// nodes // nodes
//ASSERT( nbNodes < 9 ); //ASSERT( nbNodes < 9 );
const SMDS_MeshNode* aNodes[ nbNodes ]; const SMDS_MeshNode* aNodes[ nbNodes ];
for ( int iNode = 0; iNode < nbNodes; iNode++ ) for ( int iNode = 0; iNode < nbNodes; iNode++ )
aNodes[ iNode ] = FindNode( meshPtr, anIndexes[i++] ); aNodes[ iNode ] = FindNode( mySMDSMesh, anIndexes[i++] );
// change // change
meshPtr->ChangeElementNodes( elem, aNodes, nbNodes ); mySMDSMesh->ChangeElementNodes( elem, aNodes, nbNodes );
} }
break; break;
case SMESH::CHANGE_POLYHEDRON_NODES: case SMESH::CHANGE_POLYHEDRON_NODES:
ChangePolyhedronNodes(meshPtr, aSeq, anId); ChangePolyhedronNodes(mySMDSMesh, aSeq, anId);
break; break;
case SMESH::RENUMBER: case SMESH::RENUMBER:
for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3) for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3)
{ {
meshPtr->Renumber( anIndexes[i], anIndexes[i+1], anIndexes[i+2] ); mySMDSMesh->Renumber( anIndexes[i], anIndexes[i+1], anIndexes[i+2] );
} }
break; break;
default:; default:;
} }
} }
theIsUpdated = 1;
} }
catch ( SALOME::SALOME_Exception& exc ) catch ( SALOME::SALOME_Exception& exc )
{ {
@ -466,15 +525,15 @@ SMDS_Mesh* SMESH_Client::Update( SMESH::SMESH_Gen_ptr smesh,
{ {
INFOS("Unknown exception was cought !!!"); INFOS("Unknown exception was cought !!!");
} }
} // end of else (update mesh by log script
if ( MYDEBUG && meshPtr ) if ( MYDEBUG && mySMDSMesh )
{ {
MESSAGE("Update - meshPtr->NbNodes() = "<<meshPtr->NbNodes()); MESSAGE("Update - mySMDSMesh->NbNodes() = "<<mySMDSMesh->NbNodes());
MESSAGE("Update - meshPtr->NbEdges() = "<<meshPtr->NbEdges()); MESSAGE("Update - mySMDSMesh->NbEdges() = "<<mySMDSMesh->NbEdges());
MESSAGE("Update - meshPtr->NbFaces() = "<<meshPtr->NbFaces()); MESSAGE("Update - mySMDSMesh->NbFaces() = "<<mySMDSMesh->NbFaces());
MESSAGE("Update - meshPtr->NbVolumes() = "<<meshPtr->NbVolumes()); MESSAGE("Update - mySMDSMesh->NbVolumes() = "<<mySMDSMesh->NbVolumes());
} }
} // end of update mesh by log script
return meshPtr; return anIsModified;
} }

View File

@ -31,11 +31,6 @@
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen) #include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
//#include CORBA_SERVER_HEADER(SALOME_Container)
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS
#define SMESHCLIENT_WNT_EXPORT __declspec( dllexport ) #define SMESHCLIENT_WNT_EXPORT __declspec( dllexport )
@ -43,41 +38,41 @@
#define SMESHCLIENT_WNT_EXPORT #define SMESHCLIENT_WNT_EXPORT
#endif #endif
class SMESHDS_Mesh;
class SMDS_Mesh; class SMDS_Mesh;
//===================================================================== //=====================================================================
// SMESH_Client : class definition // SMESH_Client : class definition
//===================================================================== //=====================================================================
class SMESHCLIENT_WNT_EXPORT SMESH_Client { class SMESHCLIENT_WNT_EXPORT SMESH_Client
{
public: public:
static
SMESH::SMESH_Gen_var
GetSMESHGen(CORBA::ORB_ptr theORB,
CORBA::Boolean& theIsEmbeddedMode);
inline void* operator new(size_t,void* anAddress) SMESH_Client(CORBA::ORB_ptr theORB,
{ SMESH::SMESH_Mesh_ptr theMesh);
return anAddress; ~SMESH_Client();
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// Methods PUBLIC
//
SMESH_Client();
SMESH_Client(Engines::Container_ptr client);
SMDS_Mesh* Update( SMESH::SMESH_Gen_ptr smesh,
SMESH::SMESH_Mesh_ptr theMeshServer,
SMDS_Mesh* theMesh,
int theIsClear,
int& theIsUpdated );
private: bool
// Fields PRIVATE Update(bool theIsClear);
//
long pid_client; SMDS_Mesh*
GetMesh() const;
SMDS_Mesh*
operator->() const;
SMESH::SMESH_Mesh_ptr
GetMeshServer();
protected:
SMESH::SMESH_Mesh_var myMeshServer;
SMESHDS_Mesh* mySMESHDSMesh;
SMDS_Mesh* mySMDSMesh;
}; };

View File

@ -43,13 +43,13 @@ SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID)
//function : NewMesh //function : NewMesh
//purpose : //purpose :
//======================================================================= //=======================================================================
int SMESHDS_Document::NewMesh() int SMESHDS_Document::NewMesh(bool theIsEmbeddedMode)
{ {
static int NewMeshID = 0; static int aNewMeshID = 0;
NewMeshID++; aNewMeshID++;
SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(NewMeshID); SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(aNewMeshID,theIsEmbeddedMode);
myMeshes[NewMeshID] = aNewMesh; myMeshes[aNewMeshID] = aNewMesh;
return NewMeshID; return aNewMeshID;
} }
//======================================================================= //=======================================================================

View File

@ -36,7 +36,7 @@ class SMESHDS_Document
{ {
public: public:
SMESHDS_Document(int UserID); SMESHDS_Document(int UserID);
int NewMesh(); int NewMesh(bool theIsEmbeddedMode);
void RemoveMesh(int MeshID); void RemoveMesh(int MeshID);
SMESHDS_Mesh * GetMesh(int MeshID); SMESHDS_Mesh * GetMesh(int MeshID);
void AddHypothesis(SMESHDS_Hypothesis * H); void AddHypothesis(SMESHDS_Hypothesis * H);

View File

@ -45,9 +45,10 @@ using namespace std;
//function : Create //function : Create
//purpose : //purpose :
//======================================================================= //=======================================================================
SMESHDS_Mesh::SMESHDS_Mesh(int MeshID):myMeshID(MeshID) SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
myMeshID(theMeshID)
{ {
myScript = new SMESHDS_Script(); myScript = new SMESHDS_Script(theIsEmbeddedMode);
} }
//======================================================================= //=======================================================================

View File

@ -78,7 +78,7 @@ class SMESHDS_GroupBase;
class SMESHDS_WNT_EXPORT SMESHDS_Mesh:public SMDS_Mesh{ class SMESHDS_WNT_EXPORT SMESHDS_Mesh:public SMDS_Mesh{
public: public:
SMESHDS_Mesh(int MeshID); SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode);
void ShapeToMesh(const TopoDS_Shape & S); void ShapeToMesh(const TopoDS_Shape & S);
bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H); bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H);
bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H); bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);

View File

@ -30,6 +30,14 @@
using namespace std; using namespace std;
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
myIsEmbeddedMode(theIsEmbeddedMode)
{}
//======================================================================= //=======================================================================
//function : Destructor //function : Destructor
//purpose : //purpose :
@ -39,6 +47,18 @@ SMESHDS_Script::~SMESHDS_Script()
Clear(); Clear();
} }
//=======================================================================
void SMESHDS_Script::SetModified(bool theModified)
{
myIsModified = theModified;
}
//=======================================================================
bool SMESHDS_Script::IsModified()
{
return myIsModified;
}
//======================================================================= //=======================================================================
//function : getCommand //function : getCommand
//purpose : //purpose :
@ -78,6 +98,10 @@ void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
//======================================================================= //=======================================================================
void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2) void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2); getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
} }
@ -88,6 +112,10 @@ void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
void SMESHDS_Script::AddFace(int NewFaceID, void SMESHDS_Script::AddFace(int NewFaceID,
int idnode1, int idnode2, int idnode3) int idnode1, int idnode2, int idnode3)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID, getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
idnode1, idnode2, idnode3); idnode1, idnode2, idnode3);
} }
@ -100,6 +128,10 @@ void SMESHDS_Script::AddFace(int NewFaceID,
int idnode1, int idnode2, int idnode1, int idnode2,
int idnode3, int idnode4) int idnode3, int idnode4)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID, getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
idnode1, idnode2, idnode1, idnode2,
idnode3, idnode4); idnode3, idnode4);
@ -113,6 +145,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode1, int idnode2,
int idnode3, int idnode4) int idnode3, int idnode4)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID, getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
idnode1, idnode2, idnode1, idnode2,
idnode3, idnode4); idnode3, idnode4);
@ -126,6 +162,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode1, int idnode2,
int idnode3, int idnode4, int idnode5) int idnode3, int idnode4, int idnode5)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPyramid)->AddVolume(NewID, getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
idnode1, idnode2, idnode1, idnode2,
idnode3, idnode4, idnode5); idnode3, idnode4, idnode5);
@ -139,6 +179,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode3, int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6) int idnode4, int idnode5, int idnode6)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPrism)->AddVolume(NewID, getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
idnode1, idnode2, idnode3, idnode1, idnode2, idnode3,
idnode4, idnode5, idnode6); idnode4, idnode5, idnode6);
@ -152,6 +196,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode3, int idnode4, int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5, int idnode6, int idnode7, int idnode8) int idnode5, int idnode6, int idnode7, int idnode8)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID, getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
idnode1, idnode2, idnode3, idnode4, idnode1, idnode2, idnode3, idnode4,
idnode5, idnode6, idnode7, idnode8); idnode5, idnode6, idnode7, idnode8);
@ -163,6 +211,10 @@ void SMESHDS_Script::AddVolume(int NewID,
//======================================================================= //=======================================================================
void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids) void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids); getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
} }
@ -174,6 +226,10 @@ void SMESHDS_Script::AddPolyhedralVolume (int NewID,
std::vector<int> nodes_ids, std::vector<int> nodes_ids,
std::vector<int> quantities) std::vector<int> quantities)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
(NewID, nodes_ids, quantities); (NewID, nodes_ids, quantities);
} }
@ -184,6 +240,10 @@ void SMESHDS_Script::AddPolyhedralVolume (int NewID,
//======================================================================= //=======================================================================
void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z) void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z); getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
} }
@ -193,6 +253,10 @@ void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
//======================================================================= //=======================================================================
void SMESHDS_Script::RemoveNode(int ID) void SMESHDS_Script::RemoveNode(int ID)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_RemoveNode)->RemoveNode(ID); getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
} }
@ -202,6 +266,10 @@ void SMESHDS_Script::RemoveNode(int ID)
//======================================================================= //=======================================================================
void SMESHDS_Script::RemoveElement(int ElementID) void SMESHDS_Script::RemoveElement(int ElementID)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID); getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
} }
@ -212,6 +280,10 @@ void SMESHDS_Script::RemoveElement(int ElementID)
void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes) void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes ); getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
} }
@ -223,6 +295,10 @@ void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
std::vector<int> nodes_ids, std::vector<int> nodes_ids,
std::vector<int> quantities) std::vector<int> quantities)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
(ElementID, nodes_ids, quantities); (ElementID, nodes_ids, quantities);
} }
@ -233,6 +309,10 @@ void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
//======================================================================= //=======================================================================
void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID) void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID ); getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
} }
@ -269,6 +349,10 @@ const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
//======================================================================= //=======================================================================
void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12) void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12); getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12);
} }
@ -279,6 +363,10 @@ void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
int n12, int n23, int n31) int n12, int n23, int n31)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3, getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
n12, n23, n31); n12, n23, n31);
} }
@ -290,6 +378,10 @@ void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4, void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
int n12, int n23, int n34, int n41) int n12, int n23, int n34, int n41)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4, getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
n12, n23, n34, n41); n12, n23, n34, n41);
} }
@ -302,6 +394,10 @@ void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n12, int n23, int n31, int n12, int n23, int n31,
int n14, int n24, int n34) int n14, int n24, int n34)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4, getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
n12, n23, n31, n12, n23, n31,
n14, n24, n34); n14, n24, n34);
@ -315,6 +411,10 @@ void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n5, int n12, int n23, int n34, int n41, int n5, int n12, int n23, int n34, int n41,
int n15, int n25, int n35, int n45) int n15, int n25, int n35, int n45)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5, getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
n12, n23, n34, n41, n12, n23, n34, n41,
n15, n25, n35, n45); n15, n25, n35, n45);
@ -329,6 +429,10 @@ void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n45, int n56, int n64, int n45, int n56, int n64,
int n14, int n25, int n36) int n14, int n25, int n36)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6, getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
n12, n23, n31, n12, n23, n31,
n45, n56, n64, n45, n56, n64,
@ -345,6 +449,10 @@ void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
int n56, int n67, int n78, int n85, int n56, int n67, int n78, int n85,
int n15, int n26, int n37, int n48) int n15, int n26, int n37, int n48)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4, getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
n5, n6, n7, n8, n5, n6, n7, n8,
n12, n23, n34, n41, n12, n23, n34, n41,

View File

@ -36,9 +36,12 @@
class SMESHDS_Script class SMESHDS_Script
{ {
public: public:
SMESHDS_Script() {}; SMESHDS_Script(bool theIsEmbeddedMode);
~SMESHDS_Script(); ~SMESHDS_Script();
void SetModified(bool theModified);
bool IsModified();
void AddNode(int NewNodeID, double x, double y, double z); void AddNode(int NewNodeID, double x, double y, double z);
void AddEdge(int NewEdgeID, int idnode1, int idnode2); void AddEdge(int NewEdgeID, int idnode1, int idnode2);
void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3); void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3);
@ -95,6 +98,9 @@ class SMESHDS_Script
SMESHDS_Command* getCommand(const SMESHDS_CommandType aType); SMESHDS_Command* getCommand(const SMESHDS_CommandType aType);
std::list<SMESHDS_Command*> myCommands; std::list<SMESHDS_Command*> myCommands;
bool myIsEmbeddedMode;
bool myIsModified;
}; };
#endif #endif

View File

@ -26,6 +26,7 @@
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESH_Client.hxx"
#include "SMESHGUI_NodesDlg.h" #include "SMESHGUI_NodesDlg.h"
#include "SMESHGUI_TransparencyDlg.h" #include "SMESHGUI_TransparencyDlg.h"
#include "SMESHGUI_ClippingDlg.h" #include "SMESHGUI_ClippingDlg.h"
@ -828,9 +829,8 @@ SalomeApp_Module( "SMESH" )
{ {
if ( CORBA::is_nil( myComponentSMESH ) ) if ( CORBA::is_nil( myComponentSMESH ) )
{ {
SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() ); CORBA::Boolean anIsEmbeddedMode;
Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" ); myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
} }
myActiveDialogBox = 0; myActiveDialogBox = 0;

View File

@ -244,6 +244,7 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb,
_thisObj = this ; _thisObj = this ;
_id = myPoa->activate_object( _thisObj ); _id = myPoa->activate_object( _thisObj );
myIsEmbeddedMode = false;
myShapeReader = NULL; // shape reader myShapeReader = NULL; // shape reader
mySMESHGen = this; mySMESHGen = this;
} }
@ -377,7 +378,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh()
// create a new mesh object servant, store it in a map in study context // create a new mesh object servant, store it in a map in study context
SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() ); SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() );
// create a new mesh object // create a new mesh object
meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID() )); meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode ));
// activate the CORBA servant of Mesh // activate the CORBA servant of Mesh
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() ); SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() );
@ -407,6 +408,32 @@ GEOM_Client* SMESH_Gen_i::GetShapeReader()
return myShapeReader; return myShapeReader;
} }
//=============================================================================
/*!
* SMESH_Gen_i::SetEmbeddedMode
*
* Set current mode
*/
//=============================================================================
void SMESH_Gen_i::SetEmbeddedMode( CORBA::Boolean theMode )
{
myIsEmbeddedMode = theMode;
}
//=============================================================================
/*!
* SMESH_Gen_i::IsEmbeddedMode
*
* Get current mode
*/
//=============================================================================
CORBA::Boolean SMESH_Gen_i::IsEmbeddedMode()
{
return myIsEmbeddedMode;
}
//============================================================================= //=============================================================================
/*! /*!
* SMESH_Gen_i::SetCurrentStudy * SMESH_Gen_i::SetCurrentStudy

View File

@ -166,6 +166,11 @@ public:
// Interface methods // Interface methods
// ***************************************** // *****************************************
// Set current study
void SetEmbeddedMode( CORBA::Boolean theMode );
// Get current study
CORBA::Boolean IsEmbeddedMode();
// Set current study // Set current study
void SetCurrentStudy( SALOMEDS::Study_ptr theStudy ); void SetCurrentStudy( SALOMEDS::Study_ptr theStudy );
// Get current study // Get current study
@ -417,6 +422,7 @@ private:
GEOM_Client* myShapeReader; // Shape reader GEOM_Client* myShapeReader; // Shape reader
SALOMEDS::Study_var myCurrentStudy; // Current study SALOMEDS::Study_var myCurrentStudy; // Current study
CORBA::Boolean myIsEmbeddedMode; // Current mode
// Dump Python: trace of API methods calls // Dump Python: trace of API methods calls
std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts; std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts;