SMESH_Pattern GetPattern();
+ /*!
+ Set the current mode
+ */
+ void SetEmbeddedMode( in boolean theMode );
+
+ /*!
+ Get the current mode
+ */
+ boolean IsEmbeddedMode();
+
/*!
Set the current study
*/
@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 \
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@
#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>
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();
- */
}
//=================================================================================
// 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());
}
//=================================================================================
//=================================================================================
SMESH_MeshObj::~SMESH_MeshObj()
{
- myMeshServer->Destroy();
- if ( !myIsMeshFromServer )
- delete myMesh;
+ if ( MYDEBUG )
+ MESSAGE("SMESH_MeshObj - this = "<<this<<"\n");
}
//=================================================================================
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
}
//=================================================================================
//=================================================================================
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;
{
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:
{
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;
//=================================================================================
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 ;
}
#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)
#include <map>
#include <list>
-#include "SMESH_Controls.hxx"
-#include "SMESH_Object.h"
-
class vtkPoints;
class SALOME_ExtractUnstructuredGrid;
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;
};
*/
//=============================================================================
-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
-
- StudyContextStruct *myStudyContext = GetStudyContext(studyId);
-
- // create a new SMESH_mesh object
-
- SMESH_Mesh *mesh = new SMESH_Mesh(_localId++,
- studyId,
- this,
- myStudyContext->myDocument);
- myStudyContext->mapMesh[_localId] = mesh;
+ // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+ StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
- // associate a TopoDS_Shape to the mesh
+ // create a new SMESH_mesh object
+ SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
+ theStudyId,
+ this,
+ theIsEmbeddedMode,
+ aStudyContext->myDocument);
+ aStudyContext->mapMesh[_localId] = aMesh;
-//mesh->ShapeToMesh(aShape);
- return mesh;
+ return aMesh;
}
//=============================================================================
// 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);
*/
//=============================================================================
-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;
}
//=============================================================================
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();
-lMEDWrapperBase \
-lMEDWrapper_V2_1 \
-lMEDWrapper_V2_2 \
+ -lSalomeResourcesManager \
+ -lSalomeLifeCycleCORBA \
+ -lSalomeNotification \
+ -lSalomeContainer \
+ -lRegistry \
+ -lSalomeNS \
-lSALOMELocalTrace \
-lSALOMEBasics \
-lOpUtil
// 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
static int MYDEBUG = 0;
#endif
-//=======================================================================
-// 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)
+namespace
{
- 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;
}
}
+//=======================================================================
+SMESH::SMESH_Gen_var
+SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB,
+ CORBA::Boolean& theIsEmbeddedMode)
+{
+ 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::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
+ 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;
+}
+
+
//=================================================================================
-// function : Update
+SMDS_Mesh*
+SMESH_Client::operator->() const
+{
+ return GetMesh();
+}
+
+
+//=================================================================================
+SMESH::SMESH_Mesh_ptr
+SMESH_Client::GetMeshServer()
+{
+ return myMeshServer.in();
+}
+
+
+//=================================================================================
+// function : SMESH_Client
// 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 )
+bool
+SMESH_Client::Update(bool theIsClear)
{
- 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 );
+ 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( !aLength )
- return meshPtr; // nothing to update
+ if(!anIsModified)
+ return false;
- 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 ( 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
- {
// update client mesh structure by logged changes commands
try
{
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;
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 )
{
{
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;
}
#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 )
#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);
+
+ 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();
-private:
- // Fields PRIVATE
- //
- long pid_client;
+protected:
+ SMESH::SMESH_Mesh_var myMeshServer;
+ SMESHDS_Mesh* mySMESHDSMesh;
+ SMDS_Mesh* mySMDSMesh;
};
//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;
}
//=======================================================================
{
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);
//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);
}
//=======================================================================
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);
using namespace std;
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
+ myIsEmbeddedMode(theIsEmbeddedMode)
+{}
+
//=======================================================================
//function : Destructor
//purpose :
Clear();
}
+//=======================================================================
+void SMESHDS_Script::SetModified(bool theModified)
+{
+ myIsModified = theModified;
+}
+
+//=======================================================================
+bool SMESHDS_Script::IsModified()
+{
+ return myIsModified;
+}
+
//=======================================================================
//function : getCommand
//purpose :
//=======================================================================
void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, 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);
}
int idnode1, int idnode2,
int idnode3, int idnode4)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
idnode1, idnode2,
idnode3, idnode4);
int idnode1, int idnode2,
int idnode3, int idnode4)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
idnode1, idnode2,
idnode3, idnode4);
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);
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);
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);
//=======================================================================
void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
}
std::vector<int> nodes_ids,
std::vector<int> quantities)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
(NewID, nodes_ids, quantities);
}
//=======================================================================
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);
}
//=======================================================================
void SMESHDS_Script::RemoveNode(int ID)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
}
//=======================================================================
void SMESHDS_Script::RemoveElement(int ElementID)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
}
void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
}
std::vector<int> nodes_ids,
std::vector<int> quantities)
{
+ if(myIsEmbeddedMode){
+ myIsModified = true;
+ return;
+ }
getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
(ElementID, nodes_ids, quantities);
}
//=======================================================================
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 );
}
//=======================================================================
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);
}
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);
}
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);
}
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);
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);
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,
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,
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);
SMESHDS_Command* getCommand(const SMESHDS_CommandType aType);
std::list<SMESHDS_Command*> myCommands;
+
+ bool myIsEmbeddedMode;
+ bool myIsModified;
};
#endif
#include "SMESHGUI.h"
+#include "SMESH_Client.hxx"
#include "SMESHGUI_NodesDlg.h"
#include "SMESHGUI_TransparencyDlg.h"
#include "SMESHGUI_ClippingDlg.h"
//=============================================================================
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;
_thisObj = this ;
_id = myPoa->activate_object( _thisObj );
+ myIsEmbeddedMode = false;
myShapeReader = NULL; // shape reader
mySMESHGen = this;
}
// 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() );
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
// 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
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;