Merge branch 'master' into gni/adaptation

This commit is contained in:
Gérald NICOLAS 2021-02-09 12:24:02 +01:00
commit ed49807f17
41 changed files with 1087 additions and 159 deletions

View File

@ -41,7 +41,7 @@ SALOME_INSTALL_SCRIPTS("${EXAMPLES_TESTS}" ${SALOME_INSTALL_DOC}/examples/SMESH)
# Application tests # Application tests
SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test) SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test)
INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY}) INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} ${SESSION_FREE_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY})
INSTALL(FILES CTestTestfileInstall.cmake INSTALL(FILES CTestTestfileInstall.cmake
DESTINATION ${TEST_INSTALL_DIRECTORY} DESTINATION ${TEST_INSTALL_DIRECTORY}

View File

@ -29,3 +29,10 @@ FOREACH(tfile ${GOOD_TESTS} ${BAD_TESTS})
ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}) ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile})
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
ENDFOREACH() ENDFOREACH()
foreach(tfile ${SESSION_FREE_TESTS})
get_filename_component(BASE_NAME ${tfile} NAME_WE)
set(TEST_NAME SMESH_${BASE_NAME})
add_test(${TEST_NAME} python ${tfile})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
endforeach()

View File

@ -0,0 +1,53 @@
"""
Most basic test of GEOM/SMESH usecase, but it can be tested without any session launched.
"""
import sys
import salome
import os
salome.standalone() # <- key point of test is here
salome.salome_init()
import salome_notebook
notebook = salome_notebook.NoteBook()
###
### GEOM component
###
import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS
geompy = geomBuilder.New()
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )
geompy.addToStudy( Box_1, 'Box_1' )
###
### SMESH component
###
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New()
smesh.SetEnablePublish( True ) # Set to False to avoid publish in study if not needed or in some particular situations:
# multiples meshes built in parallel, complex and numerous mesh edition (performance)
Mesh_1 = smesh.Mesh(Box_1)
NETGEN_1D_2D_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
isDone = Mesh_1.Compute()
## Set names of Mesh objects
smesh.SetName(NETGEN_1D_2D_3D.GetAlgorithm(), 'NETGEN 1D-2D-3D')
smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
assert(Mesh_1.GetMesh().NbTetras()>=5)

View File

@ -0,0 +1,74 @@
"""
Most basic test of SHAPE/SMESH usecase, but it can be tested without any session launched.
"""
import sys
import salome
salome.standalone() # <- key point of test is here
salome.salome_init()
#from salome.shaper import initConfig
import os
print(os.getpid())
#input("AAA")
###
### SHAPER component
###
from salome.shaper import model
model.begin()
partSet = model.moduleDocument()
### Create Part
Part_1 = model.addPart(partSet)
Part_1_doc = Part_1.document()
### Create Box
Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
model.end()
###
### SHAPERSTUDY component
###
#import pdb; pdb.set_trace()
model.publishToShaperStudy()
import SHAPERSTUDY
#import pdb; pdb.set_trace()
Box_1_1, = SHAPERSTUDY.shape(model.featureStringId(Box_1))
###
### SMESH component
###
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New()
#smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations:
# multiples meshes built in parallel, complex and numerous mesh edition (performance)
Mesh_1 = smesh.Mesh(Box_1_1)
NETGEN_1D_2D_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
NETGEN_3D_Parameters_1 = NETGEN_1D_2D_3D.Parameters()
NETGEN_3D_Parameters_1.SetMaxSize( 5 )
NETGEN_3D_Parameters_1.SetMinSize( 1 )
NETGEN_3D_Parameters_1.SetSecondOrder( 0 )
NETGEN_3D_Parameters_1.SetOptimize( 1 )
NETGEN_3D_Parameters_1.SetFineness( 2 )
NETGEN_3D_Parameters_1.SetChordalError( -1 )
NETGEN_3D_Parameters_1.SetChordalErrorEnabled( 0 )
NETGEN_3D_Parameters_1.SetUseSurfaceCurvature( 1 )
NETGEN_3D_Parameters_1.SetFuseEdges( 1 )
NETGEN_3D_Parameters_1.SetQuadAllowed( 0 )
NETGEN_3D_Parameters_1.SetCheckChartBoundary( 152 )
isDone = Mesh_1.Compute()
## Set names of Mesh objects
smesh.SetName(NETGEN_1D_2D_3D.GetAlgorithm(), 'NETGEN 1D-2D-3D')
smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
smesh.SetName(NETGEN_3D_Parameters_1, 'NETGEN 3D Parameters_1')
assert(Mesh_1.GetMesh().NbTetras()>=5)

View File

@ -19,6 +19,7 @@ geompy = geomBuilder.New()
## Creates a polygon given its centre, external radius and number of sides ## Creates a polygon given its centre, external radius and number of sides
def makePolygon(p_centre, radius, nb_sides, theName=""): def makePolygon(p_centre, radius, nb_sides, theName=""):
global geompy, math
points = [] points = []
x, y, z = geompy.PointCoordinates(p_centre) x, y, z = geompy.PointCoordinates(p_centre)
for i in range(nb_sides): for i in range(nb_sides):
@ -33,6 +34,7 @@ def makePolygon(p_centre, radius, nb_sides, theName=""):
## Creates a solid by adding a vertex on its top ## Creates a solid by adding a vertex on its top
def makeSummitSolid(face, height, theName=""): def makeSummitSolid(face, height, theName=""):
global geompy
p_cdg = geompy.MakeCDG(face) p_cdg = geompy.MakeCDG(face)
p_top = geompy.MakeTranslation(p_cdg, 0, 0, height) p_top = geompy.MakeTranslation(p_cdg, 0, 0, height)
edges = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) edges = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])

View File

@ -185,4 +185,9 @@ SET(GOOD_TESTS
test_polyhedron_per_solid.py test_polyhedron_per_solid.py
) )
SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS} testme.py) set(SESSION_FREE_TESTS
basic_geom_smesh_without_session.py
basic_shaper_smesh_without_session.py
)
SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS} ${SESSION_FREE_TESTS} testme.py)

View File

@ -40,6 +40,7 @@ SET(SUBDIRS_COMMON
StdMeshers_I StdMeshers_I
SMESH_PY SMESH_PY
Tools Tools
SalomeSessionless
) )
IF(SALOME_SMESH_ENABLE_MEFISTO) IF(SALOME_SMESH_ENABLE_MEFISTO)

View File

@ -29,11 +29,11 @@
#include "SMDS_SpacePosition.hxx" #include "SMDS_SpacePosition.hxx"
#include "SMDS_VertexPosition.hxx" #include "SMDS_VertexPosition.hxx"
SMDS_SpacePosition* SMDS_SpacePosition::_originPosition = new SMDS_SpacePosition(); SMDS_SpacePosition* SMDS_SpacePosition::__originPosition = nullptr;
SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition() SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition()
{ {
return SMDS_PositionPtr( _originPosition, /*isOwner=*/false ); return SMDS_PositionPtr( _originPosition(), /*isOwner=*/false );
} }
SMDS_PositionPtr SMDS_VertexPosition::StaticPosition() SMDS_PositionPtr SMDS_VertexPosition::StaticPosition()
@ -42,3 +42,9 @@ SMDS_PositionPtr SMDS_VertexPosition::StaticPosition()
return SMDS_PositionPtr( _vertexPosition, /*isOwner=*/false ); return SMDS_PositionPtr( _vertexPosition, /*isOwner=*/false );
} }
SMDS_SpacePosition *SMDS_SpacePosition::_originPosition()
{
if(!__originPosition)
__originPosition = new SMDS_SpacePosition;
return __originPosition;
}

View File

@ -40,7 +40,8 @@ class SMDS_EXPORT SMDS_SpacePosition : public SMDS_Position
virtual const double* GetParameters() const { return 0; } virtual const double* GetParameters() const { return 0; }
private: private:
static SMDS_SpacePosition* _originPosition; static SMDS_SpacePosition *_originPosition();
static SMDS_SpacePosition* __originPosition;
}; };
#endif #endif

View File

