mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-03-14 19:51:16 +05:00
Apply SMESH module performance improvement
This commit is contained in:
parent
702e8ce383
commit
1cb4a4d452
@ -440,6 +440,12 @@ module SMESH
|
||||
* Get mesh description
|
||||
*/
|
||||
string Dump();
|
||||
|
||||
/*!
|
||||
* Get mesh pointer
|
||||
*/
|
||||
long GetMeshPtr();
|
||||
|
||||
};
|
||||
|
||||
interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
|
||||
|
@ -33,7 +33,7 @@ VPATH=.:@srcdir@
|
||||
|
||||
SUBDIRS = \
|
||||
SMDS SMESHDS Controls Driver DriverMED DriverDAT DriverUNV DriverSTL \
|
||||
SMESH SMESH_I OBJECT SMESHFiltersSelection SMESHGUI SMESH_SWIG \
|
||||
SMESH SMESH_I SMESHClient OBJECT SMESHFiltersSelection SMESHGUI SMESH_SWIG \
|
||||
MEFISTO2 StdMeshers StdMeshers_I StdMeshersGUI
|
||||
|
||||
@MODULE@
|
||||
|
@ -43,7 +43,11 @@ LIB_SRC = SMESH_Object.cxx SMESH_DeviceActor.cxx SMESH_Actor.cxx \
|
||||
LIB_CLIENT_IDL = SALOME_Exception.idl \
|
||||
SALOME_GenericObj.idl \
|
||||
SMESH_Mesh.idl \
|
||||
SMESH_Group.idl
|
||||
SMESH_Group.idl \
|
||||
SALOMEDS.idl \
|
||||
SMESH_Gen.idl \
|
||||
GEOM_Gen.idl \
|
||||
SMESH_Hypothesis.idl
|
||||
|
||||
|
||||
# Executables targets
|
||||
@ -53,6 +57,7 @@ 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 \
|
||||
-lSalomeApp -lSalomeObject -lSMESHControls
|
||||
-lSMESHClient -lSalomeApp -lSalomeObject -lSMESHControls -lSalomeLifeCycleCORBA -lSalomeDS -lCASCatch -lSalomeSession
|
||||
LDFLAGSFORBIN += $(LDFLAGS)
|
||||
|
||||
@CONCLUDE@
|
||||
|
@ -746,13 +746,13 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
|
||||
my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
|
||||
my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
|
||||
|
||||
//SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
|
||||
SetIsShrunkable(true);
|
||||
|
||||
SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
|
||||
if( !mgr )
|
||||
return false;
|
||||
|
||||
//SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
|
||||
SetIsShrunkable(true);
|
||||
|
||||
SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 0.75 ) );
|
||||
|
||||
int aMode = mgr->integerValue( "SMESH", "display_mode" );
|
||||
@ -835,6 +835,8 @@ bool SMESH_ActorDef::IsInfinitive(){
|
||||
|
||||
|
||||
void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
|
||||
if ( myIsShrinkable == theShrunkable )
|
||||
return;
|
||||
myIsShrinkable = theShrunkable;
|
||||
Modified();
|
||||
}
|
||||
@ -1135,6 +1137,8 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
|
||||
|
||||
|
||||
void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
|
||||
if ( myIsPointsVisible == theIsPointsVisible )
|
||||
return;
|
||||
myIsPointsVisible = theIsPointsVisible;
|
||||
SetRepresentation(GetRepresentation());
|
||||
}
|
||||
@ -1175,12 +1179,16 @@ void SMESH_ActorDef::UpdateHighlight(){
|
||||
|
||||
|
||||
void SMESH_ActorDef::highlight(bool theHighlight){
|
||||
if ( myIsHighlighted == theHighlight )
|
||||
return;
|
||||
myIsHighlighted = theHighlight;
|
||||
UpdateHighlight();
|
||||
}
|
||||
|
||||
|
||||
void SMESH_ActorDef::SetPreSelected(bool thePreselect){
|
||||
if ( myIsPreselected == thePreselect )
|
||||
return;
|
||||
myIsPreselected = thePreselect;
|
||||
UpdateHighlight();
|
||||
}
|
||||
|
@ -646,6 +646,8 @@ void SMESH_DeviceActor::SetShrinkFactor(float theValue){
|
||||
|
||||
|
||||
void SMESH_DeviceActor::SetHighlited(bool theIsHighlited){
|
||||
if ( myIsHighlited == theIsHighlited )
|
||||
return;
|
||||
myIsHighlited = theIsHighlited;
|
||||
Modified();
|
||||
}
|
||||
|
@ -31,10 +31,15 @@
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMESH_Actor.h"
|
||||
#include "SMESH_ControlsDef.hxx"
|
||||
#include <VTKViewer_ExtractUnstructuredGrid.h>
|
||||
#include "SMESH_Client.hxx"
|
||||
#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>
|
||||
@ -69,271 +74,6 @@ static int MYDEBUGWITHFILES = 0;
|
||||
#endif
|
||||
|
||||
|
||||
namespace{
|
||||
|
||||
inline const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, int theId){
|
||||
if(const SMDS_MeshNode* anElem = theMesh->FindNode(theId)) return anElem;
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
|
||||
}
|
||||
|
||||
|
||||
inline const SMDS_MeshElement* FindElement(const SMDS_Mesh* theMesh, int theId){
|
||||
if(const SMDS_MeshElement* anElem = theMesh->FindElement(theId)) return anElem;
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot find a SMDS_MeshElement for ID = "<<theId);
|
||||
}
|
||||
|
||||
|
||||
inline void AddNodesWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::double_array& aCoords = theSeq[theId].coords;
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(3*aNbElems != aCoords.length())
|
||||
EXCEPTION(runtime_error,"AddNodesWithID - 3*aNbElems != aCoords.length()");
|
||||
for(CORBA::Long aCoordId = 0; anElemId < aNbElems; anElemId++, aCoordId+=3){
|
||||
SMDS_MeshElement* anElem = theMesh->AddNodeWithID(aCoords[aCoordId],
|
||||
aCoords[aCoordId+1],
|
||||
aCoords[aCoordId+2],
|
||||
anIndexes[anElemId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddNodeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddEdgesWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(3*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 3*aNbElems != aCoords.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=3){
|
||||
SMDS_MeshElement* anElem = theMesh->AddEdgeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddEdgeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddTriasWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(4*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=4){
|
||||
SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddQuadsWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(5*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
|
||||
SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddPolygonsWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
|
||||
|
||||
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
|
||||
int aFaceId = anIndexes[anIndexId++];
|
||||
|
||||
int aNbNodes = anIndexes[anIndexId++];
|
||||
std::vector<int> nodes_ids (aNbNodes);
|
||||
for (int i = 0; i < aNbNodes; i++) {
|
||||
nodes_ids[i] = anIndexes[anIndexId++];
|
||||
}
|
||||
|
||||
SMDS_MeshElement* anElem = theMesh->AddPolygonalFaceWithID(nodes_ids, aFaceId);
|
||||
if (!anElem)
|
||||
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolygonalFaceWithID for ID = "
|
||||
<< anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddTetrasWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(5*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 5*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
|
||||
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddPiramidsWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(6*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 6*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=6){
|
||||
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId+5],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddPrismsWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(7*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 7*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=7){
|
||||
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId+5],
|
||||
anIndexes[anIndexId+6],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddHexasWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(9*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 9*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=9){
|
||||
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId+5],
|
||||
anIndexes[anIndexId+6],
|
||||
anIndexes[anIndexId+7],
|
||||
anIndexes[anIndexId+8],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddPolyhedronsWithID (SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
|
||||
|
||||
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
|
||||
int aFaceId = anIndexes[anIndexId++];
|
||||
|
||||
int aNbNodes = anIndexes[anIndexId++];
|
||||
std::vector<int> nodes_ids (aNbNodes);
|
||||
for (int i = 0; i < aNbNodes; i++) {
|
||||
nodes_ids[i] = anIndexes[anIndexId++];
|
||||
}
|
||||
|
||||
int aNbFaces = anIndexes[anIndexId++];
|
||||
std::vector<int> quantities (aNbFaces);
|
||||
for (int i = 0; i < aNbFaces; i++) {
|
||||
quantities[i] = anIndexes[anIndexId++];
|
||||
}
|
||||
|
||||
SMDS_MeshElement* anElem =
|
||||
theMesh->AddPolyhedralVolumeWithID(nodes_ids, quantities, aFaceId);
|
||||
if (!anElem)
|
||||
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolyhedralVolumeWithID for ID = "
|
||||
<< anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void ChangePolyhedronNodes (SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long iind = 0, aNbElems = theSeq[theId].number;
|
||||
|
||||
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++)
|
||||
{
|
||||
// find element
|
||||
const SMDS_MeshElement* elem = FindElement(theMesh, anIndexes[iind++]);
|
||||
// nb nodes
|
||||
int nbNodes = anIndexes[iind++];
|
||||
// nodes
|
||||
std::vector<const SMDS_MeshNode*> aNodes (nbNodes);
|
||||
for (int iNode = 0; iNode < nbNodes; iNode++) {
|
||||
aNodes[iNode] = FindNode(theMesh, anIndexes[iind++]);
|
||||
}
|
||||
// nb faces
|
||||
int nbFaces = anIndexes[iind++];
|
||||
// quantities
|
||||
std::vector<int> quantities (nbFaces);
|
||||
for (int iFace = 0; iFace < nbFaces; iFace++) {
|
||||
quantities[iFace] = anIndexes[iind++];
|
||||
}
|
||||
// change
|
||||
theMesh->ChangePolyhedronNodes(elem, aNodes, quantities);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
Class : SMESH_VisualObjDef
|
||||
Description : Base class for all mesh objects to be visuilised
|
||||
@ -756,6 +496,7 @@ SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh)
|
||||
myMeshServer = SMESH::SMESH_Mesh::_duplicate( theMesh );
|
||||
myMeshServer->Register();
|
||||
myMesh = new SMDS_Mesh();
|
||||
myIsMeshFromServer = 0;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -765,7 +506,8 @@ SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh)
|
||||
SMESH_MeshObj::~SMESH_MeshObj()
|
||||
{
|
||||
myMeshServer->Destroy();
|
||||
delete myMesh;
|
||||
if ( !myIsMeshFromServer )
|
||||
delete myMesh;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -775,110 +517,23 @@ SMESH_MeshObj::~SMESH_MeshObj()
|
||||
void SMESH_MeshObj::Update( int theIsClear )
|
||||
{
|
||||
// Update SMDS_Mesh on client part
|
||||
|
||||
try
|
||||
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 )
|
||||
{
|
||||
SMESH::log_array_var aSeq = myMeshServer->GetLog( theIsClear );
|
||||
CORBA::Long aLength = aSeq->length();
|
||||
|
||||
if( MYDEBUG ) MESSAGE( "Update: length of the script is "<<aLength );
|
||||
|
||||
if( !aLength )
|
||||
return;
|
||||
|
||||
for ( CORBA::Long anId = 0; anId < aLength; anId++)
|
||||
{
|
||||
const SMESH::double_array& aCoords = aSeq[anId].coords;
|
||||
const SMESH::long_array& anIndexes = aSeq[anId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number;
|
||||
CORBA::Long aCommand = aSeq[anId].commandType;
|
||||
|
||||
switch(aCommand)
|
||||
{
|
||||
case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_POLYGON : AddPolygonsWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_PYRAMID : AddPiramidsWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( myMesh, aSeq, anId ); break;
|
||||
|
||||
case SMESH::REMOVE_NODE:
|
||||
for( ; anElemId < aNbElems; anElemId++ )
|
||||
myMesh->RemoveNode( FindNode( myMesh, anIndexes[anElemId] ) );
|
||||
break;
|
||||
|
||||
case SMESH::REMOVE_ELEMENT:
|
||||
for( ; anElemId < aNbElems; anElemId++ )
|
||||
myMesh->RemoveElement( FindElement( myMesh, 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( myMesh, anIndexes[anElemId] ));
|
||||
node->setXYZ( aCoords[aCoordId], aCoords[aCoordId+1], aCoords[aCoordId+2] );
|
||||
}
|
||||
break;
|
||||
|
||||
case SMESH::CHANGE_ELEMENT_NODES:
|
||||
for ( CORBA::Long i = 0; anElemId < aNbElems; anElemId++ )
|
||||
{
|
||||
// find element
|
||||
const SMDS_MeshElement* elem = FindElement( myMesh, 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( myMesh, anIndexes[i++] );
|
||||
// change
|
||||
myMesh->ChangeElementNodes( elem, aNodes, nbNodes );
|
||||
}
|
||||
break;
|
||||
|
||||
case SMESH::CHANGE_POLYHEDRON_NODES:
|
||||
ChangePolyhedronNodes(myMesh, aSeq, anId);
|
||||
break;
|
||||
case SMESH::RENUMBER:
|
||||
for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3)
|
||||
{
|
||||
myMesh->Renumber( anIndexes[i], anIndexes[i+1], anIndexes[i+2] );
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
}
|
||||
delete myMesh;
|
||||
myMesh = meshPtr;
|
||||
myIsMeshFromServer = 1;
|
||||
}
|
||||
catch ( SALOME::SALOME_Exception& exc )
|
||||
{
|
||||
INFOS("Following exception was cought:\n\t"<<exc.details.text);
|
||||
}
|
||||
catch( const std::exception& exc)
|
||||
{
|
||||
INFOS("Following exception was cought:\n\t"<<exc.what());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
INFOS("Unknown exception was cought !!!");
|
||||
}
|
||||
|
||||
if ( MYDEBUG )
|
||||
{
|
||||
MESSAGE("Update - myMesh->NbNodes() = "<<myMesh->NbNodes());
|
||||
MESSAGE("Update - myMesh->NbEdges() = "<<myMesh->NbEdges());
|
||||
MESSAGE("Update - myMesh->NbFaces() = "<<myMesh->NbFaces());
|
||||
MESSAGE("Update - myMesh->NbVolumes() = "<<myMesh->NbVolumes());
|
||||
}
|
||||
|
||||
// Fill unstructured grid
|
||||
buildPrs();
|
||||
if ( isUpdated )
|
||||
{
|
||||
buildPrs();
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -1256,15 +911,3 @@ bool SMESH_subMeshObj::IsNodePrs() const
|
||||
{
|
||||
return mySubMeshServer->GetNumberOfElements() == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
SMDS_Mesh* GetMesh() const { return myMesh; }
|
||||
|
||||
protected:
|
||||
|
||||
int myIsMeshFromServer;
|
||||
SMESH::SMESH_Mesh_var myMeshServer;
|
||||
SMDS_Mesh* myMesh;
|
||||
};
|
||||
|
73
src/SMESHClient/Makefile.in
Normal file
73
src/SMESHClient/Makefile.in
Normal file
@ -0,0 +1,73 @@
|
||||
# GEOM GEOMClient : tool to transfer BREP files from GEOM server to GEOM client
|
||||
#
|
||||
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||
#
|
||||
#
|
||||
#
|
||||
# File : Makefile.in
|
||||
# Author : Pavel TELKOV (OCC)
|
||||
# Module : SHESM
|
||||
|
||||
top_srcdir=@top_srcdir@
|
||||
top_builddir=../..
|
||||
srcdir=@srcdir@
|
||||
VPATH=.:@srcdir@:@top_srcdir@/idl
|
||||
|
||||
|
||||
@COMMENCE@
|
||||
|
||||
# header files
|
||||
EXPORT_HEADERS = \
|
||||
SMESH_Client.hxx
|
||||
|
||||
# Libraries targets
|
||||
|
||||
LIB = libSMESHClient.la
|
||||
LIB_SRC = SMESH_Client.cxx
|
||||
|
||||
LIB_CLIENT_IDL = SALOME_Comm.idl \
|
||||
SALOME_Component.idl \
|
||||
SALOMEDS.idl \
|
||||
SALOMEDS_Attributes.idl \
|
||||
SALOME_Exception.idl \
|
||||
SALOME_GenericObj.idl \
|
||||
SMESH_Mesh.idl \
|
||||
SMESH_Gen.idl \
|
||||
SMESH_Group.idl \
|
||||
SMESH_Hypothesis.idl \
|
||||
SMESH_Pattern.idl \
|
||||
SMESH_Filter.idl \
|
||||
GEOM_Gen.idl \
|
||||
MED.idl
|
||||
|
||||
# Executables targets
|
||||
BIN = SMESHClientBin
|
||||
BIN_SRC =
|
||||
BIN_CLIENT_IDL =
|
||||
BIN_SERVER_IDL =
|
||||
|
||||
# additionnal information to compil and link file
|
||||
CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
|
||||
CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
|
||||
LDFLAGS += $(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lSMDS -lSMESHimpl -lSMESHDS -lSMESHControls
|
||||
|
||||
LDFLAGSFORBIN += $(LDFLAGS)
|
||||
@CONCLUDE@
|
||||
|
30
src/SMESHClient/SMESHClientBin.cxx
Normal file
30
src/SMESHClient/SMESHClientBin.cxx
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||
//
|
||||
// File :
|
||||
// Author :
|
||||
// Module :
|
||||
// $Header:
|
||||
|
||||
#include "SMESH_Client.hxx"
|
||||
|
||||
int main( int, char** )
|
||||
{
|
||||
return 0;
|
||||
}
|
480
src/SMESHClient/SMESH_Client.cxx
Normal file
480
src/SMESHClient/SMESH_Client.cxx
Normal file
@ -0,0 +1,480 @@
|
||||
// SMESH SMESHClient : tool to update client mesh structure by mesh from server
|
||||
//
|
||||
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : SMESH_Client.cxx
|
||||
// Author : Pavel TELKOV
|
||||
// Module : SMESH
|
||||
|
||||
#include "SMESH_Client.hxx"
|
||||
|
||||
#include <SALOMEconfig.h>
|
||||
#include "OpUtil.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
#include <SMESH_Mesh.hxx>
|
||||
|
||||
#include CORBA_SERVER_HEADER(SALOME_Exception)
|
||||
|
||||
#ifdef WNT
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#ifndef EXCEPTION
|
||||
#define EXCEPTION(TYPE, MSG) {\
|
||||
std::ostringstream aStream;\
|
||||
aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
|
||||
throw TYPE(aStream.str());\
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG_
|
||||
static int MYDEBUG = 0;
|
||||
#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)
|
||||
{
|
||||
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;
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
|
||||
}
|
||||
|
||||
|
||||
inline const SMDS_MeshElement* FindElement(const SMDS_Mesh* theMesh, int theId){
|
||||
if(const SMDS_MeshElement* anElem = theMesh->FindElement(theId)) return anElem;
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot find a SMDS_MeshElement for ID = "<<theId);
|
||||
}
|
||||
|
||||
|
||||
inline void AddNodesWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::double_array& aCoords = theSeq[theId].coords;
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(3*aNbElems != aCoords.length())
|
||||
EXCEPTION(runtime_error,"AddNodesWithID - 3*aNbElems != aCoords.length()");
|
||||
for(CORBA::Long aCoordId = 0; anElemId < aNbElems; anElemId++, aCoordId+=3){
|
||||
SMDS_MeshElement* anElem = theMesh->AddNodeWithID(aCoords[aCoordId],
|
||||
aCoords[aCoordId+1],
|
||||
aCoords[aCoordId+2],
|
||||
anIndexes[anElemId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddNodeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddEdgesWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(3*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 3*aNbElems != aCoords.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=3){
|
||||
SMDS_MeshElement* anElem = theMesh->AddEdgeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddEdgeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddTriasWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(4*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=4){
|
||||
SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddQuadsWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(5*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
|
||||
SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddPolygonsWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
|
||||
|
||||
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
|
||||
int aFaceId = anIndexes[anIndexId++];
|
||||
|
||||
int aNbNodes = anIndexes[anIndexId++];
|
||||
std::vector<int> nodes_ids (aNbNodes);
|
||||
for (int i = 0; i < aNbNodes; i++) {
|
||||
nodes_ids[i] = anIndexes[anIndexId++];
|
||||
}
|
||||
|
||||
SMDS_MeshElement* anElem = theMesh->AddPolygonalFaceWithID(nodes_ids, aFaceId);
|
||||
if (!anElem)
|
||||
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolygonalFaceWithID for ID = "
|
||||
<< anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddTetrasWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(5*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 5*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
|
||||
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddPiramidsWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(6*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 6*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=6){
|
||||
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId+5],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddPrismsWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(7*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 7*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=7){
|
||||
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId+5],
|
||||
anIndexes[anIndexId+6],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddHexasWithID(SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
|
||||
if(9*aNbElems != anIndexes.length())
|
||||
EXCEPTION(runtime_error,"AddEdgeWithID - 9*aNbElems != anIndexes.length()");
|
||||
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=9){
|
||||
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
|
||||
anIndexes[anIndexId+2],
|
||||
anIndexes[anIndexId+3],
|
||||
anIndexes[anIndexId+4],
|
||||
anIndexes[anIndexId+5],
|
||||
anIndexes[anIndexId+6],
|
||||
anIndexes[anIndexId+7],
|
||||
anIndexes[anIndexId+8],
|
||||
anIndexes[anIndexId]);
|
||||
if(!anElem)
|
||||
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AddPolyhedronsWithID (SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
|
||||
|
||||
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
|
||||
int aFaceId = anIndexes[anIndexId++];
|
||||
|
||||
int aNbNodes = anIndexes[anIndexId++];
|
||||
std::vector<int> nodes_ids (aNbNodes);
|
||||
for (int i = 0; i < aNbNodes; i++) {
|
||||
nodes_ids[i] = anIndexes[anIndexId++];
|
||||
}
|
||||
|
||||
int aNbFaces = anIndexes[anIndexId++];
|
||||
std::vector<int> quantities (aNbFaces);
|
||||
for (int i = 0; i < aNbFaces; i++) {
|
||||
quantities[i] = anIndexes[anIndexId++];
|
||||
}
|
||||
|
||||
SMDS_MeshElement* anElem =
|
||||
theMesh->AddPolyhedralVolumeWithID(nodes_ids, quantities, aFaceId);
|
||||
if (!anElem)
|
||||
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolyhedralVolumeWithID for ID = "
|
||||
<< anElemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void ChangePolyhedronNodes (SMDS_Mesh* theMesh,
|
||||
SMESH::log_array_var& theSeq,
|
||||
CORBA::Long theId)
|
||||
{
|
||||
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
|
||||
CORBA::Long iind = 0, aNbElems = theSeq[theId].number;
|
||||
|
||||
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++)
|
||||
{
|
||||
// find element
|
||||
const SMDS_MeshElement* elem = FindElement(theMesh, anIndexes[iind++]);
|
||||
// nb nodes
|
||||
int nbNodes = anIndexes[iind++];
|
||||
// nodes
|
||||
std::vector<const SMDS_MeshNode*> aNodes (nbNodes);
|
||||
for (int iNode = 0; iNode < nbNodes; iNode++) {
|
||||
aNodes[iNode] = FindNode(theMesh, anIndexes[iind++]);
|
||||
}
|
||||
// nb faces
|
||||
int nbFaces = anIndexes[iind++];
|
||||
// quantities
|
||||
std::vector<int> quantities (nbFaces);
|
||||
for (int iFace = 0; iFace < nbFaces; iFace++) {
|
||||
quantities[iFace] = anIndexes[iind++];
|
||||
}
|
||||
// change
|
||||
theMesh->ChangePolyhedronNodes(elem, aNodes, quantities);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// 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 )
|
||||
{
|
||||
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
|
||||
|
||||
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
|
||||
{
|
||||
for ( CORBA::Long anId = 0; anId < aLength; anId++)
|
||||
{
|
||||
const SMESH::double_array& aCoords = aSeq[anId].coords;
|
||||
const SMESH::long_array& anIndexes = aSeq[anId].indexes;
|
||||
CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number;
|
||||
CORBA::Long aCommand = aSeq[anId].commandType;
|
||||
|
||||
switch(aCommand)
|
||||
{
|
||||
case SMESH::ADD_NODE : AddNodesWithID ( 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::REMOVE_NODE:
|
||||
for( ; anElemId < aNbElems; anElemId++ )
|
||||
meshPtr->RemoveNode( FindNode( meshPtr, anIndexes[anElemId] ) );
|
||||
break;
|
||||
|
||||
case SMESH::REMOVE_ELEMENT:
|
||||
for( ; anElemId < aNbElems; anElemId++ )
|
||||
meshPtr->RemoveElement( FindElement( meshPtr, 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] ));
|
||||
node->setXYZ( aCoords[aCoordId], aCoords[aCoordId+1], aCoords[aCoordId+2] );
|
||||
}
|
||||
break;
|
||||
|
||||
case SMESH::CHANGE_ELEMENT_NODES:
|
||||
for ( CORBA::Long i = 0; anElemId < aNbElems; anElemId++ )
|
||||
{
|
||||
// find element
|
||||
const SMDS_MeshElement* elem = FindElement( meshPtr, 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++] );
|
||||
// change
|
||||
meshPtr->ChangeElementNodes( elem, aNodes, nbNodes );
|
||||
}
|
||||
break;
|
||||
|
||||
case SMESH::CHANGE_POLYHEDRON_NODES:
|
||||
ChangePolyhedronNodes(meshPtr, 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] );
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
}
|
||||
theIsUpdated = 1;
|
||||
}
|
||||
catch ( SALOME::SALOME_Exception& exc )
|
||||
{
|
||||
INFOS("Following exception was cought:\n\t"<<exc.details.text);
|
||||
}
|
||||
catch( const std::exception& exc)
|
||||
{
|
||||
INFOS("Following exception was cought:\n\t"<<exc.what());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
INFOS("Unknown exception was cought !!!");
|
||||
}
|
||||
} // 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;
|
||||
}
|
84
src/SMESHClient/SMESH_Client.hxx
Normal file
84
src/SMESHClient/SMESH_Client.hxx
Normal file
@ -0,0 +1,84 @@
|
||||
// SMESH SMESHClient : tool to update client mesh structure by mesh from server
|
||||
//
|
||||
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : SMESH_Client.hxx
|
||||
// Author : Pavel TELKOV
|
||||
// Module : SMESH
|
||||
|
||||
#ifndef _SMESH_Client_HeaderFile
|
||||
#define _SMESH_Client_HeaderFile
|
||||
|
||||
#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 )
|
||||
#else
|
||||
#define SMESHCLIENT_WNT_EXPORT
|
||||
#endif
|
||||
|
||||
class SMDS_Mesh;
|
||||
|
||||
//=====================================================================
|
||||
// SMESH_Client : class definition
|
||||
//=====================================================================
|
||||
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 );
|
||||
|
||||
private:
|
||||
// Fields PRIVATE
|
||||
//
|
||||
long pid_client;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -193,7 +193,7 @@ LDFLAGS += -lSMESHObject -lSMESHFiltersSelection -lSMDS -lSMESHControls -lDlgRef
|
||||
$(OCC_KERNEL_LIBS) -lTKBO -lTKAdvTools -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome \
|
||||
-lVTKViewer -lSalomeDSClient -lSalomeDS -lSalomeApp -lSalomePrs -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject \
|
||||
-lEvent -lSALOMELocalTrace -lSVTK -lOCCViewer -L${GEOM_ROOT_DIR}/lib/salome -lGEOM -lGEOMClient \
|
||||
-lGEOMBase -lGEOMObject -lGEOMFiltersSelection
|
||||
-lGEOMBase -lGEOMObject -lGEOMFiltersSelection -lSalomeSession
|
||||
|
||||
LDFLAGSFORBIN += $(LDFLAGS)
|
||||
|
||||
|
@ -1570,3 +1570,14 @@ SMESH::ElementType SMESH_Mesh_i::GetElementType( const CORBA::Long id, const boo
|
||||
{
|
||||
return ( SMESH::ElementType )_impl->GetElementType( id, iselem );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
CORBA::Long SMESH_Mesh_i::GetMeshPtr()
|
||||
{
|
||||
return (CORBA::Long)_impl;
|
||||
}
|
||||
|
@ -254,6 +254,8 @@ public:
|
||||
|
||||
virtual SMESH::long_array* GetIDs();
|
||||
|
||||
CORBA::Long GetMeshPtr();
|
||||
|
||||
map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
|
||||
map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user