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();
/*!
Set the current mode
*/
void SetEmbeddedMode( in boolean theMode );
/*!
Get the current mode
*/
boolean IsEmbeddedMode();
/*!
Set the current study
*/

View File

@ -31,14 +31,22 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
@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
LIB = libSMESHObject.la
LIB_SRC = SMESH_Object.cxx SMESH_DeviceActor.cxx SMESH_Actor.cxx \
SMESH_ExtractGeometry.cxx SMESH_ActorUtils.cxx
LIB_SRC = \
SMESH_Object.cxx \
SMESH_DeviceActor.cxx \
SMESH_Actor.cxx \
SMESH_ExtractGeometry.cxx \
SMESH_ActorUtils.cxx
LIB_CLIENT_IDL = SALOME_Exception.idl \
SALOME_GenericObj.idl \
@ -54,10 +62,75 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \
BIN =
BIN_SRC =
CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
$(BOOST_CPPFLAGS) $(QT_INCLUDES)
LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lSMDS \
-lSMESHClient -lSalomeApp -lSalomeObject -lSMESHControls -lSalomeLifeCycleCORBA -lSalomeDS -lCASCatch -lSalomeSession
LDFLAGSFORBIN += $(LDFLAGS)
CPPFLAGS+= \
-I${KERNEL_ROOT_DIR}/include/salome \
-I${GUI_ROOT_DIR}/include/salome \
$(OCC_INCLUDES) \
$(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@

View File

@ -31,15 +31,12 @@
#include "SMDS_Mesh.hxx"
#include "SMESH_Actor.h"
#include "SMESH_ControlsDef.hxx"
#include "SMESH_Client.hxx"
#include "SalomeApp_Application.h"
#include "VTKViewer_ExtractUnstructuredGrid.h"
#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SALOME_Exception)
#include "SALOME_LifeCycleCORBA.hxx"
#include "SalomeApp_Application.h"
#include <vtkCell.h>
#include <vtkIdList.h>
#include <vtkIntArray.h>
@ -238,42 +235,6 @@ void SMESH_VisualObjDef::buildNodePrs()
aPoints->Delete();
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
// 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 )
MESSAGE("SMESH_MeshObj - theMesh->_is_nil() = "<<theMesh->_is_nil());
myMeshServer = SMESH::SMESH_Mesh::_duplicate( theMesh );
myMeshServer->Register();
myMesh = new SMDS_Mesh();
myIsMeshFromServer = 0;
MESSAGE("SMESH_MeshObj - this = "<<this<<"; theMesh->_is_nil() = "<<theMesh->_is_nil());
}
//=================================================================================
@ -541,9 +498,8 @@ SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh)
//=================================================================================
SMESH_MeshObj::~SMESH_MeshObj()
{
myMeshServer->Destroy();
if ( !myIsMeshFromServer )
delete myMesh;
if ( MYDEBUG )
MESSAGE("SMESH_MeshObj - this = "<<this<<"\n");
}
//=================================================================================
@ -553,23 +509,8 @@ SMESH_MeshObj::~SMESH_MeshObj()
void SMESH_MeshObj::Update( int theIsClear )
{
// Update SMDS_Mesh on client part
SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( SalomeApp_Application::namingService() );
Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" );
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();
}
if ( myClient.Update(theIsClear) )
buildPrs(); // Fill unstructured grid
}
//=================================================================================
@ -578,7 +519,7 @@ void SMESH_MeshObj::Update( int theIsClear )
//=================================================================================
int SMESH_MeshObj::GetElemDimension( const int theObjId )
{
const SMDS_MeshElement* anElem = myMesh->FindElement( theObjId );
const SMDS_MeshElement* anElem = myClient->FindElement( theObjId );
if ( anElem == 0 )
return 0;
@ -602,22 +543,22 @@ int SMESH_MeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{
case SMDSAbs_Node:
{
return myMesh->NbNodes();
return myClient->NbNodes();
}
break;
case SMDSAbs_Edge:
{
return myMesh->NbEdges();
return myClient->NbEdges();
}
break;
case SMDSAbs_Face:
{
return myMesh->NbFaces();
return myClient->NbFaces();
}
break;
case SMDSAbs_Volume:
{
return myMesh->NbVolumes();
return myClient->NbVolumes();
}
break;
default:
@ -634,25 +575,25 @@ int SMESH_MeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList&
{
case SMDSAbs_Node:
{
SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator();
SMDS_NodeIteratorPtr anIter = myClient->nodesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
case SMDSAbs_Edge:
{
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
SMDS_EdgeIteratorPtr anIter = myClient->edgesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
case SMDSAbs_Face:
{
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
SMDS_FaceIteratorPtr anIter = myClient->facesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
case SMDSAbs_Volume:
{
SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
SMDS_VolumeIteratorPtr anIter = myClient->volumesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
@ -678,7 +619,7 @@ void SMESH_MeshObj::UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor
//=================================================================================
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
#define SMESH_OBJECTDEF_H
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
#include "SMESH_Client.hxx"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
@ -37,9 +41,6 @@
#include <map>
#include <list>
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
class vtkPoints;
class SALOME_ExtractUnstructuredGrid;
@ -121,13 +122,11 @@ public:
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); }
SMDS_Mesh* GetMesh() const { return myMesh; }
SMESH::SMESH_Mesh_ptr GetMeshServer() { return myClient.GetMeshServer(); }
SMDS_Mesh* GetMesh() const { return myClient.GetMesh(); }
protected:
int myIsMeshFromServer;
SMESH::SMESH_Mesh_var myMeshServer;
SMDS_Mesh* myMesh;
SMESH_Client myClient;
};

View File

@ -102,33 +102,24 @@ SMESH_Gen::~SMESH_Gen()
*/
//=============================================================================
SMESH_Mesh* SMESH_Gen::CreateMesh(int studyId)
throw(SALOME_Exception)
SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
MESSAGE("SMESH_Gen::CreateMesh");
// if (aShape.ShapeType() == TopAbs_COMPOUND)
// {
// INFOS("Mesh Compound not yet implemented!");
// throw(SALOME_Exception(LOCALIZED("Mesh Compound not yet implemented!")));
// }
Unexpect aCatch(SalomeException);
MESSAGE("SMESH_Gen::CreateMesh");
// 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
SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
theStudyId,
this,
theIsEmbeddedMode,
aStudyContext->myDocument);
aStudyContext->mapMesh[_localId] = aMesh;
// create a new SMESH_mesh object
SMESH_Mesh *mesh = new SMESH_Mesh(_localId++,
studyId,
this,
myStudyContext->myDocument);
myStudyContext->mapMesh[_localId] = mesh;
// associate a TopoDS_Shape to the mesh
//mesh->ShapeToMesh(aShape);
return mesh;
return aMesh;
}
//=============================================================================

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,11 +31,6 @@
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
#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
#define SMESHCLIENT_WNT_EXPORT __declspec( dllexport )
@ -43,41 +38,41 @@
#define SMESHCLIENT_WNT_EXPORT
#endif
class SMESHDS_Mesh;
class SMDS_Mesh;
//=====================================================================
// SMESH_Client : class definition
//=====================================================================
class SMESHCLIENT_WNT_EXPORT SMESH_Client {
class SMESHCLIENT_WNT_EXPORT SMESH_Client
{
public:
inline void* operator new(size_t,void* anAddress)
{
return anAddress;
}
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 );
static
SMESH::SMESH_Gen_var
GetSMESHGen(CORBA::ORB_ptr theORB,
CORBA::Boolean& theIsEmbeddedMode);
private:
// Fields PRIVATE
//
long pid_client;
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();
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
//purpose :
//=======================================================================
int SMESHDS_Document::NewMesh()
int SMESHDS_Document::NewMesh(bool theIsEmbeddedMode)
{
static int NewMeshID = 0;
NewMeshID++;
SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(NewMeshID);
myMeshes[NewMeshID] = aNewMesh;
return NewMeshID;
static int aNewMeshID = 0;
aNewMeshID++;
SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(aNewMeshID,theIsEmbeddedMode);
myMeshes[aNewMeshID] = aNewMesh;
return aNewMeshID;
}
//=======================================================================

View File

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

View File

@ -45,9 +45,10 @@ using namespace std;
//function : Create
//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{
public:
SMESHDS_Mesh(int MeshID);
SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode);
void ShapeToMesh(const TopoDS_Shape & S);
bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H);
bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);