@ -73,6 +73,8 @@ SET(_link_LIBRARIES
${KERNEL_SalomeIDLKERNEL} ${KERNEL_SalomeIDLKERNEL}
${KERNEL_SALOMELocalTrace} ${KERNEL_SALOMELocalTrace}
${KERNEL_SalomeKernelHelpers} ${KERNEL_SalomeKernelHelpers}
${KERNEL_SalomeDS}
${KERNEL_SalomeCatalog}
${OpenCASCADE_ApplicationFramework_LIBRARIES} ${OpenCASCADE_ApplicationFramework_LIBRARIES}
${OpenCASCADE_ModelingAlgorithms_LIBRARIES} ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
${GEOM_GEOMClient} ${GEOM_GEOMClient}
@ -92,6 +94,8 @@ SET(_link_LIBRARIES
# header files / no moc processing # header files / no moc processing
SET(SMESHEngine_HEADERS SET(SMESHEngine_HEADERS
SMESH_Gen_i.hxx SMESH_Gen_i.hxx
SMESH_Gen_No_Session_i.hxx
SMESH_Gen_Session_i.hxx
SMESH_Algo_i.hxx SMESH_Algo_i.hxx
SMESH_0D_Algo_i.hxx SMESH_0D_Algo_i.hxx
SMESH_1D_Algo_i.hxx SMESH_1D_Algo_i.hxx
@ -120,6 +124,8 @@ SET(SMESHEngine_HEADERS
SET(SMESHEngine_SOURCES SET(SMESHEngine_SOURCES
SMESH_Gen_i.cxx SMESH_Gen_i.cxx
SMESH_Gen_i_1.cxx SMESH_Gen_i_1.cxx
SMESH_Gen_No_Session_i.cxx
SMESH_Gen_Session_i.cxx
SMESH_PythonDump.cxx SMESH_PythonDump.cxx
SMESH_Mesh_i.cxx SMESH_Mesh_i.cxx
SMESH_subMesh_i.cxx SMESH_subMesh_i.cxx

View File

@ -584,7 +584,7 @@ _pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod
// find a GEOM (aPass == 0) and SHAPERSTUDY (aPass == 1) entries // find a GEOM (aPass == 0) and SHAPERSTUDY (aPass == 1) entries
for(int aPass = 0; aPass < 2; aPass++) { for(int aPass = 0; aPass < 2; aPass++) {
_pyID geomID; _pyID geomID;
SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::getStudyServant()-> SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->
FindComponent(aPass == 0 ? "GEOM" : "SHAPERSTUDY"); FindComponent(aPass == 0 ? "GEOM" : "SHAPERSTUDY");
if (geomComp->_is_nil()) continue; if (geomComp->_is_nil()) continue;
CORBA::String_var entry = geomComp->GetID(); CORBA::String_var entry = geomComp->GetID();
@ -1717,7 +1717,7 @@ bool _pyGen::IsNotPublished(const _pyID& theObjID) const
// either the SMESH object is not in study or it is a GEOM object // either the SMESH object is not in study or it is a GEOM object
if ( IsGeomObject( theObjID )) if ( IsGeomObject( theObjID ))
{ {
SALOMEDS::SObject_wrap so = SMESH_Gen_i::getStudyServant()->FindObjectID( theObjID.ToCString() ); SALOMEDS::SObject_wrap so = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( theObjID.ToCString() );
if ( so->_is_nil() ) return true; if ( so->_is_nil() ) return true;
CORBA::Object_var obj = so->GetObject(); CORBA::Object_var obj = so->GetObject();
return CORBA::is_nil( obj ); return CORBA::is_nil( obj );

View File

@ -136,9 +136,9 @@ static TopoDS_Shape getShapeByName( const char* theName )
if ( theName != 0 ) if ( theName != 0 )
{ {
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::Study::ListOfSObject_var aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "GEOM" ); SALOMEDS::Study::ListOfSObject_var aList = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectByName( theName, "GEOM" );
if ( aList->length() == 0 ) if ( aList->length() == 0 )
aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "SHAPERSTUDY" ); aList = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectByName( theName, "SHAPERSTUDY" );
if ( aList->length() > 0 ) if ( aList->length() > 0 )
{ {
CORBA::Object_var anObj = aList[ 0 ]->GetObject(); CORBA::Object_var anObj = aList[ 0 ]->GetObject();
@ -155,7 +155,7 @@ static TopoDS_Shape getShapeByID (const char* theID)
{ {
if ( theID && strlen( theID ) > 0 ) { if ( theID && strlen( theID ) > 0 ) {
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID(theID); SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID(theID);
if ( !aSObj->_is_nil() ) { if ( !aSObj->_is_nil() ) {
CORBA::Object_var obj = aSObj->GetObject(); CORBA::Object_var obj = aSObj->GetObject();
GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj); GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
@ -828,7 +828,7 @@ void BelongToMeshGroup_i::SetGroupID( const char* theID ) // IOR or StoreName
} }
else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI
{ {
SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( myID.c_str() ); SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( myID.c_str() );
if ( !aSObj->_is_nil() ) { if ( !aSObj->_is_nil() ) {
CORBA::Object_var obj = aSObj->GetObject(); CORBA::Object_var obj = aSObj->GetObject();
SetGroup( SMESH::SMESH_GroupBase::_narrow( obj )); SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
@ -1713,7 +1713,7 @@ void ConnectedElements_i::SetThreshold ( const char*
} }
case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry ///////////////// case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry /////////////////
{ {
SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( threshold ); SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( threshold );
if ( sobj->_is_nil() ) if ( sobj->_is_nil() )
THROW_SALOME_CORBA_EXCEPTION THROW_SALOME_CORBA_EXCEPTION
( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM ); ( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM );

View File

@ -0,0 +1,50 @@
// Copyright (C) 2021 CEA/DEN, EDF R&D
//
// 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, or (at your option) any later version.
//
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "SMESH_Gen_No_Session_i.hxx"
#include "SALOMEDS_Study_i.hxx"
#include "SALOME_KernelServices.hxx"
#include "SALOME_ModuleCatalog_impl.hxx"
SMESH_Gen_No_Session_i::SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
const char* instanceName,
const char* interfaceName):SMESH_Gen_i(orb,poa,contId,instanceName,interfaceName,false)
{
}
GEOM::GEOM_Gen_var SMESH_Gen_No_Session_i::GetGeomEngine( bool isShaper )
{
CORBA::Object_var temp = KERNEL::RetrieveCompo(isShaper ? "SHAPERSTUDY" : "GEOM");
myGeomGen = GEOM::GEOM_Gen::_narrow( temp );
return myGeomGen;
}
SALOMEDS::Study_var SMESH_Gen_No_Session_i::getStudyServantVirtual() const
{
return SALOMEDS::Study::_duplicate(KERNEL::getStudyServantSA());
}
SALOME_ModuleCatalog::ModuleCatalog_var SMESH_Gen_No_Session_i::getModuleCatalog() const
{
SALOME_ModuleCatalog::ModuleCatalog_var aCat = KERNEL::getModuleComponentServantSA();
return aCat;
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2021 CEA/DEN, EDF R&D
//
// 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, or (at your option) any later version.
//
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#pragma once
#include "SMESH_Gen_i.hxx"
class SMESH_I_EXPORT SMESH_Gen_No_Session_i : public SMESH_Gen_i
{
public:
SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
const char* instanceName,
const char* interfaceName);
GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override;
SALOMEDS::Study_var getStudyServantVirtual() const override;
SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const override;
};

View File

@ -0,0 +1,63 @@
// Copyright (C) 2021 CEA/DEN, EDF R&D
//
// 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, or (at your option) any later version.
//
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "SMESH_Gen_Session_i.hxx"
#include "SALOME_KernelServices.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
SMESH_Gen_Session_i::SMESH_Gen_Session_i( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
const char* instanceName,
const char* interfaceName):SMESH_Gen_i(orb,poa,contId,instanceName,interfaceName,true)
{
}
GEOM::GEOM_Gen_var SMESH_Gen_Session_i::GetGeomEngine( bool isShaper )
{
Engines::EngineComponent_ptr temp = GetLCC()->FindOrLoad_Component( isShaper ? "FactoryServer" : "FactoryServer", isShaper ? "SHAPERSTUDY" : "GEOM" );
myGeomGen = GEOM::GEOM_Gen::_narrow( temp );
return myGeomGen;
}
SALOMEDS::Study_var SMESH_Gen_Session_i::getStudyServantVirtual() const
{
return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
}
SALOME_ModuleCatalog::ModuleCatalog_var SMESH_Gen_Session_i::getModuleCatalog() const
{
SALOME_ModuleCatalog::ModuleCatalog_var aCat = SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") );
return aCat;
}
extern "C"
{ SMESH_I_EXPORT
PortableServer::ObjectId* SMESHEngine_factory( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
const char* instanceName,
const char* interfaceName )
{
SMESH_Gen_Session_i* aSMESHGen = new SMESH_Gen_Session_i(orb, poa, contId, instanceName, interfaceName);
return aSMESHGen->getId() ;
}
}

View File

@ -0,0 +1,36 @@
// Copyright (C) 2021 CEA/DEN, EDF R&D
//
// 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, or (at your option) any later version.
//
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#pragma once
#include "SMESH_Gen_i.hxx"
class SMESH_I_EXPORT SMESH_Gen_Session_i : public SMESH_Gen_i
{
public:
SMESH_Gen_Session_i( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
const char* instanceName,
const char* interfaceName);
GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override;
// Get the SALOMEDS::Study from naming service
SALOMEDS::Study_var getStudyServantVirtual() const override;
SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const override;
};

View File

@ -49,7 +49,6 @@
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
#include <process.h> #include <process.h>
@ -280,24 +279,6 @@ SALOME_LifeCycleCORBA* SMESH_Gen_i::GetLCC()
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Gen_var SMESH_Gen_i::GetGeomEngine( bool isShaper )
{
Engines::EngineComponent_ptr temp =
GetLCC()->FindOrLoad_Component( isShaper ? "FactoryServer" : "FactoryServer",
isShaper ? "SHAPERSTUDY" : "GEOM" );
myGeomGen = GEOM::GEOM_Gen::_narrow( temp );
return myGeomGen;
}
//=============================================================================
/*!
* GetGeomEngine [ static ]
*
* Get GEOM::GEOM_Gen reference
*/
//=============================================================================
GEOM::GEOM_Gen_var SMESH_Gen_i::GetGeomEngine( GEOM::GEOM_Object_ptr go ) GEOM::GEOM_Gen_var SMESH_Gen_i::GetGeomEngine( GEOM::GEOM_Object_ptr go )
{ {
GEOM::GEOM_Gen_ptr gen = GEOM::GEOM_Gen::_nil(); GEOM::GEOM_Gen_ptr gen = GEOM::GEOM_Gen::_nil();
@ -330,8 +311,9 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa, PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId, PortableServer::ObjectId* contId,
const char* instanceName, const char* instanceName,
const char* interfaceName ) const char* interfaceName,
: Engines_Component_i( orb, poa, contId, instanceName, interfaceName ) bool checkNS)
: Engines_Component_i( orb, poa, contId, instanceName, interfaceName, false, checkNS )
{ {
myOrb = CORBA::ORB::_duplicate(orb); myOrb = CORBA::ORB::_duplicate(orb);
@ -356,21 +338,24 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb,
// find out mode (embedded or standalone) here else // find out mode (embedded or standalone) here else
// meshes created before calling SMESH_Client::GetSMESHGen(), which calls // meshes created before calling SMESH_Client::GetSMESHGen(), which calls
// SMESH_Gen_i::SetEmbeddedMode(), have wrong IsEmbeddedMode flag // SMESH_Gen_i::SetEmbeddedMode(), have wrong IsEmbeddedMode flag
if ( SALOME_NamingService* ns = GetNS() ) if(checkNS)
{ {
CORBA::Object_var obj = ns->Resolve( "/Kernel/Session" ); if ( SALOME_NamingService* ns = GetNS() )
SALOME::Session_var session = SALOME::Session::_narrow( obj ) ;
if ( !session->_is_nil() )
{ {
CORBA::String_var str_host = session->getHostname(); CORBA::Object_var obj = ns->Resolve( "/Kernel/Session" );
CORBA::Long s_pid = session->getPID(); SALOME::Session_var session = SALOME::Session::_narrow( obj ) ;
string my_host = Kernel_Utils::GetHostname(); if ( !session->_is_nil() )
{
CORBA::String_var str_host = session->getHostname();
CORBA::Long s_pid = session->getPID();
string my_host = Kernel_Utils::GetHostname();
#ifdef WIN32 #ifdef WIN32
long my_pid = (long)_getpid(); long my_pid = (long)_getpid();
#else #else
long my_pid = (long) getpid(); long my_pid = (long) getpid();
#endif #endif
SetEmbeddedMode( s_pid == my_pid && my_host == str_host.in() ); SetEmbeddedMode( s_pid == my_pid && my_host == str_host.in() );
}
} }
} }
} }
@ -827,7 +812,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam
SALOMEDS::SObject_wrap aSO = PublishHypothesis( hyp ); SALOMEDS::SObject_wrap aSO = PublishHypothesis( hyp );
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TPythonDump() << aSO << " = " << this << ".CreateHypothesis('" TPythonDump(this) << aSO << " = " << this << ".CreateHypothesis('"
<< theHypName << "', '" << theLibName << "')"; << theHypName << "', '" << theLibName << "')";
} }
} }
@ -862,7 +847,7 @@ SMESH_Gen_i::CreateHypothesisByAverageLength( const char* theHypType,
initParams ); initParams );
SALOMEDS::SObject_wrap so = PublishHypothesis( hyp ); SALOMEDS::SObject_wrap so = PublishHypothesis( hyp );
TPythonDump() << hyp << " = " << this << ".CreateHypothesisByAverageLength( '" TPythonDump(this) << hyp << " = " << this << ".CreateHypothesisByAverageLength( '"
<< theHypType << "', '" << theHypType << "', '"
<< theLibName << "', " << theLibName << "', "
<< theAverageLength << ", " << theAverageLength << ", "
@ -1217,7 +1202,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TPythonDump() << aSO << " = " << this << ".CreateMesh(" << theShapeObject << ")"; TPythonDump(this) << aSO << " = " << this << ".CreateMesh(" << theShapeObject << ")";
} }
} }
@ -1247,7 +1232,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateEmptyMesh()
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TPythonDump() << aSO << " = " << this << ".CreateEmptyMesh()"; TPythonDump(this) << aSO << " = " << this << ".CreateEmptyMesh()";
} }
} }
@ -1301,7 +1286,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TPythonDump() << aSO << " = " << this << ".CreateMeshesFromUNV(r'" << theFileName << "')"; TPythonDump(this) << aSO << " = " << this << ".CreateMeshesFromUNV(r'" << theFileName << "')";
} }
} }
@ -1348,7 +1333,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileNa
{ // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups() { // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
// Python Dump // Python Dump
TPythonDump aPythonDump; TPythonDump aPythonDump(this);
aPythonDump << "(["; aPythonDump << "([";
if (theStatus == SMESH::DRS_OK) { if (theStatus == SMESH::DRS_OK) {
@ -1498,7 +1483,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TPythonDump() << aSO << " = " << this << ".CreateMeshesFromSTL(r'" << theFileName << "')"; TPythonDump(this) << aSO << " = " << this << ".CreateMeshesFromSTL(r'" << theFileName << "')";
} }
} }
@ -1536,7 +1521,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char*
{ // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups() { // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
// Python Dump // Python Dump
TPythonDump aPythonDump; TPythonDump aPythonDump(this);
aPythonDump << "(["; aPythonDump << "([";
if (theStatus == SMESH::DRS_OK) if (theStatus == SMESH::DRS_OK)
@ -1624,7 +1609,7 @@ SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName,
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TPythonDump() << "("<< aSO << ", error) = " << this << ".CreateMeshesFromGMF(r'" TPythonDump(this) << "("<< aSO << ", error) = " << this << ".CreateMeshesFromGMF(r'"
<< theFileName << "', " << theFileName << "', "
<< theMakeRequiredGroups << " )"; << theMakeRequiredGroups << " )";
} }
@ -1894,7 +1879,7 @@ SMESH_Gen_i::MakeGroupsOfBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
if ( SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh )) if ( SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh ))
{ {
groups = meshServant->MakeGroupsOfBadInputElements( theSubShapeID, theGroupName ); groups = meshServant->MakeGroupsOfBadInputElements( theSubShapeID, theGroupName );
TPythonDump() << groups << " = " << this TPythonDump(this) << groups << " = " << this
<< ".MakeGroupsOfBadInputElements( " << ".MakeGroupsOfBadInputElements( "
<< theMesh << ", " << theSubShapeID << ", '" << theGroupName << "' )"; << theMesh << ", " << theSubShapeID << ", '" << theGroupName << "' )";
} }
@ -2064,7 +2049,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
SALOME::BAD_PARAM ); SALOME::BAD_PARAM );
// Update Python script // Update Python script
TPythonDump() << "isDone = " << this << ".Compute( " TPythonDump(this) << "isDone = " << this << ".Compute( "
<< theMesh << ", " << theShapeObject << ")"; << theMesh << ", " << theShapeObject << ")";
try { try {
@ -2350,7 +2335,7 @@ SMESH::long_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh,
nbels[i] = 0; nbels[i] = 0;
// Update Python script // Update Python script
TPythonDump() << "theNbElems = " << this << ".Evaluate( " TPythonDump(this) << "theNbElems = " << this << ".Evaluate( "
<< theMesh << ", " << theShapeObject << ")"; << theMesh << ", " << theShapeObject << ")";
try { try {
@ -2607,7 +2592,7 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::ListOfIDSources& theMeshesArray,
CORBA::Boolean theCommonGroups, CORBA::Boolean theCommonGroups,
SMESH::SMESH_Mesh_ptr theMeshToAppendTo) SMESH::SMESH_Mesh_ptr theMeshToAppendTo)
{ {
std::unique_ptr< TPythonDump > pPythonDump( new TPythonDump ); std::unique_ptr< TPythonDump > pPythonDump( new TPythonDump(this) );
TPythonDump& pythonDump = *pPythonDump; // prevent dump of called methods TPythonDump& pythonDump = *pPythonDump; // prevent dump of called methods
// create mesh if theMeshToAppendTo not provided // create mesh if theMeshToAppendTo not provided
@ -2888,7 +2873,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
{ {
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh() TPythonDump* pyDump = new TPythonDump(this); // prevent dump from CreateMesh()
std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump ); std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
// 1. Get source mesh // 1. Get source mesh
@ -3670,7 +3655,7 @@ CORBA::Boolean SMESH_Gen_i::CopyMeshWithGeom( SMESH::SMESH_Mesh_ptr theSou
bool ok = true; bool ok = true;
SMESH_TRY; SMESH_TRY;
TPythonDump pyDump; // prevent dump from CreateMesh() TPythonDump pyDump(this); // prevent dump from CreateMesh()
theNewMesh = CreateMesh( theNewGeometry ); theNewMesh = CreateMesh( theNewGeometry );
theNewGroups = new SMESH::ListOfGroups(); theNewGroups = new SMESH::ListOfGroups();
@ -4230,7 +4215,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ; SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ;
if ( !myMesh->_is_nil() ) { if ( !myMesh->_is_nil() ) {
myMesh->Load(); // load from study file if not yet done myMesh->Load(); // load from study file if not yet done
TPythonDump pd; // not to dump GetGroups() TPythonDump pd(this); // not to dump GetGroups()
SMESH::ListOfGroups_var groups = myMesh->GetGroups(); SMESH::ListOfGroups_var groups = myMesh->GetGroups();
for ( CORBA::ULong i = 0; i < groups->length(); ++i ) for ( CORBA::ULong i = 0; i < groups->length(); ++i )
{ {
@ -5226,7 +5211,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
return false; return false;
} }
TPythonDump pd; // prevent dump during loading TPythonDump pd(this); // prevent dump during loading
// For PAL13473 ("Repetitive mesh") implementation. // For PAL13473 ("Repetitive mesh") implementation.
// New dependencies between SMESH objects are established: // New dependencies between SMESH objects are established:
@ -6581,26 +6566,3 @@ std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
} }
return res; return res;
} }
//=============================================================================
/*!
* SMESHEngine_factory
*
* C factory, accessible with dlsym, after dlopen
*/
//=============================================================================
extern "C"
{ SMESH_I_EXPORT
PortableServer::ObjectId* SMESHEngine_factory( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
const char* instanceName,
const char* interfaceName )
{
if(MYDEBUG) MESSAGE( "PortableServer::ObjectId* SMESHEngine_factory()" );
if(MYDEBUG) SCRUTE(interfaceName);
SMESH_Gen_i* aSMESHGen = new SMESH_Gen_i(orb, poa, contId, instanceName, interfaceName);
return aSMESHGen->getId() ;
}
}

View File

@ -469,9 +469,6 @@ public:
void CleanPythonTrace(); void CleanPythonTrace();
static int CountInPyDump(const TCollection_AsciiString& text); static int CountInPyDump(const TCollection_AsciiString& text);
SMESH::MG_ADAPT_ptr CreateMG_ADAPT();
SMESH::MG_ADAPT_ptr CreateAdaptationHypothesis();
SMESH::MG_ADAPT_OBJECT_ptr Adaptation( const char* adaptationType);
// ***************************************** // *****************************************
// Internal methods // Internal methods

View File

@ -34,13 +34,12 @@
#include "SMESH_Mesh_i.hxx" #include "SMESH_Mesh_i.hxx"
#include "SMESH_subMesh_i.hxx" #include "SMESH_subMesh_i.hxx"
#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
#include <utilities.h> #include <utilities.h>
#include <Utils_ExceptHandlers.hxx> #include <Utils_ExceptHandlers.hxx>
#include <SALOMEDS_wrap.hxx> #include <SALOMEDS_wrap.hxx>
#include <SALOMEDS_Attributes_wrap.hxx> #include <SALOMEDS_Attributes_wrap.hxx>
#include <SALOME_KernelServices.hxx> #include "SALOME_KernelServices.hxx"
#include "SALOME_ModuleCatalog_impl.hxx"
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TopoDS_Solid.hxx> #include <TopoDS_Solid.hxx>
@ -209,15 +208,6 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(CORBA::Object_ptr theObject)
return aSO._retn(); return aSO._retn();
} }
//=======================================================================
//function : GetStudyPtr
//purpose : Get study from naming service
//=======================================================================
SALOMEDS::Study_var SMESH_Gen_i::getStudyServant()
{
return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
}
//======================================================================= //=======================================================================
//function : objectToServant //function : objectToServant
//purpose : //purpose :
@ -291,14 +281,14 @@ GEOM::GEOM_Object_ptr SMESH_Gen_i::GetGeomObjectByEntry( const std::string& entr
//purpose : //purpose :
//======================================================================= //=======================================================================
static SALOMEDS::SObject_ptr publish(CORBA::Object_ptr theIOR, SALOMEDS::SObject_ptr SMESH_Gen_i::publish(CORBA::Object_ptr theIOR,
SALOMEDS::SObject_ptr theFatherObject, SALOMEDS::SObject_ptr theFatherObject,
const int theTag = 0, const int theTag,
const char* thePixMap = 0, const char* thePixMap,
const bool theSelectable = true) const bool theSelectable)
{ {
SALOMEDS::Study_var theStudy = SMESH_Gen_i::getStudyServant(); SALOMEDS::Study_var theStudy = getStudyServant();
SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theIOR ); SALOMEDS::SObject_wrap SO = ObjectToSObject( theIOR );
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder(); SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder();
bool isNewSO = false, isInUseCaseTree = false; bool isNewSO = false, isInUseCaseTree = false;
@ -439,9 +429,7 @@ void SMESH_Gen_i::SetPixMap(SALOMEDS::SObject_ptr theSObject,
//purpose : //purpose :
//======================================================================= //=======================================================================
static void addReference (SALOMEDS::SObject_ptr theSObject, void SMESH_Gen_i::addReference (SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theToObject, int theTag)
CORBA::Object_ptr theToObject,
int theTag = 0)
{ {
SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant(); SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
SALOMEDS::SObject_wrap aToObjSO = SMESH_Gen_i::ObjectToSObject( theToObject ); SALOMEDS::SObject_wrap aToObjSO = SMESH_Gen_i::ObjectToSObject( theToObject );
@ -587,8 +575,7 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent()
// If component for this SMESH engine does not exist in the study, create it // If component for this SMESH engine does not exist in the study, create it
SALOME_ModuleCatalog::ModuleCatalog_var aCat = SALOME_ModuleCatalog::ModuleCatalog_var aCat = this->getModuleCatalog();
SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") );
if ( CORBA::is_nil( aCat ) ) if ( CORBA::is_nil( aCat ) )
return father._retn(); return father._retn();

View File

@ -130,7 +130,7 @@ bool SMESH_Hypothesis_i::IsPublished()
bool res = false; bool res = false;
if ( SMESH_Gen_i::GetSMESHGen() ) if ( SMESH_Gen_i::GetSMESHGen() )
{ {
SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( _this()); SALOMEDS::SObject_wrap SO = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject( _this());
res = !SO->_is_nil(); res = !SO->_is_nil();
} }
return res; return res;

View File

@ -4052,9 +4052,9 @@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theO
if ( *theMeshName && mesh_var->NbFaces() == 0 ) if ( *theMeshName && mesh_var->NbFaces() == 0 )
{ {
// new mesh empty, remove it // new mesh empty, remove it
SALOMEDS::Study_var study = SMESH_Gen_i::getStudyServant(); SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
SALOMEDS::StudyBuilder_var builder = study->NewBuilder(); SALOMEDS::StudyBuilder_var builder = study->NewBuilder();
SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject( mesh_var ); SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject( mesh_var );
builder->RemoveObjectWithChildren( meshSO ); builder->RemoveObjectWithChildren( meshSO );
THROW_SALOME_CORBA_EXCEPTION("Offset failed", SALOME::INTERNAL_ERROR); THROW_SALOME_CORBA_EXCEPTION("Offset failed", SALOME::INTERNAL_ERROR);
} }

View File

@ -1117,7 +1117,7 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )"; TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
// Remove group's SObject // Remove group's SObject
SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder(); SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewBuilder();
builder->RemoveObjectWithChildren( aGroupSO ); builder->RemoveObjectWithChildren( aGroupSO );
} }
aGroup->Modified(/*removed=*/true); // notify dependent Filter with FT_BelongToMeshGroup criterion aGroup->Modified(/*removed=*/true); // notify dependent Filter with FT_BelongToMeshGroup criterion
@ -3055,7 +3055,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase
SALOMEDS::StudyBuilder_var builder; SALOMEDS::StudyBuilder_var builder;
SALOMEDS::SObject_wrap aGroupSO; SALOMEDS::SObject_wrap aGroupSO;
SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant(); SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
if ( !aStudy->_is_nil() ) { if ( !aStudy->_is_nil() ) {
builder = aStudy->NewBuilder(); builder = aStudy->NewBuilder();
aGroupSO = _gen_i->ObjectToSObject( theGroup ); aGroupSO = _gen_i->ObjectToSObject( theGroup );
@ -3693,7 +3693,7 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char* file,
// Perform Export // Perform Export
PrepareForWriting(file, overwrite); PrepareForWriting(file, overwrite);
string aMeshName = "Mesh"; string aMeshName = "Mesh";
SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant(); SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
if ( !aStudy->_is_nil() ) { if ( !aStudy->_is_nil() ) {
SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( _this() ); SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( _this() );
if ( !aMeshSO->_is_nil() ) { if ( !aMeshSO->_is_nil() ) {
@ -5955,7 +5955,7 @@ SMESH::string_array* SMESH_Mesh_i::GetLastParameters()
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
if(gen) { if(gen) {
CORBA::String_var aParameters = GetParameters(); CORBA::String_var aParameters = GetParameters();
SALOMEDS::ListOfListOfStrings_var aSections = SMESH_Gen_i::getStudyServant()->ParseVariables(aParameters); SALOMEDS::ListOfListOfStrings_var aSections = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->ParseVariables(aParameters);
if ( aSections->length() > 0 ) { if ( aSections->length() > 0 ) {
SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ]; SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
aResult->length( aVars.length() ); aResult->length( aVars.length() );

View File

@ -707,7 +707,7 @@ void SMESH_NoteBook::ReplaceVariables()
// dumped calls due to the fix of // dumped calls due to the fix of
// issue 0021364:: Dump of netgen parameters has duplicate lines // issue 0021364:: Dump of netgen parameters has duplicate lines
SMESH_Gen_i * aGen = SMESH_Gen_i::GetSMESHGen(); SMESH_Gen_i * aGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( (*it).first.ToCString() ); SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( (*it).first.ToCString() );
CORBA::Object_var obj = aGen->SObjectToObject( sobj ); CORBA::Object_var obj = aGen->SObjectToObject( sobj );
if ( SMESH_Hypothesis_i* h = SMESH::DownCast< SMESH_Hypothesis_i*>( obj )) if ( SMESH_Hypothesis_i* h = SMESH::DownCast< SMESH_Hypothesis_i*>( obj ))
{ {
@ -744,7 +744,7 @@ void SMESH_NoteBook::InitObjectMap()
if(!aGen) if(!aGen)
return; return;
SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant(); SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
if(aStudy->_is_nil()) if(aStudy->_is_nil())
return; return;
@ -953,7 +953,7 @@ bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double&
{ {
bool ok = false; bool ok = false;
SALOMEDS::Study_ptr aStudy = SMESH_Gen_i::getStudyServant(); SALOMEDS::Study_ptr aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
if(aStudy->_is_nil()) if(aStudy->_is_nil())
return ok; return ok;

View File

@ -1233,7 +1233,7 @@ void SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD(SALOMEDS::SComponent_ptr sme
{ {
if ( theMeshCounter > 0 ) if ( theMeshCounter > 0 )
{ {
SALOMEDS::ChildIterator_wrap itBig = SMESH_Gen_i::getStudyServant()->NewChildIterator( smeshComp ); SALOMEDS::ChildIterator_wrap itBig = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewChildIterator( smeshComp );
for ( ; itBig->More(); itBig->Next() ) { for ( ; itBig->More(); itBig->Next() ) {
SALOMEDS::SObject_wrap gotBranch = itBig->Value(); SALOMEDS::SObject_wrap gotBranch = itBig->Value();
CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject( gotBranch ); CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject( gotBranch );

View File

@ -69,8 +69,12 @@ namespace SMESH
myVals[i] = SMESH_Comment(value[i]); myVals[i] = SMESH_Comment(value[i]);
} }
TPythonDump:: TPythonDump::TPythonDump():myVarsCounter(0),mySmesh(SMESH_Gen_i::GetSMESHGen())
TPythonDump():myVarsCounter(0) {
++myCounter;
}
TPythonDump::TPythonDump(SMESH_Gen_i *smesh):myVarsCounter(0),mySmesh(smesh)
{ {
++myCounter; ++myCounter;
} }
@ -304,7 +308,7 @@ namespace SMESH
operator<<(CORBA::Object_ptr theArg) operator<<(CORBA::Object_ptr theArg)
{ {
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg); SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
if(!aSObject->_is_nil()) { if(!aSObject->_is_nil()) {
CORBA::String_var id = aSObject->GetID(); CORBA::String_var id = aSObject->GetID();
myStream << id; myStream << id;
@ -323,7 +327,7 @@ namespace SMESH
TPythonDump:: TPythonDump::
operator<<(SMESH::SMESH_Hypothesis_ptr theArg) operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
{ {
SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg); SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
if(aSObject->_is_nil() && !CORBA::is_nil(theArg)) if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
myStream << "hyp_" << theArg->GetId(); myStream << "hyp_" << theArg->GetId();
else else
@ -337,7 +341,7 @@ namespace SMESH
{ {
if ( CORBA::is_nil( theArg ) ) if ( CORBA::is_nil( theArg ) )
return *this << "None"; return *this << "None";
SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg); SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
if(!aSObject->_is_nil()) if(!aSObject->_is_nil())
{ {
return *this << aSObject; return *this << aSObject;
@ -352,7 +356,7 @@ namespace SMESH
SMESH::long_array_var anElementsId = theArg->GetIDs(); SMESH::long_array_var anElementsId = theArg->GetIDs();
SMESH::array_of_ElementType_var types = theArg->GetTypes(); SMESH::array_of_ElementType_var types = theArg->GetTypes();
SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL; SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(mesh); SALOMEDS::SObject_wrap meshSO = mySmesh->ObjectToSObject(mesh);
if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
return *this << mesh << ".GetIDSource([], " << type << ")"; return *this << mesh << ".GetIDSource([], " << type << ")";
else else

View File

@ -121,7 +121,9 @@ namespace SMESH
std::ostringstream myStream; std::ostringstream myStream;
static size_t myCounter; static size_t myCounter;
int myVarsCounter; // counts stored TVar's int myVarsCounter; // counts stored TVar's
SMESH_Gen_i *mySmesh = nullptr;
public: public:
TPythonDump(SMESH_Gen_i *smesh);
TPythonDump(); TPythonDump();
virtual ~TPythonDump(); virtual ~TPythonDump();

View File

@ -17,7 +17,17 @@
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
# --- scripts --- include(${SWIG_USE_FILE})
include_directories(
${PROJECT_SOURCE_DIR}/src/SMESHDS
${PROJECT_SOURCE_DIR}/src/SMESHUtils
${PROJECT_SOURCE_DIR}/src/SMDS
${PROJECT_SOURCE_DIR}/src/SMESH
${PROJECT_SOURCE_DIR}/src/SMESH_I
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_BINARY_DIR}/idl
)
# scripts / static # scripts / static
SET(_bin_SCRIPTS SET(_bin_SCRIPTS
@ -99,6 +109,23 @@ SET(StdMeshers_SCRIPTS
__init__.py __init__.py
StdMeshersBuilder.py StdMeshersBuilder.py
) )
SET(SMeshHelper_HEADERS SMeshHelper.h SMeshHelper.i)
SET(SMeshHelper_SOURCES SMeshHelper.cxx ${SMeshHelper_HEADERS})
SET_SOURCE_FILES_PROPERTIES(SMeshHelper.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(SMeshHelper.i PROPERTIES SWIG_FLAGS "-py3")
SET_SOURCE_FILES_PROPERTIES(SMeshHelper_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/SMeshHelper.py )
IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")
SWIG_ADD_MODULE(SMeshHelper python ${SMeshHelper_SOURCES})
ELSE()
SWIG_ADD_LIBRARY(SMeshHelper LANGUAGE python SOURCES ${SMeshHelper_SOURCES})
ENDIF()
SWIG_LINK_LIBRARIES(SMeshHelper ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SMESHEngine )
install(TARGETS _SMeshHelper DESTINATION ${SALOME_INSTALL_LIBS})
install(FILES ${SMeshHelper_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}" ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_SMeshHelper_REAL_NAME}")
# --- rules --- # --- rules ---
SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_PYTHON} DEF_PERMS) SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_PYTHON} DEF_PERMS)
SALOME_INSTALL_SCRIPTS("${smesh_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/smesh DEF_PERMS) SALOME_INSTALL_SCRIPTS("${smesh_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/smesh DEF_PERMS)

View File

@ -0,0 +1,50 @@
// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// 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, or (at your option) any later version.
//
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "SMeshHelper.h"
#include "SMESH_Gen_No_Session_i.hxx"
#include "SALOME_Container_i.hxx"
#include "SALOME_KernelServices.hxx"
#include <cstring>
std::string BuildSMESHInstanceInternal()
{
CORBA::ORB_var orb;
{ int argc(0); orb = CORBA::ORB_init(argc,nullptr); }
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
PortableServer::POAManager_var pman = poa->the_POAManager();
PortableServer::ObjectId_var conId;
//
{
char *argv[4] = {"Container","FactoryServer","SMESH",nullptr};
Engines_Container_i *cont = new Engines_Container_i(orb,poa,"FactoryServer",2,argv,false,false);
conId = poa->activate_object(cont);
}
//
pman->activate();
//
SMESH_Gen_No_Session_i *servant = new SMESH_Gen_No_Session_i(orb,poa,const_cast<PortableServer::ObjectId*>(&conId.in()),"SMESH_inst_2","SMESH");
PortableServer::ObjectId *zeId = servant->getId();
CORBA::Object_var zeRef = poa->id_to_reference(*zeId);
CORBA::String_var ior = orb->object_to_string(zeRef);
return std::string(ior.in());
}

View File

@ -0,0 +1,24 @@
// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// 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, or (at your option) any later version.
//
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#pragma once
#include <string>
std::string BuildSMESHInstanceInternal();

View File

@ -0,0 +1,34 @@
// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// 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, or (at your option) any later version.
//
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
%module SMeshHelper
%include "std_string.i"
%{
#include "SMeshHelper.h"
%}
%inline
{
std::string BuildSMESHInstance()
{
return BuildSMESHInstanceInternal();
}
}

View File

@ -1962,9 +1962,10 @@ class Mesh(metaclass = MeshMeta):
print(msg) print(msg)
print(allReasons) print(allReasons)
pass pass
if salome.sg.hasDesktop(): if salome.sg:
if not isinstance( refresh, list): # not a call from subMesh.Compute() if salome.sg.hasDesktop():
if refresh: salome.sg.updateObjBrowser() if not isinstance( refresh, list): # not a call from subMesh.Compute()
if refresh: salome.sg.updateObjBrowser()
return ok return ok

View File

@ -0,0 +1,24 @@
# Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
#
# 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, or (at your option) any later version.
#
# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
SET(_bin_SCRIPTS
SMESH_SalomeSessionless.py
)
SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_PYTHON} DEF_PERMS)

View File

@ -0,0 +1,28 @@
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
#
# 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, or (at your option) any later version.
#
# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
def buildInstance(orb):
import SMeshHelper
smesh_ior = SMeshHelper.BuildSMESHInstance()
import SMESH
import CORBA
orb=CORBA.ORB_init([''])
smeshInst = orb.string_to_object(smesh_ior)
return smeshInst, orb

View File

@ -253,6 +253,7 @@ namespace // INTERNAL STUFF
_chord2 = Max( _line. SquareDistance( curve->Value( uf + 0.25 * ( ul - uf ))), _chord2 = Max( _line. SquareDistance( curve->Value( uf + 0.25 * ( ul - uf ))),
Max( _line.SquareDistance( curve->Value( uf + 0.5 * ( ul - uf ))), Max( _line.SquareDistance( curve->Value( uf + 0.5 * ( ul - uf ))),
_line.SquareDistance( curve->Value( uf + 0.75 * ( ul - uf ))))); _line.SquareDistance( curve->Value( uf + 0.75 * ( ul - uf )))));
_chord2 *= ( 1.05 * 1.05 ); // +5%
_chord2 = Max( tol, _chord2 ); _chord2 = Max( tol, _chord2 );
_chord = Sqrt( _chord2 ); _chord = Sqrt( _chord2 );
@ -944,8 +945,8 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
SMESHDS_Mesh* tgtMesh = theMesh.GetMeshDS(); SMESHDS_Mesh* tgtMesh = theMesh.GetMeshDS();
const TopoDS_Edge& geomEdge = TopoDS::Edge( theShape ); const TopoDS_Edge& geomEdge = TopoDS::Edge( theShape );
const double edgeTol = BRep_Tool::Tolerance( geomEdge ); const double edgeTol = helper.MaxTolerance( geomEdge );
const int shapeID = tgtMesh->ShapeToIndex( geomEdge ); const int shapeID = tgtMesh->ShapeToIndex( geomEdge );
double geomTol = Precision::Confusion(); double geomTol = Precision::Confusion();
@ -1083,7 +1084,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
} // loop on groups } // loop on groups
if ( n2n->empty()) if ( n2n->empty())
return error("Empty source groups"); return error("Source groups are empty or mismatching geometry");
// check if the whole geom edge is covered by imported segments; // check if the whole geom edge is covered by imported segments;
// the check consist in passing by segments from one vetrex node to another // the check consist in passing by segments from one vetrex node to another

View File

@ -1153,7 +1153,7 @@ bool StdMeshers_Prism_3D::getWallFaces( Prism_3D::TPrismTopo & thePrism,
if ( !quadList.back() ) if ( !quadList.back() )
return toSM( error(TCom("Side face #") << shapeID( face ) return toSM( error(TCom("Side face #") << shapeID( face )
<< " not meshable with quadrangles")); << " not meshable with quadrangles"));
bool isCompositeBase = ! setBottomEdge( *edge, quadList.back(), face ); bool isCompositeBase = ! setBottomEdge( *edge, quadList.back(), face ); // -> orient CCW
if ( isCompositeBase ) if ( isCompositeBase )
{ {
// it's OK if all EDGEs of the bottom side belongs to the bottom FACE // it's OK if all EDGEs of the bottom side belongs to the bottom FACE
@ -2429,10 +2429,11 @@ bool StdMeshers_Prism_3D::assocOrProjBottom2Top( const gp_Trsf & bottomToTopTrsf
{ {
for ( int iE = 0; iE < botSide->NbEdges(); ++iE ) for ( int iE = 0; iE < botSide->NbEdges(); ++iE )
{ {
// sides are CWW oriented
NSProjUtils::InsertAssociation( botSide->Edge( iE ), NSProjUtils::InsertAssociation( botSide->Edge( iE ),
topSide->Edge( iE ), shape2ShapeMap ); topSide->Edge( iE ), shape2ShapeMap );
NSProjUtils::InsertAssociation( myHelper->IthVertex( 0, botSide->Edge( iE )), NSProjUtils::InsertAssociation( botSide->FirstVertex( iE ),
myHelper->IthVertex( 0, topSide->Edge( iE )), topSide->LastVertex ( iE ),
shape2ShapeMap ); shape2ShapeMap );
} }
} }

View File

@ -55,8 +55,15 @@
#include <BRepMesh_Delaun.hxx> #include <BRepMesh_Delaun.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <Bnd_B2d.hxx> #include <Bnd_B2d.hxx>
#include <GeomAPI_ExtremaCurveCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx> #include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomLib_IsPlanarSurface.hxx> #include <GeomLib_IsPlanarSurface.hxx>
#include <Geom_Line.hxx>
#include <IntCurveSurface_HInter.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
@ -81,6 +88,12 @@ using namespace std;
namespace TAssocTool = StdMeshers_ProjectionUtils; namespace TAssocTool = StdMeshers_ProjectionUtils;
//typedef StdMeshers_ProjectionUtils TAssocTool; //typedef StdMeshers_ProjectionUtils TAssocTool;
// allow range iteration on NCollection_IndexedMap
template < class IMAP >
typename IMAP::const_iterator begin( const IMAP & m ) { return m.cbegin(); }
template < class IMAP >
typename IMAP::const_iterator end( const IMAP & m ) { return m.cend(); }
//======================================================================= //=======================================================================
//function : StdMeshers_Projection_2D //function : StdMeshers_Projection_2D
//purpose : //purpose :
@ -1224,6 +1237,418 @@ namespace {
tgtHelper.IthVertex( 1,*edgeS ), assocMap ); tgtHelper.IthVertex( 1,*edgeS ), assocMap );
} }
//================================================================================
/*!
* \brief Find sub-shape association such that corresponding VERTEXes of
* two corresponding FACEs lie on lines parallel to thePiercingLine
*/
//================================================================================
bool findSubShapeAssociationByPiercing( const TopoDS_Face& theTgtFace,
SMESH_Mesh * /*theTgtMesh*/,
const TopoDS_Shape& theSrcShape,
SMESH_Mesh* theSrcMesh,
TAssocTool::TShapeShapeMap& theShape2ShapeMap,
Handle(Geom_Line) & thePiercingLine )
{
list< TopoDS_Edge > tgtEdges, srcEdges;
list< int > tgtNbEW, srcNbEW;
int tgtNbW = SMESH_Block::GetOrderedEdges( TopoDS::Face( theTgtFace ), tgtEdges, tgtNbEW );
TopTools_IndexedMapOfShape tgtVV, srcVV;
for ( const TopoDS_Edge& tgtEdge : tgtEdges )
tgtVV.Add( SMESH_MesherHelper::IthVertex( 0, tgtEdge ));
// if ( tgtVV.Size() < 2 )
// return false;
const int nbVV = tgtVV.Size();
const gp_Pnt tgtP0 = BRep_Tool::Pnt( TopoDS::Vertex( tgtVV( 1 )));
double minVertexDist = Precision::Infinite(), assocTol;
gp_Lin piercingLine;
TopoDS_Face assocSrcFace;
double tol;
for ( TopExp_Explorer faceExp( theSrcShape, TopAbs_FACE ); faceExp.More(); faceExp.Next())
{
const TopoDS_Face& srcFace = TopoDS::Face( faceExp.Current() );
int srcNbW = SMESH_Block::GetOrderedEdges( srcFace, srcEdges, srcNbEW );
if ( tgtNbW != srcNbW )
continue;
srcVV.Clear( false );
for ( const TopoDS_Edge& srcEdge : srcEdges )
srcVV.Add( SMESH_MesherHelper::IthVertex( 0, srcEdge ));
if ( srcVV.Extent() != tgtVV.Extent() )
continue;
// make srcFace computed
SMESH_subMesh* srcFaceSM = theSrcMesh->GetSubMesh( srcFace );
if ( !TAssocTool::MakeComputed( srcFaceSM ))
continue;
// compute tolerance
double sumLen = 0, nbEdges = 0;
for ( const TopoDS_Edge& srcEdge : srcEdges )
{
SMESH_subMesh* srcSM = theSrcMesh->GetSubMesh( srcEdge );
if ( !srcSM->GetSubMeshDS() )
continue;
SMDS_ElemIteratorPtr edgeIt = srcSM->GetSubMeshDS()->GetElements();
while ( edgeIt->more() )
{
const SMDS_MeshElement* edge = edgeIt->next();
sumLen += SMESH_NodeXYZ( edge->GetNode( 0 )).Distance( edge->GetNode( 1 ));
nbEdges += 1;
}
}
if ( nbEdges == 0 )
continue;
tol = 0.1 * sumLen / nbEdges;
// try to find corresponding VERTEXes
gp_Lin line;
double vertexDist;
for ( int iSrcV0 = 1; iSrcV0 <= srcVV.Size(); ++iSrcV0 )
{
const gp_Pnt srcP0 = BRep_Tool::Pnt( TopoDS::Vertex( srcVV( iSrcV0 )));
try {
line.SetDirection( gp_Vec( srcP0, tgtP0 ));
}
catch (...) {
continue;
}
bool correspond;
for ( int iDir : { -1, 1 }) // move connected VERTEX forward and backward
{
correspond = true;
vertexDist = 0;
int iTgtV = 0, iSrcV = iSrcV0 - 1;
for ( int i = 1; i < tgtVV.Size() && correspond; ++i )
{
iTgtV = ( iTgtV + 1 ) % nbVV;
iSrcV = ( iSrcV + iDir + nbVV ) % nbVV;
gp_Pnt tgtP = BRep_Tool::Pnt( TopoDS::Vertex( tgtVV( iTgtV + 1 )));
gp_Pnt srcP = BRep_Tool::Pnt( TopoDS::Vertex( srcVV( iSrcV + 1 )));
line.SetLocation( tgtP );
correspond = ( line.SquareDistance( srcP ) < tol * tol );
vertexDist += tgtP.SquareDistance( srcP );
}
if ( correspond )
break;
}
if ( correspond )
{
if ( vertexDist < minVertexDist )
{
minVertexDist = vertexDist;
piercingLine = line;
assocSrcFace = srcFace;
assocTol = tol;
}
break;
}
}
continue;
} // loop on src FACEs
if ( Precision::IsInfinite( minVertexDist ))
return false; // no correspondence found
thePiercingLine = new Geom_Line( piercingLine );
// fill theShape2ShapeMap
TAssocTool::InsertAssociation( theTgtFace, assocSrcFace, theShape2ShapeMap );
for ( const TopoDS_Shape& tgtV : tgtVV ) // fill theShape2ShapeMap with VERTEXes
{
gp_Pnt tgtP = BRep_Tool::Pnt( TopoDS::Vertex( tgtV ));
piercingLine.SetLocation( tgtP );
bool found = false;
for ( const TopoDS_Shape& srcV : srcVV )
{
gp_Pnt srcP = BRep_Tool::Pnt( TopoDS::Vertex( srcV ));
if ( piercingLine.SquareDistance( srcP ) < assocTol * assocTol )
{
TAssocTool::InsertAssociation( tgtV, srcV, theShape2ShapeMap );
found = true;
break;
}
}
if ( !found )
return false;
}
TopoDS_Vertex vvT[2], vvS[2], vvMapped[2];
for ( const TopoDS_Edge& tgtEdge : tgtEdges ) // fill theShape2ShapeMap with EDGEs
{
if ( SMESH_Algo::isDegenerated( tgtEdge ))
continue;
TopExp::Vertices( tgtEdge, vvT[0], vvT[1], true );
if ( !theShape2ShapeMap.IsBound( vvT[0] ) ||
!theShape2ShapeMap.IsBound( vvT[1] ))
return false;
vvMapped[0] = TopoDS::Vertex( theShape2ShapeMap( vvT[0] ));
vvMapped[1] = TopoDS::Vertex( theShape2ShapeMap( vvT[1] ));
bool found = false;
for ( TopExp_Explorer eExp( assocSrcFace, TopAbs_EDGE ); eExp.More(); eExp.Next())
{
TopoDS_Edge srcEdge = TopoDS::Edge( eExp.Current() );
TopExp::Vertices( srcEdge, vvS[0], vvS[1], true );
found = (( vvMapped[0].IsSame( vvS[0] ) && vvMapped[1].IsSame( vvS[1] )) ||
( vvMapped[0].IsSame( vvS[1] ) && vvMapped[1].IsSame( vvS[0] )));
if ( found && nbVV < 3 )
{
BRepAdaptor_Curve tgtCurve( tgtEdge );
gp_Pnt tgtP = tgtCurve.Value( 0.5 * ( tgtCurve.FirstParameter() +
tgtCurve.LastParameter() ));
thePiercingLine->SetLocation( tgtP );
double f,l;
Handle(Geom_Curve) srcCurve = BRep_Tool::Curve( srcEdge, f,l );
if ( srcCurve.IsNull() )
{
found = false;
continue;
}
GeomAPI_ExtremaCurveCurve extrema( thePiercingLine, srcCurve );
if ( !extrema.Extrema().IsDone() ||
extrema.Extrema().IsParallel() ||
extrema.NbExtrema() == 0 ||
extrema.LowerDistance() > tol )
found = false;
}
if ( found )
{
if ( !vvMapped[0].IsSame( vvS[0] ))
srcEdge.Reverse();
TAssocTool::InsertAssociation( tgtEdge, srcEdge, theShape2ShapeMap );
break;
}
}
if ( !found )
return false;
}
return true;
} // findSubShapeAssociationByPiercing()
//================================================================================
/*!
* \brief Project by piercing theTgtFace by lines parallel to thePiercingLine
*/
//================================================================================
bool projectByPiercing(Handle(Geom_Line) thePiercingLine,
const TopoDS_Face& theTgtFace,
const TopoDS_Face& theSrcFace,
const TSideVector& theTgtWires,
const TSideVector& theSrcWires,
const TAssocTool::TShapeShapeMap& theShape2ShapeMap,
TAssocTool::TNodeNodeMap& theSrc2tgtNodes,
const bool theIs1DComputed)
{
SMESH_Mesh * tgtMesh = theTgtWires[0]->GetMesh();
SMESH_Mesh * srcMesh = theSrcWires[0]->GetMesh();
if ( thePiercingLine.IsNull() )
{
// try to set thePiercingLine by VERTEX association of theShape2ShapeMap
const double tol = 0.1 * theSrcWires[0]->Length() / theSrcWires[0]->NbSegments();
for ( TopExp_Explorer vExp( theTgtFace, TopAbs_VERTEX ); vExp.More(); vExp.Next() )
{
const TopoDS_Vertex & tgtV = TopoDS::Vertex( vExp.Current() );
const TopoDS_Vertex & srcV = TopoDS::Vertex( theShape2ShapeMap( tgtV ));
gp_Pnt tgtP = BRep_Tool::Pnt( tgtV );
gp_Pnt srcP = BRep_Tool::Pnt( srcV );
if ( thePiercingLine.IsNull() ) // set thePiercingLine
{
gp_Lin line;
try {
line.SetDirection( gp_Vec( srcP, tgtP ));
line.SetLocation( tgtP );
thePiercingLine = new Geom_Line( line );
}
catch ( ... )
{
continue;
}
}
else // check thePiercingLine
{
thePiercingLine->SetLocation( tgtP );
if ( thePiercingLine->Lin().SquareDistance( srcP ) > tol * tol )
return false;
}
}
for ( TopExp_Explorer eExp( theTgtFace, TopAbs_EDGE ); eExp.More(); eExp.Next() )
{
BRepAdaptor_Curve tgtCurve( TopoDS::Edge( eExp.Current() ));
gp_Pnt tgtP = tgtCurve.Value( 0.5 * ( tgtCurve.FirstParameter() +
tgtCurve.LastParameter() ));
thePiercingLine->SetLocation( tgtP );
double f,l;
TopoDS_Edge srcEdge = TopoDS::Edge( theShape2ShapeMap( eExp.Current() ));
Handle(Geom_Curve) srcCurve = BRep_Tool::Curve( srcEdge, f,l );
if ( srcCurve.IsNull() )
continue;
GeomAPI_ExtremaCurveCurve extrema( thePiercingLine, srcCurve,
-Precision::Infinite(), Precision::Infinite(), f, l );
if ( !extrema.Extrema().IsDone() ||
extrema.Extrema().IsParallel() ||
extrema.NbExtrema() == 0 ||
extrema.LowerDistance() > tol )
return false;
}
} // if ( thePiercingLine.IsNull() )
SMESHDS_SubMesh* srcSubDS = srcMesh->GetMeshDS()->MeshElements( theSrcFace );
SMESH_MesherHelper* helper = theTgtWires[0]->FaceHelper();
if ( theIs1DComputed )
helper->IsQuadraticSubMesh( theTgtFace );
else
helper->SetIsQuadratic( srcSubDS->GetElements()->next()->IsQuadratic() );
helper->SetElementsOnShape( true );
SMESHDS_Mesh* tgtMeshDS = tgtMesh->GetMeshDS();
Handle(Geom_Surface) tgtSurface = BRep_Tool::Surface( theTgtFace );
Handle(GeomAdaptor_HSurface) tgtSurfAdaptor = new GeomAdaptor_HSurface( tgtSurface );
Handle(GeomAdaptor_HCurve) piercingCurve = new GeomAdaptor_HCurve( thePiercingLine );
IntCurveSurface_HInter intersect;
SMESH_MesherHelper* srcHelper = theSrcWires[0]->FaceHelper();
const SMDS_MeshNode* nullNode = 0;
TAssocTool::TNodeNodeMap::iterator srcN_tgtN;
vector< const SMDS_MeshNode* > tgtNodes;
SMDS_ElemIteratorPtr elemIt = srcSubDS->GetElements();
while ( elemIt->more() ) // loop on all mesh faces on srcFace
{
const SMDS_MeshElement* elem = elemIt->next();
const int nbN = elem->NbCornerNodes();
tgtNodes.resize( nbN );
for ( int i = 0; i < nbN; ++i ) // loop on nodes of the source element
{
const SMDS_MeshNode* srcNode = elem->GetNode(i);
srcN_tgtN = theSrc2tgtNodes.insert( make_pair( srcNode, nullNode )).first;
if ( srcN_tgtN->second == nullNode )
{
// create a new node
thePiercingLine->SetLocation( SMESH_NodeXYZ( srcNode ));
intersect.Perform( piercingCurve, tgtSurfAdaptor );
bool pierced = ( intersect.IsDone() && intersect.NbPoints() > 0 );
double U, V;
const SMDS_MeshNode* n = nullNode;
if ( pierced )
{
double W, minW = Precision::Infinite();
gp_Pnt tgtP;
for ( int iInt = 1; iInt <= intersect.NbPoints(); ++iInt )
{
W = intersect.Point( iInt ).W();
if ( 0 < W && W < minW )
{
U = intersect.Point( iInt ).U();
V = intersect.Point( iInt ).V();
tgtP = intersect.Point( iInt ).Pnt();
minW = W;
}
}
n = tgtMeshDS->AddNode( tgtP.X(), tgtP.Y(), tgtP.Z() );
}
SMDS_TypeOfPosition shapeType = srcNode->GetPosition()->GetTypeOfPosition();
TopoDS_Shape srcShape;
if ( shapeType != SMDS_TOP_FACE )
{
srcShape = srcHelper->GetSubShapeByNode( srcNode, srcHelper->GetMeshDS() );
if ( !theShape2ShapeMap.IsBound( srcShape, /*isSrc=*/true ))
{
if ( n ) // INTERNAL shape w/o corresponding target shape (3D_mesh_Extrusion_02/E0)
shapeType = SMDS_TOP_FACE;
else
return false;
}
}
switch ( shapeType )
{
case SMDS_TOP_FACE: {
if ( !n )
return false;
tgtMeshDS->SetNodeOnFace( n, helper->GetSubShapeID(), U, V );
break;
}
case SMDS_TOP_EDGE: {
TopoDS_Edge tgtEdge = TopoDS::Edge( theShape2ShapeMap( srcShape, /*isSrc=*/true ));
if ( n )
{
U = Precision::Infinite();
helper->CheckNodeU( tgtEdge, n, U, Precision::PConfusion());
}
else
{
Handle(Geom_Curve) tgtCurve = BRep_Tool::Curve( tgtEdge, U,V );
if ( tgtCurve.IsNull() )
return false;
GeomAPI_ExtremaCurveCurve extrema( thePiercingLine, tgtCurve );
if ( !extrema.Extrema().IsDone() ||
extrema.Extrema().IsParallel() ||
extrema.NbExtrema() == 0 )
return false;
gp_Pnt pOnLine, pOnEdge;
extrema.NearestPoints( pOnLine, pOnEdge );
extrema.LowerDistanceParameters( V, U );
n = tgtMeshDS->AddNode( pOnEdge.X(), pOnEdge.Y(), pOnEdge.Z() );
}
tgtMeshDS->SetNodeOnEdge( n, tgtEdge, U );
break;
}
case SMDS_TOP_VERTEX: {
TopoDS_Shape tgtV = theShape2ShapeMap( srcShape, /*isSrc=*/true );
if ( !n )
{
gp_Pnt tgtP = BRep_Tool::Pnt( TopoDS::Vertex( tgtV ));
n = tgtMeshDS->AddNode( tgtP.X(), tgtP.Y(), tgtP.Z() );
}
tgtMeshDS->SetNodeOnVertex( n, TopoDS::Vertex( tgtV ));
break;
}
default:;
}
srcN_tgtN->second = n;
}
tgtNodes[i] = srcN_tgtN->second;
}
// create a new face (with reversed orientation)
switch ( nbN )
{
case 3: helper->AddFace(tgtNodes[0], tgtNodes[2], tgtNodes[1]); break;
case 4: helper->AddFace(tgtNodes[0], tgtNodes[3], tgtNodes[2], tgtNodes[1]); break;
}
} // loop on all mesh faces on srcFace
return true;
} // projectByPiercing()
} // namespace } // namespace
@ -1260,20 +1685,29 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap ); TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
if ( shape2ShapeMap.IsEmpty() ) if ( shape2ShapeMap.IsEmpty() )
initAssoc4Quad2Closed( tgtFace, helper, srcShape, srcMesh, shape2ShapeMap ); initAssoc4Quad2Closed( tgtFace, helper, srcShape, srcMesh, shape2ShapeMap );
Handle(Geom_Line) piercingLine;
bool piercingTried = false;
if ( !TAssocTool::FindSubShapeAssociation( tgtFace, tgtMesh, srcShape, srcMesh, if ( !TAssocTool::FindSubShapeAssociation( tgtFace, tgtMesh, srcShape, srcMesh,
shape2ShapeMap) || shape2ShapeMap) ||
!shape2ShapeMap.IsBound( tgtFace )) !shape2ShapeMap.IsBound( tgtFace ))
{ {
if ( srcShape.ShapeType() == TopAbs_FACE ) piercingTried = true;
if ( !findSubShapeAssociationByPiercing( tgtFace, tgtMesh, srcShape, srcMesh,
shape2ShapeMap, piercingLine ))
{ {
int nbE1 = helper.Count( tgtFace, TopAbs_EDGE, /*ignoreSame=*/true ); if ( srcShape.ShapeType() == TopAbs_FACE )
int nbE2 = helper.Count( srcShape, TopAbs_EDGE, /*ignoreSame=*/true ); {
if ( nbE1 != nbE2 ) int nbE1 = helper.Count( tgtFace, TopAbs_EDGE, /*ignoreSame=*/true );
return error(COMPERR_BAD_SHAPE, int nbE2 = helper.Count( srcShape, TopAbs_EDGE, /*ignoreSame=*/true );
SMESH_Comment("Different number of edges in source and target faces: ") if ( nbE1 != nbE2 )
<< nbE2 << " and " << nbE1 ); return error(COMPERR_BAD_SHAPE,
SMESH_Comment("Different number of edges in source and target faces: ")
<< nbE2 << " and " << nbE1 );
}
return error(COMPERR_BAD_SHAPE,"Topology of source and target faces seems different" );
} }
return error(COMPERR_BAD_SHAPE,"Topology of source and target faces seems different" );
} }
TopoDS_Face srcFace = TopoDS::Face( shape2ShapeMap( tgtFace ).Oriented(TopAbs_FORWARD)); TopoDS_Face srcFace = TopoDS::Face( shape2ShapeMap( tgtFace ).Oriented(TopAbs_FORWARD));
@ -1310,6 +1744,13 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
bool projDone = false; bool projDone = false;
if ( !projDone && !piercingLine.IsNull() )
{
// project by piercing tgtFace by lines parallel to piercingLine
projDone = projectByPiercing( piercingLine, tgtFace, srcFace, tgtWires, srcWires,
shape2ShapeMap, _src2tgtNodes, is1DComputed );
piercingTried = true;
}
if ( !projDone ) if ( !projDone )
{ {
// try to project from the same face with different location // try to project from the same face with different location
@ -1329,6 +1770,12 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
projDone = projectQuads( tgtFace, srcFace, tgtWires, srcWires, projDone = projectQuads( tgtFace, srcFace, tgtWires, srcWires,
shape2ShapeMap, _src2tgtNodes, is1DComputed); shape2ShapeMap, _src2tgtNodes, is1DComputed);
} }
if ( !projDone && !piercingTried )
{
// project by piercing tgtFace by lines parallel to piercingLine
projDone = projectByPiercing( piercingLine, tgtFace, srcFace, tgtWires, srcWires,
shape2ShapeMap, _src2tgtNodes, is1DComputed );
}
// it will remove mesh built on edges and vertices in failure case // it will remove mesh built on edges and vertices in failure case
MeshCleaner cleaner( tgtSubMesh ); MeshCleaner cleaner( tgtSubMesh );

View File

@ -596,7 +596,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::updateState()
GEOM::GEOM_Object_var StdMeshersGUI_SubShapeSelectorWdg::GetGeomObjectByEntry( const QString& theEntry ) GEOM::GEOM_Object_var StdMeshersGUI_SubShapeSelectorWdg::GetGeomObjectByEntry( const QString& theEntry )
{ {
GEOM::GEOM_Object_var aGeomObj; GEOM::GEOM_Object_var aGeomObj;
SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.toUtf8().data() ); SALOMEDS::SObject_var aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( theEntry.toUtf8().data() );
if (!aSObj->_is_nil() ) if (!aSObj->_is_nil() )
{ {
CORBA::Object_var obj = aSObj->GetObject(); CORBA::Object_var obj = aSObj->GetObject();

View File

@ -92,7 +92,7 @@ void StdMeshers_ImportSource1D_i::SetSourceEdges(const SMESH::ListOfGroups& grou
THROW_SALOME_CORBA_EXCEPTION("Wrong group type", SALOME::BAD_PARAM); THROW_SALOME_CORBA_EXCEPTION("Wrong group type", SALOME::BAD_PARAM);
smesh_groups.push_back( gp_i->GetSmeshGroup() ); smesh_groups.push_back( gp_i->GetSmeshGroup() );
SALOMEDS::SObject_wrap so = SMESH_Gen_i::ObjectToSObject(groups[i]); SALOMEDS::SObject_wrap so = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject(groups[i]);
if ( !so->_is_nil()) if ( !so->_is_nil())
{ {
CORBA::String_var entry = so->GetID(); CORBA::String_var entry = so->GetID();
@ -171,7 +171,7 @@ char* StdMeshers_ImportSource1D_i::SaveTo()
os << " " << _groupEntries[i]; os << " " << _groupEntries[i];
// id // id
SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( _groupEntries[i] ); SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( _groupEntries[i] );
CORBA::Object_var groupObj; CORBA::Object_var groupObj;
if ( !groupSO->_is_nil() ) if ( !groupSO->_is_nil() )
groupObj = groupSO->GetObject(); groupObj = groupSO->GetObject();

View File

@ -91,7 +91,7 @@ void StdMeshers_ImportSource2D_i::SetSourceFaces(const SMESH::ListOfGroups& grou
THROW_SALOME_CORBA_EXCEPTION("Wrong group type", SALOME::BAD_PARAM); THROW_SALOME_CORBA_EXCEPTION("Wrong group type", SALOME::BAD_PARAM);
smesh_groups.push_back( gp_i->GetSmeshGroup() ); smesh_groups.push_back( gp_i->GetSmeshGroup() );
SALOMEDS::SObject_var so = SMESH_Gen_i::ObjectToSObject(groups[i]); SALOMEDS::SObject_var so = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject(groups[i]);
if ( !so->_is_nil()) if ( !so->_is_nil())
{ {
CORBA::String_var entry = so->GetID(); CORBA::String_var entry = so->GetID();
@ -171,7 +171,7 @@ char* StdMeshers_ImportSource2D_i::SaveTo()
os << " " << _groupEntries[i]; os << " " << _groupEntries[i];
// id // id
SALOMEDS::SObject_var groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( _groupEntries[i] ); SALOMEDS::SObject_var groupSO = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( _groupEntries[i] );
CORBA::Object_var groupObj; CORBA::Object_var groupObj;
if ( !groupSO->_is_nil() ) { if ( !groupSO->_is_nil() ) {
groupObj = groupSO->GetObject(); groupObj = groupSO->GetObject();

View File

@ -90,7 +90,7 @@ void StdMeshers_LayerDistribution_i::SetLayerDistribution(SMESH::SMESH_Hypothesi
SALOMEDS::SObject_var SO = gen->ObjectToSObject( hyp1D ); SALOMEDS::SObject_var SO = gen->ObjectToSObject( hyp1D );
if ( ! SO->_is_nil() ) if ( ! SO->_is_nil() )
{ {
SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder(); SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewBuilder();
builder->RemoveObjectWithChildren( SO ); builder->RemoveObjectWithChildren( SO );
SO->UnRegister(); SO->UnRegister();
} }

View File

@ -60,7 +60,7 @@ StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject (const std::string& theEntry,
// try by entry // try by entry
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
if ( ! theEntry.empty() ) { if ( ! theEntry.empty() ) {
SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() ); SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( theEntry.c_str() );
CORBA::Object_var obj = gen->SObjectToObject( sobj ); CORBA::Object_var obj = gen->SObjectToObject( sobj );
geom = GEOM::GEOM_Object::_narrow( obj ); geom = GEOM::GEOM_Object::_narrow( obj );
} }
@ -116,7 +116,7 @@ TopoDS_Shape StdMeshers_ObjRefUlils::LoadFromStream( istream & stream,
if ( entry ) if ( entry )
* entry = str; * entry = str;
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( str.c_str() ); SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( str.c_str() );
CORBA::Object_var obj = gen->SObjectToObject( sobj ); CORBA::Object_var obj = gen->SObjectToObject( sobj );
GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj ); GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj );
return gen->GeomObjectToShape( geom.in() ); return gen->GeomObjectToShape( geom.in() );
@ -173,7 +173,7 @@ TopoDS_Shape StdMeshers_ObjRefUlils::EntryToShape(const std::string theEntry)
TopoDS_Shape shape; TopoDS_Shape shape;
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() ); SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( theEntry.c_str() );
CORBA::Object_var obj = gen->SObjectToObject( sobj ); CORBA::Object_var obj = gen->SObjectToObject( sobj );
GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj ); GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj );
shape = gen->GeomObjectToShape( geom.in() ); shape = gen->GeomObjectToShape( geom.in() );