View File

@ -30,6 +30,14 @@
using namespace std;
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
myIsEmbeddedMode(theIsEmbeddedMode)
{}
//=======================================================================
//function : Destructor
//purpose :
@ -39,6 +47,18 @@ SMESHDS_Script::~SMESHDS_Script()
Clear();
}
//=======================================================================
void SMESHDS_Script::SetModified(bool theModified)
{
myIsModified = theModified;
}
//=======================================================================
bool SMESHDS_Script::IsModified()
{
return myIsModified;
}
//=======================================================================
//function : getCommand
//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)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
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,
int idnode1, int idnode2, int idnode3)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
idnode1, idnode2, idnode3);
}
@ -100,6 +128,10 @@ void SMESHDS_Script::AddFace(int NewFaceID,
int idnode1, int idnode2,
int idnode3, int idnode4)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
idnode1, idnode2,
idnode3, idnode4);
@ -113,6 +145,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2,
int idnode3, int idnode4)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
idnode1, idnode2,
idnode3, idnode4);
@ -126,6 +162,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2,
int idnode3, int idnode4, int idnode5)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
idnode1, idnode2,
idnode3, idnode4, idnode5);
@ -139,6 +179,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
idnode1, idnode2, idnode3,
idnode4, idnode5, idnode6);
@ -152,6 +196,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5, int idnode6, int idnode7, int idnode8)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
idnode1, idnode2, idnode3, idnode4,
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)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
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> quantities)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
(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)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
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)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
}
@ -202,6 +266,10 @@ void SMESHDS_Script::RemoveNode(int ID)
//=======================================================================
void SMESHDS_Script::RemoveElement(int ElementID)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
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)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
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> quantities)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
(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)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
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)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
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,
int n12, int n23, int n31)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
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,
int n12, int n23, int n34, int n41)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
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 n14, int n24, int n34)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
n12, n23, n31,
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 n15, int n25, int n35, int n45)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
n12, n23, n34, n41,
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 n14, int n25, int n36)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
n12, n23, n31,
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 n15, int n26, int n37, int n48)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
n5, n6, n7, n8,
n12, n23, n34, n41,

View File

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

View File

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

View File

@ -244,6 +244,7 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb,
_thisObj = this ;
_id = myPoa->activate_object( _thisObj );
myIsEmbeddedMode = false;
myShapeReader = NULL; // shape reader
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
SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() );
// create a new mesh object
meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID() ));
meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode ));
// activate the CORBA servant of Mesh
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() );
@ -407,6 +408,32 @@ GEOM_Client* SMESH_Gen_i::GetShapeReader()
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

View File

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