salome.salome_init()
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"])
MEFISTO_2D_3 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_3)
SubMesh_3 = MEFISTO_2D_3.GetSubMesh()
- # check exisiting sub-mesh priority order
+ # check existing sub-mesh priority order
[ [ SubMesh_1, SubMesh_3, SubMesh_2 ] ] = Mesh_1.GetMeshOrder()
isDone = Mesh_1.Compute()
-print "Nb elements at initial order of sub-meshes:", Mesh_1.NbElements()
+print("Nb elements at initial order of sub-meshes:", Mesh_1.NbElements())
# set new sub-mesh order
isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_1, SubMesh_2, SubMesh_3 ] ])
# compute mesh
isDone = Mesh_1.Compute()
-print "Nb elements at new order of sub-meshes:", Mesh_1.NbElements()
+print("Nb elements at new order of sub-meshes:", Mesh_1.NbElements())
# compute with other sub-mesh order
isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_2, SubMesh_1, SubMesh_3 ] ])
isDone = Mesh_1.Compute()
-print "Nb elements at another order of sub-meshes:", Mesh_1.NbElements()
+print("Nb elements at another order of sub-meshes:", Mesh_1.NbElements())
# get faces with aspect ratio > 2.5
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5)
ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with aspect ratio > 2.5:", len(ids)
+print("Number of faces with aspect ratio > 2.5:", len(ids))
# get faces with aspect ratio > 1.5
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, '>', 1.5, mesh=mesh)
ids = filter.GetIDs()
-print "Number of faces with aspect ratio > 1.5:", len(ids)
+print("Number of faces with aspect ratio > 1.5:", len(ids))
# copy the faces with aspect ratio > 1.5 to another mesh;
- # this demostrates that a filter can be used where usually a group or sub-mesh is acceptable
+ # this demonstrates that a filter can be used where usually a group or sub-mesh is acceptable
filter.SetMesh( mesh.GetMesh() ) # - actually non necessary as mesh is set at filter creation
mesh2 = smesh.CopyMesh( filter, "AR > 1.5" )
-print "Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces()
+print("Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces())
# create a group (Group on Filter) of faces with Aspect Ratio < 1.5
group = mesh.MakeGroup("AR < 1.5", SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5)
-print "Number of faces with aspect ratio < 1.5:", group.Size()
+print("Number of faces with aspect ratio < 1.5:", group.Size())
# combine several criteria to Create a Group of only Triangular faces with Aspect Ratio < 1.5;
# note that contents of a GroupOnFilter is dynamically updated as the mesh changes
crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ),
smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ]
triaGroup = mesh.MakeGroupByCriteria( "Tria AR < 1.5", crit )
-print "Number of triangles with aspect ratio < 1.5:", triaGroup.Size()
+print("Number of triangles with aspect ratio < 1.5:", triaGroup.Size())
# get range of values of Aspect Ratio of all faces in the mesh
aspects = mesh.GetMinMax( SMESH.FT_AspectRatio )
-print "MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] )
+print("MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] ))
# get max value of Aspect Ratio of faces in triaGroup
grAspects = mesh.GetMinMax( SMESH.FT_AspectRatio, triaGroup )
-print "GROUP: Max aspect = %s" % grAspects[1]
+print("GROUP: Max aspect = %s" % grAspects[1])
# get Aspect Ratio of an element
aspect = mesh.FunctorValue( SMESH.FT_AspectRatio, ids[0] )
-print "Aspect ratio of the face %s = %s" % ( ids[0], aspect )
+print("Aspect ratio of the face %s = %s" % ( ids[0], aspect ))
/*!
- \page smesh_migration_page Modifing Mesh Python scripts from SALOME 6 and before
+ \page smesh_migration_page Modifying Mesh Python scripts from SALOME 6 and before
\n In SALOME 7.2, the Python interface for %Mesh has been slightly modified to offer new functionality:
\n the old mode (from dump):
\code
import smesh, SMESH, SALOMEDS
-smesh.SetCurrentStudy(salome.myStudy)
+smesh.UpdateStudy()
\endcode
\n the new mode:
\code
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
\endcode
const long Tag_LastGroup = 16;
/*!
- * Hypothesis definintion error
+ * Hypothesis definition error
*/
struct AlgoStateError
{
boolean IsEmbeddedMode();
/*!
- Set the current study
+ Update the study
*/
- void SetCurrentStudy( in SALOMEDS::Study theStudy );
-
+ void UpdateStudy();
+
+ /*!
+ Set enable publishing in the study
+ */
+ void SetEnablePublish( in boolean theIsEnablePublish );
+
/*!
- Get the current study
+ Get enable publishing in the study
*/
- SALOMEDS::Study GetCurrentStudy();
+ boolean IsEnablePublish();
/*!
* Create a hypothesis that can be shared by different parts of the mesh.
raises ( SALOME::SALOME_Exception );
/*!
- * Return errors of hypotheses definintion
+ * Return errors of hypotheses definition
* algo_error_array is empty if everything is OK
*/
algo_error_array GetAlgoState( in SMESH_Mesh theMesh,
*/
long GetObjectId(in Object theObject);
+ /*!
+ * \brief Get version of MED format being used.
+ */
+ string GetMEDFileVersion();
+
/*!
* \brief Get MED version of the file by its name.
*/
- boolean GetMEDVersion(in string theFileName, out MED_VERSION theVersion);
+ string GetMEDVersion(in string theFileName);
+
+ /*!
+ * \brief Check compatibility of file with MED format being used.
+ */
+ boolean CheckCompatibility(in string theFileName);
/*!
* \brief Get names of meshes defined in file with the specified name.
if ( !myMesh )
return addMessage("Supporting mesh not set", /*isFatal=*/true );
- MED::PWrapper medFile = MED::CrWrapper( myFile, MED::eV2_2 );
+ MED::PWrapper medFile = MED::CrWrapperW( myFile );
MED::PMeshInfo meshInfo;
if ( myMeshId > 0 )
{
return DRS_OK;
}
- namespace DriverMED // Implemetation of fuctions declared in DriverMED.hxx
+ namespace DriverMED // Implementation of functions declared in DriverMED.hxx
{
//================================================================================
/*!
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : SMESH_Algo.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
*/
//=============================================================================
-SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, studyId, gen)
+SMESH_Algo::SMESH_Algo (int hypId, SMESH_Gen * gen)
+ : SMESH_Hypothesis(hypId, gen)
{
_compatibleAllHypFilter = _compatibleNoAuxHypFilter = NULL;
_onlyUnaryInput = _requireDiscreteBoundary = _requireShape = true;
*/
//=============================================================================
-SMESH_0D_Algo::SMESH_0D_Algo(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Algo(hypId, studyId, gen)
+SMESH_0D_Algo::SMESH_0D_Algo(int hypId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, gen)
{
_shapeType = (1 << TopAbs_VERTEX);
_type = ALGO_0D;
}
-SMESH_1D_Algo::SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Algo(hypId, studyId, gen)
+SMESH_1D_Algo::SMESH_1D_Algo(int hypId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, gen)
{
_shapeType = (1 << TopAbs_EDGE);
_type = ALGO_1D;
}
-SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Algo(hypId, studyId, gen)
+SMESH_2D_Algo::SMESH_2D_Algo(int hypId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, gen)
{
_shapeType = (1 << TopAbs_FACE);
_type = ALGO_2D;
}
-SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Algo(hypId, studyId, gen)
+SMESH_3D_Algo::SMESH_3D_Algo(int hypId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, gen)
{
_shapeType = (1 << TopAbs_SOLID);
_type = ALGO_3D;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : SMESH_Algo.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
* Methods of the class are grouped into several parts:
* - main lifecycle methods, like Compute()
* - methods describing features of the algorithm, like NeedShape()
- * - methods related to dependencies between sub-meshes imposed by the algorith
+ * - methods related to dependencies between sub-meshes imposed by the algorithm
* - static utilities, like EdgeLength()
*/
// ==================================================================================
/*!
* \brief Creates algorithm
* \param hypId - algorithm ID
- * \param studyId - study ID
* \param gen - SMESH_Gen
*/
- SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
+ SMESH_Algo(int hypId, SMESH_Gen * gen);
/*!
* \brief Destructor
class SMESH_EXPORT SMESH_0D_Algo: public SMESH_Algo
{
public:
- SMESH_0D_Algo(int hypId, int studyId, SMESH_Gen* gen);
+ SMESH_0D_Algo(int hypId, SMESH_Gen* gen);
};
class SMESH_EXPORT SMESH_1D_Algo: public SMESH_Algo
{
public:
- SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen);
+ SMESH_1D_Algo(int hypId, SMESH_Gen* gen);
};
class SMESH_EXPORT SMESH_2D_Algo: public SMESH_Algo
{
public:
- SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen);
+ SMESH_2D_Algo(int hypId, SMESH_Gen* gen);
/*!
* \brief Method in which an algorithm generating a structured mesh
* fixes positions of in-face nodes after there movement
class SMESH_EXPORT SMESH_3D_Algo: public SMESH_Algo
{
public:
- SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen);
+ SMESH_3D_Algo(int hypId, SMESH_Gen* gen);
};
#endif
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : SMESH_Gen.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
SMESH_Gen::SMESH_Gen()
{
+ _studyContext = new StudyContextStruct;
+ _studyContext->myDocument = new SMESHDS_Document();
_localId = 0;
_hypId = 0;
_segmentation = _nbSegments = 10;
SMESH_Gen::~SMESH_Gen()
{
- std::map < int, StudyContextStruct * >::iterator i_sc = _mapStudyContext.begin();
- for ( ; i_sc != _mapStudyContext.end(); ++i_sc )
- {
- StudyContextStruct* context = i_sc->second;
- std::map < int, SMESH_Hypothesis * >::iterator i_hyp = context->mapHypothesis.begin();
- for ( ; i_hyp != context->mapHypothesis.end(); ++i_hyp )
+ std::map < int, SMESH_Hypothesis * >::iterator i_hyp = _studyContext->mapHypothesis.begin();
+ for ( ; i_hyp != _studyContext->mapHypothesis.end(); ++i_hyp )
{
if ( _Hyp* h = static_cast< _Hyp*>( i_hyp->second ))
h->NullifyGen();
}
- delete context->myDocument;
- delete context;
- }
+ delete _studyContext->myDocument;
+ delete _studyContext;
}
//=============================================================================
*/
//=============================================================================
-SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
+SMESH_Mesh* SMESH_Gen::CreateMesh(bool theIsEmbeddedMode)
throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
- // Get studyContext, create it if it doesn't exist, with a SMESHDS_Document
- StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
-
// create a new SMESH_mesh object
SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
- theStudyId,
this,
theIsEmbeddedMode,
- aStudyContext->myDocument);
- aStudyContext->mapMesh[_localId-1] = aMesh;
+ _studyContext->myDocument);
+ _studyContext->mapMesh[_localId-1] = aMesh;
return aMesh;
}
*/
//=============================================================================
-StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
+StudyContextStruct *SMESH_Gen::GetStudyContext()
{
- // Get studyContext, create it if it doesn't exist, with a SMESHDS_Document
-
- if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
- {
- _mapStudyContext[studyId] = new StudyContextStruct;
- _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
- }
- StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
- return myStudyContext;
+ return _studyContext;
}
//================================================================================
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : SMESH_Gen.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
SMESH_Gen();
~SMESH_Gen();
- SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
+ SMESH_Mesh* CreateMesh(bool theIsEmbeddedMode)
throw(SALOME_Exception);
enum ComputeFlags
// if Compute() would fail because of some algo bad state
// theErrors list contains problems description
- StudyContextStruct *GetStudyContext(int studyId);
+ StudyContextStruct *GetStudyContext();
static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType);
static int GetShapeDim(const TopoDS_Shape & aShape)
private:
int _localId; // unique Id of created objects, within SMESH_Gen entity
- std::map < int, StudyContextStruct * >_mapStudyContext;
+ StudyContextStruct* _studyContext;
// hypotheses managing
int _hypId;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : SMESH_Hypothesis.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
//=============================================================================
SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
- int studyId,
SMESH_Gen* gen) : SMESHDS_Hypothesis(hypId)
{
_gen = gen;
- _studyId = studyId;
_type = PARAM_ALGO;
_shapeType = 0; // to be set by algo with TopAbs_Enum
_param_algo_dim = -1; // to be set by algo parameter
- StudyContextStruct* myStudyContext = gen->GetStudyContext(_studyId);
+ StudyContextStruct* myStudyContext = gen->GetStudyContext();
myStudyContext->mapHypothesis[hypId] = this;
}
{
if ( _gen )
{
- StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
+ StudyContextStruct* myStudyContext = _gen->GetStudyContext();
myStudyContext->mapHypothesis[_hypId] = 0;
}
}
*/
//=============================================================================
-int SMESH_Hypothesis::GetStudyId() const
-{
- return _studyId;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
{
// for all meshes in study
- StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
+ StudyContextStruct* myStudyContext = _gen->GetStudyContext();
map<int, SMESH_Mesh*>::iterator itm;
for (itm = myStudyContext->mapMesh.begin();
itm != myStudyContext->mapMesh.end();
SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id)
{
- StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
+ StudyContextStruct* myStudyContext = _gen->GetStudyContext();
map<int, SMESH_Mesh*>::iterator itm = myStudyContext->mapMesh.begin();
for ( ; itm != myStudyContext->mapMesh.end(); itm++)
{
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : SMESH_Hypothesis.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
static bool IsStatusFatal(Hypothesis_Status theStatus)
{ return theStatus >= HYP_UNKNOWN_FATAL; }
- SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen);
+ SMESH_Hypothesis(int hypId, SMESH_Gen* gen);
virtual ~SMESH_Hypothesis();
virtual int GetDim() const;
- int GetStudyId() const;
SMESH_Gen* GetGen() const { return (SMESH_Gen*) _gen; }
virtual int GetShapeType() const;
virtual const char* GetLibName() const;
protected:
SMESH_Gen* _gen;
- int _studyId;
int _shapeType;
int _param_algo_dim; // to be set at descendant hypothesis constructor
//=============================================================================
SMESH_Mesh::SMESH_Mesh(int theLocalId,
- int theStudyId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument):
{
if(MYDEBUG) MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
_id = theLocalId;
- _studyId = theStudyId;
_gen = theGen;
_myDocument = theDocument;
_myMeshDS = theDocument->NewMesh(theIsEmbeddedMode,theLocalId);
SMESH_Mesh::SMESH_Mesh():
_id(-1),
- _studyId(-1),
_groupId( 0 ),
_nbSubShapes( 0 ),
_isShapeToMesh( false ),
// remove self from studyContext
if ( _gen )
{
- StudyContextStruct * studyContext = _gen->GetStudyContext( _studyId );
+ StudyContextStruct * studyContext = _gen->GetStudyContext();
studyContext->mapMesh.erase( _id );
}
if ( _myDocument )
if ( _id == meshId )
return (SMESH_Mesh*) this;
- if ( StudyContextStruct *aStudyContext = _gen->GetStudyContext( _studyId ))
+ if ( StudyContextStruct *aStudyContext = _gen->GetStudyContext())
{
std::map < int, SMESH_Mesh * >::iterator i_m = aStudyContext->mapMesh.find( meshId );
if ( i_m != aStudyContext->mapMesh.end() )
}
}
- // check concurent hypotheses on ancestors
+ // check concurrent hypotheses on ancestors
if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp )
{
SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
Unexpect aCatch(SalomeException);
if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
- StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
+ StudyContextStruct *sc = _gen->GetStudyContext();
if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
if (ret2 > ret) // more severe
ret = ret2;
- // check concurent hypotheses on ancestors
+ // check concurrent hypotheses on ancestors
if (ret < SMESH_Hypothesis::HYP_CONCURENT && !IsMainShape( aSubShape ) )
{
SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const int anHypId) const
{
- StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
+ StudyContextStruct *sc = _gen->GetStudyContext();
if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
return NULL;
* \param [in] theAutoGroups - boolean parameter for creating/not creating
* the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
* the typical use is auto_groups=false.
- * \param [in] theVersion - defines the version of format of MED file, that will be created
* \param [in] meshPart - mesh data to export
* \param [in] theAutoDimension - if \c true, a space dimension of a MED mesh can be either
* - 1D if all mesh nodes lie on OX coordinate axis, or
void SMESH_Mesh::ExportMED(const char * file,
const char* theMeshName,
bool theAutoGroups,
- int theVersion,
const SMESHDS_Mesh* meshPart,
bool theAutoDimension,
bool theAddODOnVertices,
SMESH_TRY;
DriverMED_W_SMESHDS_Mesh myWriter;
- myWriter.SetFile ( file, MED::EVersion(theVersion) );
+ myWriter.SetFile ( file );
myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
myWriter.SetAutoDimension( theAutoDimension );
myWriter.AddODOnVertices ( theAddODOnVertices );
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
cmd += "\"";
system(cmd.c_str());
- ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, /*theVersion=*/1,
+ ExportMED(medfilename.c_str(), theMeshName, theAutoGroups,
/*meshPart=*/NULL, /*theAutoDimension=*/false, /*theAddODOnVertices=*/false,
/*theAllElemsToGroup=*/true ); // theAllElemsToGroup is for PAL0023413
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import convert ; convert(r'" + medfilename + "', 'MED', 'GIBI', 1, r'" + file + "')";
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
mySelectButton3->setIcon(iconSelect);
myLineEdit3 = new QLineEdit(myGroupArguments);
myLineEdit3->setReadOnly(true);
+ myGenerateButton3 = new QPushButton(tr("GENERATE_GROUPS"), myGroupArguments);
myCheckBox1 = new QCheckBox(tr("CONSTRUCT_NEW_GROUP_ELEMENTS"), myGroupArguments);
myCheckBox2 = new QCheckBox(tr("CONSTRUCT_NEW_GROUP_NODES"), myGroupArguments);
- aGroupArgumentsLayout->addWidget(myTextLabel1, 0, 0);
- aGroupArgumentsLayout->addWidget(mySelectButton1, 0, 1);
- aGroupArgumentsLayout->addWidget(myLineEdit1, 0, 2);
- aGroupArgumentsLayout->addWidget(myTextLabel2, 1, 0);
- aGroupArgumentsLayout->addWidget(mySelectButton2, 1, 1);
- aGroupArgumentsLayout->addWidget(myLineEdit2, 1, 2);
- aGroupArgumentsLayout->addWidget(myTextLabel3, 2, 0);
- aGroupArgumentsLayout->addWidget(mySelectButton3, 2, 1);
- aGroupArgumentsLayout->addWidget(myLineEdit3, 2, 2);
- aGroupArgumentsLayout->addWidget(myCheckBox1, 3, 0);
- aGroupArgumentsLayout->addWidget(myCheckBox2, 4, 0);
+ aGroupArgumentsLayout->addWidget(myTextLabel1, 0, 0);
+ aGroupArgumentsLayout->addWidget(mySelectButton1, 0, 1);
+ aGroupArgumentsLayout->addWidget(myLineEdit1, 0, 2, 1, 2);
+ aGroupArgumentsLayout->addWidget(myTextLabel2, 1, 0);
+ aGroupArgumentsLayout->addWidget(mySelectButton2, 1, 1);
+ aGroupArgumentsLayout->addWidget(myLineEdit2, 1, 2, 1, 2);
+ aGroupArgumentsLayout->addWidget(myTextLabel3, 2, 0);
+ aGroupArgumentsLayout->addWidget(mySelectButton3, 2, 1);
+ aGroupArgumentsLayout->addWidget(myLineEdit3, 2, 2);
+ aGroupArgumentsLayout->addWidget(myGenerateButton3,2, 3);
+ aGroupArgumentsLayout->addWidget(myCheckBox1, 3, 0);
+ aGroupArgumentsLayout->addWidget(myCheckBox2, 4, 0);
aGroupArgumentsLayout->setRowStretch(5, 1);
// Buttons
connect(mySelectButton1, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
connect(mySelectButton2, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
connect(mySelectButton3, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
+ connect(myGenerateButton3, SIGNAL (clicked()), this, SLOT(onGenerate()));
connect(myCheckBox2, SIGNAL(stateChanged(int)), SLOT(updateButtons()));
// Set text to the group of arguments and to the first two labels
myGroupArguments->setTitle(tr("DUPLICATION_WITHOUT_ELEMS"));
myTextLabel1->setText(tr("GROUP_NODES_TO_DUPLICATE"));
- myTextLabel2->setText(tr("GROUP_NODES_TO_REPLACE"));
+ myTextLabel3->setText(tr("GROUP_NODES_TO_REPLACE"));
myCheckBox1->hide();
myCheckBox2->show();
myCheckBox2->setText( tr("CONSTRUCT_NEW_GROUP_NODES"));
- // Hide the third field
- myTextLabel2->show();
- mySelectButton2->show();
- myLineEdit2->show();
- myTextLabel3->hide();
- mySelectButton3->hide();
- myLineEdit3->hide();
-
+ // Hide the 2nd field
+ myTextLabel2 ->hide();
+ mySelectButton2 ->hide();
+ myLineEdit2 ->hide();
+ myTextLabel3 ->show();
+ mySelectButton3 ->show();
+ myLineEdit3 ->show();
+ myGenerateButton3->show();
+
break;
}
case 1:
myCheckBox1->setText( tr("CONSTRUCT_NEW_GROUP_ELEMENTS"));
myCheckBox2->setText( tr("CONSTRUCT_NEW_GROUP_NODES"));
- // Show the third field
- myTextLabel2->show();
- mySelectButton2->show();
- myLineEdit2->show();
- myTextLabel3->show();
- mySelectButton3->show();
- myLineEdit3->show();
+ // Show the 2nd field
+ myTextLabel2 ->show();
+ mySelectButton2 ->show();
+ myLineEdit2 ->show();
+ myTextLabel3 ->show();
+ mySelectButton3 ->show();
+ myLineEdit3 ->show();
+ myGenerateButton3->show();
break;
}
myCheckBox2->hide();
// Hide the second and the third field
- myTextLabel2->hide();
- mySelectButton2->hide();
- myLineEdit2->hide();
- myTextLabel3->hide();
- mySelectButton3->hide();
- myLineEdit3->hide();
+ myTextLabel2 ->hide();
+ mySelectButton2 ->hide();
+ myLineEdit2 ->hide();
+ myTextLabel3 ->hide();
+ mySelectButton3 ->hide();
+ myLineEdit3 ->hide();
+ myGenerateButton3->hide();
break;
}
myCheckBox2->setText( tr("ON_ALL_BOUNDARIES"));
// Hide the second and the third field
- myTextLabel2->hide();
- mySelectButton2->hide();
- myLineEdit2->hide();
- myTextLabel3->hide();
- mySelectButton3->hide();
- myLineEdit3->hide();
+ myTextLabel2 ->hide();
+ mySelectButton2 ->hide();
+ myLineEdit2 ->hide();
+ myTextLabel3 ->hide();
+ mySelectButton3 ->hide();
+ myLineEdit3 ->hide();
+ myGenerateButton3->hide();
break;
}
*/
bool SMESHGUI_DuplicateNodesDlg::onApply()
{
- if ( mySMESHGUI->isActiveStudyLocked() || !isValid() )
+ if ( SMESHGUI::isStudyLocked() || !isValid() )
return false;
BusyLocker lock( myBusy );
QStringList anEntryList;
try {
- SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
+ SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
switch ( operationMode ) {
for ( int i = 0; i < myGroups1.count(); i++ )
g1[i] = myGroups1[i];
SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
- g2->length( myGroups2.count() );
- for ( int i = 0; i < myGroups2.count(); i++ )
- g2[i] = myGroups2[i];
+ g2->length( myGroups3.count() );
+ for ( int i = 0; i < myGroups3.count(); i++ )
+ g2[i] = myGroups3[i];
if ( toCreateNodeGroup ) {
SMESH::SMESH_GroupBase_var aNewGroup =
SalomeApp_Tools::QtCatchCorbaException(S_ex);
}
catch ( const std::exception& exc ) {
- INFOS( "Follow exception was cought:\n\t" << exc.what() );
+ INFOS( "Follow exception was caught:\n\t" << exc.what() );
}
catch (...) {
- INFOS( "Unknown exception was cought !!!" );
+ INFOS( "Unknown exception was caught !!!" );
}
if (!result) {
bool isDataValid = isValid();
myButtonOk->setEnabled( isDataValid );
myButtonApply->setEnabled( isDataValid );
+
+ int operationMode = myGroupConstructors->checkedId();
+ myGenerateButton3->setEnabled( operationMode <= 1 && !myGroups1.empty() );
}
/*!
}
}
- if ( mySMESHGUI->isActiveStudyLocked() )
+ /*!
+ \brief SLOT called when Generate button is clicked
+ */
+ void SMESHGUI_DuplicateNodesDlg::onGenerate()
+ {
++ if ( SMESHGUI::isStudyLocked() )
+ return;
+
+ SUIT_OverrideCursor aWaitCursor;
+ BusyLocker lock( myBusy );
+
+ try {
+ SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
+ SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
+
+ SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
+ g1->length( myGroups1.count() );
+ for ( int i = 0; i < myGroups1.count(); i++ )
+ g1[i] = myGroups1[i];
+ SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
+ g2->length( myGroups2.count() );
+ for ( int i = 0; i < myGroups2.count(); i++ )
+ g2[i] = myGroups2[i];
+
+ SMESH::ListOfGroups_var newGroups =
+ aMeshEditor->AffectedElemGroupsInRegion( g1, g2, GEOM::GEOM_Object::_nil() );
+
+ QString text;
+ switch ( newGroups->length() ) {
+ case 0: break;
+ case 1: text = SMESH::toQStr( newGroups[0]->GetName() ); break;
+ default: text = tr( "SMESH_OBJECTS_SELECTED" ).arg( newGroups->length() );
+ }
+ myLineEdit3->setText( text );
+
+ myGroups3.clear();
+ for ( CORBA::ULong i = 0; i < newGroups->length(); ++i )
+ myGroups3 << SMESH::SMESH_GroupBase::_duplicate( newGroups[i] );
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
+ }
+ catch ( const std::exception& exc ) {
+ INFOS( "Follow exception was caught:\n\t" << exc.what() );
+ }
+ catch (...) {
+ INFOS( "Unknown exception was caught !!!" );
+ }
+
+ mySMESHGUI->updateObjBrowser(true);
+ updateButtons();
+ }
+
/*!
\brief Receive dialog enter events.
Activates the dialog when the mouse cursor enters.
<source>MED_FILES_FILTER</source>
<translation>MED files</translation>
</message>
+ <message>
+ <source>SAUV_FILES_FILTER</source>
+ <translation>SAUV files</translation>
+ </message>
<message>
<source>IDEAS_FILES_FILTER</source>
<translation>IDEAS files</translation>
<source>TEXT_FILES_FILTER</source>
<translation>TXT files</translation>
</message>
- <message>
- <source>MED_VX_FILES_FILTER</source>
- <translation>MED %1 files</translation>
- </message>
<message>
<source>STL_FILES_FILTER</source>
<translation>STL files</translation>
<source>SMESH_EXPORT_ONLY_GPOUP</source>
<translation>You are going to export the group without its mesh.
Do you want to continue?</translation>
- </message>
- <message>
- <source>SMESH_EXPORT_MED_V2_1</source>
- <translation>During export mesh with name - "%1" to MED 2.1
-polygons and polyhedrons elements will be missed
-For correct export use MED 2.2
-Are you sure want to export to MED 2.1?</translation>
</message>
<message>
<source>SMESH_EXPORT_MED_VERSION_COLLISION</source>
<source>ON_ALL_BOUNDARIES</source>
<translation>On all boundaries</translation>
</message>
+ <message>
+ <source>GENERATE_GROUPS</source>
+ <translation>Generate</translation>
+ </message>
</context>
<context>
<name>SMESHGUI_Make2DFrom3DDlg</name>
_AString comment;
_pyID obj = cmd->GetObject();
- if ( obj.Search( "print " ) == 1 )
+ if ( obj.Search( "print(" ) == 1 )
return; // print statement
if ( !obj.IsEmpty() && obj.Value( obj.Length() ) == ')' )
}
}
}
+
+ bool _FilterArg( const _AString& theArg )
+ {
+ static std::list<_AString> filteredArgs;
+ static bool initialized = false;
+ if ( !initialized ) {
+ initialized = true;
+ filteredArgs.push_back( "SMESH.MED_V2_1" );
+ filteredArgs.push_back( "SMESH.MED_V2_2" );
+ }
+ return std::find( filteredArgs.begin(), filteredArgs.end(), theArg ) != filteredArgs.end();
+ }
}
//================================================================================
Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
std::set< TCollection_AsciiString >& theRemovedObjIDs,
- SALOMEDS::Study_ptr& theStudy,
const bool theToKeepAllCommands)
{
std::list< TCollection_AsciiString >::iterator lineIt;
theGen = new _pyGen( theEntry2AccessorMethod,
theObjectNames,
theRemovedObjIDs,
- theStudy,
theToKeepAllCommands );
for ( lineIt = theScriptLines.begin(); lineIt != theScriptLines.end(); ++lineIt )
MESSAGE_BEGIN ( std::endl << " ######## RESULT ######## " << std::endl<< std::endl );
#endif
- // clean commmands of removed objects depending on myIsPublished flag
+ // clean commands of removed objects depending on myIsPublished flag
theGen->ClearCommands();
// reorder commands after conversion
set<_pyID> createdObjects;
createdObjects.insert( "smeshBuilder" );
createdObjects.insert( "smesh" );
- createdObjects.insert( "theStudy" );
for ( cmd = theGen->GetCommands().begin(); cmd != theGen->GetCommands().end(); ++cmd )
{
#ifdef DUMP_CONVERSION
_pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
std::set< TCollection_AsciiString >& theRemovedObjIDs,
- SALOMEDS::Study_ptr& theStudy,
const bool theToKeepAllCommands)
: _pyObject( new _pyCommand( "", 0 )),
myNbCommands( 0 ),
myRemovedObjIDs( theRemovedObjIDs ),
myNbFilters( 0 ),
myToKeepAllCommands( theToKeepAllCommands ),
- myStudy( SALOMEDS::Study::_duplicate( theStudy )),
myGeomIDNb(0), myGeomIDIndex(-1)
{
// make that GetID() to return TPythonDump::SMESHGenName()
GetCreationCmd()->GetString() += "=";
// Find 1st digit of study entry by which a GEOM object differs from a SMESH object
- if ( !theObjectNames.IsEmpty() && !CORBA::is_nil( theStudy ))
+ if ( !theObjectNames.IsEmpty() )
{
// find a GEOM entry
_pyID geomID;
- SALOMEDS::SComponent_wrap geomComp = theStudy->FindComponent("GEOM");
+ SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::getStudyServant()->FindComponent("GEOM");
if ( geomComp->_is_nil() ) return;
CORBA::String_var entry = geomComp->GetID();
geomID = entry.in();
_AString newCmd = indent + tab + ( aCommand->GetString().ToCString() + indent.Length() );
_AString pasCmd = indent + tab + "pass"; // to keep valid if newCmd is erased
_AString excStr = indent + "except:";
- _AString msgStr = indent + "\tprint '"; msgStr += method + "() failed. Invalid file name?'";
+ _AString msgStr = indent + "\tprint('"; msgStr += method + "() failed. Invalid file name?')";
myCommands.insert( --myCommands.end(), new _pyCommand( tryStr, myNbCommands ));
aCommand->Clear();
else if ( method == "MakeBoundaryElements")
meshID = aCommand->GetResultValue(2);
- if ( method.Search("MakeGroups") != -1 ||
- method == "ExtrusionAlongPathX" ||
- method == "ExtrusionAlongPathObjX" ||
- method == "DoubleNodeGroupNew" ||
- method == "DoubleNodeGroupsNew" ||
- method == "DoubleNodeElemGroupNew" ||
- method == "DoubleNodeElemGroupsNew"||
- method == "DoubleNodeElemGroup2New"||
- method == "DoubleNodeElemGroups2New"
+ if ( method.Search("MakeGroups") != -1 ||
+ method == "ExtrusionAlongPathX" ||
+ method == "ExtrusionAlongPathObjX" ||
+ method == "DoubleNodeGroupNew" ||
+ method == "DoubleNodeGroupsNew" ||
+ method == "DoubleNodeElemGroupNew" ||
+ method == "DoubleNodeElemGroupsNew" ||
+ method == "DoubleNodeElemGroup2New" ||
+ method == "DoubleNodeElemGroups2New" ||
+ method == "AffectedElemGroupsInRegion"
)
groups = aCommand->GetResultValue();
else if ( method == "MakeBoundaryMesh" )
static TStringSet smeshpyMethods;
if ( smeshpyMethods.empty() ) {
const char * names[] =
- { "SetEmbeddedMode","IsEmbeddedMode","SetCurrentStudy","GetCurrentStudy",
+ { "SetEmbeddedMode","IsEmbeddedMode","UpdateStudy","GetStudy",
"GetPattern","GetSubShapesId",
"" }; // <- mark of array end
smeshpyMethods.Insert( names );
//================================================================================
/*!
- * \brief Clean commmands of removed objects depending on myIsPublished flag
+ * \brief Clean commands of removed objects depending on myIsPublished flag
*/
//================================================================================
// either the SMESH object is not in study or it is a GEOM object
if ( IsGeomObject( theObjID ))
{
- SALOMEDS::SObject_wrap so = myStudy->FindObjectID( theObjID.ToCString() );
+ SALOMEDS::SObject_wrap so = SMESH_Gen_i::getStudyServant()->FindObjectID( theObjID.ToCString() );
if ( so->_is_nil() ) return true;
CORBA::Object_var obj = so->GetObject();
return CORBA::is_nil( obj );
// ----------------------------------------------------------------------
else if ( theCommand->MethodStartsFrom( "Export" ))
{
- if ( method == "ExportToMED" || // ExportToMED() --> ExportMED()
- method == "ExportToMEDX" ) // ExportToMEDX() --> ExportMED()
+ if ( method == "ExportToMED" || // ExportToMED() --> ExportMED()
+ method == "ExportToMEDX" || // ExportToMEDX() --> ExportMED()
+ method == "ExportMED" )
{
theCommand->SetMethod( "ExportMED" );
- if ( theCommand->GetNbArgs() == 5 )
+ // filter out deprecated version parameter
+ vector< _AString > args;
+ for ( int i = 1; i <= theCommand->GetNbArgs(); i++ ) {
+ if ( !_FilterArg( theCommand->GetArg( i ) ) )
+ args.push_back( theCommand->GetArg( i ) );
+ }
+ theCommand->RemoveArgs();
+ for ( uint i = 0; i < args.size(); i++ )
+ theCommand->SetArg( i+1, args[i] );
+ if ( theCommand->GetNbArgs() == 4 )
{
// ExportToMEDX(...,autoDimension) -> ExportToMEDX(...,meshPart=None,autoDimension)
- _AString autoDimension = theCommand->GetArg( 5 );
- theCommand->SetArg( 5, "None" );
- theCommand->SetArg( 6, autoDimension );
+ _AString autoDimension = theCommand->GetArg( 4 );
+ theCommand->SetArg( 4, "None" );
+ theCommand->SetArg( 5, autoDimension );
}
}
else if ( method == "ExportCGNS" )
TCollection_AsciiString newMethod = method;
newMethod.Remove( /*where=*/7, /*howmany=*/6 );
theCommand->SetMethod( newMethod );
+ // filter out deprecated version parameter
+ vector< _AString > args;
+ for ( int i = 1; i <= theCommand->GetNbArgs(); i++ ) {
+ if ( !_FilterArg( theCommand->GetArg( i ) ) )
+ args.push_back( theCommand->GetArg( i ) );
+ }
+ theCommand->RemoveArgs();
+ for ( uint i = 0; i < args.size(); i++ )
+ theCommand->SetArg( i+1, args[i] );
// make the 1st arg be the last one (or last but three for ExportMED())
_pyID partID = theCommand->GetArg( 1 );
int nbArgs = theCommand->GetNbArgs() - 3 * (newMethod == "ExportMED");
const char * names[] =
{ "ExportDAT","ExportUNV","ExportSTL","ExportSAUV", "RemoveGroup","RemoveGroupWithContents",
"GetGroups","UnionGroups","IntersectGroups","CutGroups","CreateDimGroup","GetLog","GetId",
- "ClearLog","GetStudyId","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
+ "ClearLog","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
"NbEdges","NbEdgesOfOrder","NbFaces","NbFacesOfOrder","NbTriangles",
"NbTrianglesOfOrder","NbQuadrangles","NbQuadranglesOfOrder","NbPolygons","NbVolumes",
"NbVolumesOfOrder","NbTetras","NbTetrasOfOrder","NbHexas","NbHexasOfOrder",
"Scale","ScaleMakeMesh","RotateMakeMesh","RotateObjectMakeMesh","MakeBoundaryMesh",
"MakeBoundaryElements", "SplitVolumesIntoTetra","SplitHexahedraIntoPrisms",
"DoubleElements","DoubleNodes","DoubleNode","DoubleNodeGroup","DoubleNodeGroups",
- "DoubleNodeElem","DoubleNodeElemInRegion","DoubleNodeElemGroup",
+ "DoubleNodeElem","DoubleNodeElemInRegion","DoubleNodeElemGroup","AffectedElemGroupsInRegion",
"DoubleNodeElemGroupInRegion","DoubleNodeElemGroups","DoubleNodeElemGroupsInRegion",
"DoubleNodesOnGroupBoundaries","CreateFlatElementsOnFacesGroups","CreateHoleSkin"
,"" }; // <- mark of the end
//================================================================================
/*!
- * \brief Set agrument
+ * \brief Set argument
* \param index - The argument index, it counts from 1
* \param theArg - The argument string
*/
if ( theName != 0 )
{
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- if ( !aStudy->_is_nil() )
+ SALOMEDS::Study::ListOfSObject_var aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "GEOM" );
+ if ( aList->length() > 0 )
{
- SALOMEDS::Study::ListOfSObject_var aList = aStudy->FindObjectByName( theName, "GEOM" );
- if ( aList->length() > 0 )
- {
- CORBA::Object_var anObj = aList[ 0 ]->GetObject();
- GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( anObj );
- TopoDS_Shape shape = aSMESHGen->GeomObjectToShape( aGeomObj );
- SALOME::UnRegister( aList ); // UnRegister() objects in aList
- return shape;
- }
+ CORBA::Object_var anObj = aList[ 0 ]->GetObject();
+ GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( anObj );
+ TopoDS_Shape shape = aSMESHGen->GeomObjectToShape( aGeomObj );
+ SALOME::UnRegister( aList ); // UnRegister() objects in aList
+ return shape;
}
}
return TopoDS_Shape();
{
if ( theID && strlen( theID ) > 0 ) {
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
- if ( !aSObj->_is_nil() ) {
- CORBA::Object_var obj = aSObj->GetObject();
- GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
- return aSMESHGen->GeomObjectToShape( aGeomObj );
- }
+ SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID(theID);
+ if ( !aSObj->_is_nil() ) {
+ CORBA::Object_var obj = aSObj->GetObject();
+ GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
+ return aSMESHGen->GeomObjectToShape( aGeomObj );
}
}
return TopoDS_Shape();
// static std::string getShapeNameByID (const char* theID)
// {
// if ( theID && strlen( theID ) > 0 ) {
-// SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
-// SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
-// if ( !aStudy->_is_nil() ) {
-// SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
-// if ( !aSObj->_is_nil() ) {
-// CORBA::String_var name = aSObj->GetName();
-// return name.in();
-// }
+// SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID(theID);
+// if ( !aSObj->_is_nil() ) {
+// CORBA::String_var name = aSObj->GetName();
+// return name.in();
// }
// }
// return "";
/*
Class : Functor_i
- Description : An abstact class for all functors
+ Description : An abstract class for all functors
*/
Functor_i::Functor_i():
SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
}
else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI
{
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID( myID.c_str() );
- if ( !aSObj->_is_nil() ) {
- CORBA::Object_var obj = aSObj->GetObject();
- SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
- }
+ SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( myID.c_str() );
+ if ( !aSObj->_is_nil() ) {
+ CORBA::Object_var obj = aSObj->GetObject();
+ SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
}
}
else if ( !myID.empty() ) // persistent mode
{
// search for a group in a current study
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- if ( StudyContext* sc = aSMESHGen->GetCurrentStudyContext() )
+ if ( StudyContext* sc = aSMESHGen->GetStudyContext() )
{
int id = 1;
std::string ior;
}
case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry /////////////////
{
- SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
- if ( study->_is_nil() )
- THROW_SALOME_CORBA_EXCEPTION
- ( "ConnectedElements_i::SetThreshold(): NULL current study", SALOME::BAD_PARAM );
- SALOMEDS::SObject_wrap sobj = study->FindObjectID( threshold );
+ SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( threshold );
if ( sobj->_is_nil() )
THROW_SALOME_CORBA_EXCEPTION
( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM );
#include <map>
#include <fstream>
+#include <sstream>
#include <cstdio>
#include <cstdlib>
_thisObj = this ;
_id = myPoa->activate_object( _thisObj );
+ myStudyContext = new StudyContext;
+
myIsEmbeddedMode = false;
+ myIsEnablePublish = true;
myShapeReader = NULL; // shape reader
mySMESHGen = this;
myIsHistoricalPythonDump = true;
myHypCreatorMap.clear();
// Clear study contexts data
- map<int, StudyContext*>::iterator it;
- for ( it = myStudyContextMap.begin(); it != myStudyContextMap.end(); ++it ) {
- delete it->second;
- }
- myStudyContextMap.clear();
+ delete myStudyContext;
+
// delete shape reader
if ( myShapeReader )
delete myShapeReader;
throw (SALOME::SALOME_Exception)
{
std::string aPlatformLibName;
- /* It's Need to tranlate lib name for WIN32 or X platform */
+ /* It's Need to translate lib name for WIN32 or X platform */
if ( theLibName && theLibName[0] != '\0' )
{
int libNameLen = strlen(theLibName);
getHypothesisCreator(theHypName, theLibName, aPlatformLibName);
// create a new hypothesis object, store its ref. in studyContext
- myHypothesis_i = aCreator->Create(myPoa, GetCurrentStudyID(), &myGen);
+ myHypothesis_i = aCreator->Create(myPoa, &myGen);
if (myHypothesis_i)
{
myHypothesis_i->SetLibName( aPlatformLibName.c_str() ); // for persistency assurance
// Get or create the GEOM_Client instance
try {
// create a new mesh object servant, store it in a map in study context
- SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() );
+ SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this );
// create a new mesh object
if(MYDEBUG) MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode);
- meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode ));
+ meshServant->SetImpl( myGen.CreateMesh( myIsEmbeddedMode ));
// activate the CORBA servant of Mesh
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() );
//=============================================================================
/*!
- * SMESH_Gen_i::SetCurrentStudy
+ * SMESH_Gen_i::SetEnablePublish
*
- * Set current study
+ * Set enable publishing in the study
*/
//=============================================================================
-
-void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy )
+void SMESH_Gen_i::SetEnablePublish( CORBA::Boolean theIsEnablePublish )
{
- setCurrentStudy( theStudy );
+ myIsEnablePublish = theIsEnablePublish;
}
-void SMESH_Gen_i::setCurrentStudy( SALOMEDS::Study_ptr theStudy,
- bool theStudyIsBeingClosed)
+//=============================================================================
+/*!
+ * SMESH_Gen_i::IsEnablePublish
+ *
+ * Check enable publishing
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_Gen_i::IsEnablePublish()
{
- int curStudyId = GetCurrentStudyID();
- myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy );
- // create study context, if it doesn't exist and set current study
- int studyId = GetCurrentStudyID();
- if ( myStudyContextMap.find( studyId ) == myStudyContextMap.end() )
- myStudyContextMap[ studyId ] = new StudyContext;
-
- // myCurrentStudy may be nil
- if ( !theStudyIsBeingClosed && !CORBA::is_nil( myCurrentStudy ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
- SALOMEDS::SComponent_wrap GEOM_var = myCurrentStudy->FindComponent( "GEOM" );
- if( !GEOM_var->_is_nil() )
- aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine() );
- // NPAL16168, issue 0020210
- // Let meshes update their data depending on GEOM groups that could change
- if ( curStudyId != studyId )
- {
- CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SComponent_wrap me = myCurrentStudy->FindComponent( compDataType.in() );
- if ( !me->_is_nil() ) {
- SALOMEDS::ChildIterator_wrap anIter = myCurrentStudy->NewChildIterator( me );
- for ( ; anIter->More(); anIter->Next() ) {
- SALOMEDS::SObject_wrap so = anIter->Value();
- CORBA::Object_var ior = SObjectToObject( so );
- if ( SMESH_Mesh_i* mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
- mesh->CheckGeomModif();
- }
- }
- }
- }
+ return myIsEnablePublish;
}
//=============================================================================
/*!
- * SMESH_Gen_i::GetCurrentStudy
+ * SMESH_Gen_i::UpdateStudy
*
- * Get current study
+ * Update study (needed at switching GEOM->SMESH)
*/
//=============================================================================
-SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy()
+void SMESH_Gen_i::UpdateStudy()
{
- if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetCurrentStudy: study Id = " << GetCurrentStudyID() );
- if ( GetCurrentStudyID() < 0 )
- return SALOMEDS::Study::_nil();
- return SALOMEDS::Study::_duplicate( myCurrentStudy );
+ if ( !myStudyContext )
+ myStudyContext = new StudyContext;
+
+ SALOMEDS::Study_var aStudy = getStudyServant();
+ if ( !CORBA::is_nil( aStudy ) ) {
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::SComponent_wrap GEOM_var = aStudy->FindComponent( "GEOM" );
+ if( !GEOM_var->_is_nil() )
+ aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine() );
+ // NPAL16168, issue 0020210
+ // Let meshes update their data depending on GEOM groups that could change
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SComponent_wrap me = aStudy->FindComponent( compDataType.in() );
+ if ( !me->_is_nil() ) {
+ SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( me );
+ for ( ; anIter->More(); anIter->Next() ) {
+ SALOMEDS::SObject_wrap so = anIter->Value();
+ CORBA::Object_var ior = SObjectToObject( so );
+ if ( SMESH_Mesh_i* mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
+ mesh->CheckGeomModif();
+ }
+ }
+ }
}
//=============================================================================
/*!
- * SMESH_Gen_i::GetCurrentStudyContext
+ * SMESH_Gen_i::GetStudyContext
*
- * Get current study context
+ * Get study context
*/
//=============================================================================
-StudyContext* SMESH_Gen_i::GetCurrentStudyContext()
+StudyContext* SMESH_Gen_i::GetStudyContext()
{
- if ( !CORBA::is_nil( myCurrentStudy ) &&
- myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() )
- return myStudyContextMap[ myCurrentStudy->StudyId() ];
- else
- return 0;
+ return myStudyContext;
}
//=============================================================================
// Publish hypothesis/algorithm in the study
if ( CanPublishInStudy( hyp ) ) {
- SALOMEDS::SObject_wrap aSO = PublishHypothesis( myCurrentStudy, hyp );
+ SALOMEDS::SObject_wrap aSO = PublishHypothesis( hyp );
if ( !aSO->_is_nil() ) {
// Update Python script
TPythonDump() << aSO << " = " << this << ".CreateHypothesis('"
SMESH::SMESH_Mesh_out theMesh,
GEOM::GEOM_Object_out theShape)
{
- if ( GetCurrentStudyID() < 0 || CORBA::is_nil( theHyp ))
+ if ( CORBA::is_nil( theHyp ))
return false;
// get Mesh component SO
CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SComponent_wrap comp = myCurrentStudy->FindComponent( compDataType.in() );
+ SALOMEDS::SComponent_wrap comp = getStudyServant()->FindComponent( compDataType.in() );
if ( CORBA::is_nil( comp ))
return false;
SMESH::SMESH_Mesh_var foundMesh;
TopoDS_Shape foundShape;
bool isSole = true;
- SALOMEDS::ChildIterator_wrap meshIter = myCurrentStudy->NewChildIterator( comp );
+ SALOMEDS::ChildIterator_wrap meshIter = getStudyServant()->NewChildIterator( comp );
for ( ; meshIter->More() && isSole; meshIter->Next() )
{
SALOMEDS::SObject_wrap curSO = meshIter->Value();
// publish mesh in the study
if ( CanPublishInStudy( mesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, mesh.in() );
+ SALOMEDS::SObject_wrap aSO = PublishMesh( mesh.in() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
// publish mesh in the study
if ( CanPublishInStudy( mesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, mesh.in() );
+ SALOMEDS::SObject_wrap aSO = PublishMesh( mesh.in() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
string aFileName;
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, aMesh.in(), aFileName.c_str() );
+ SALOMEDS::SObject_wrap aSO = PublishMesh( aMesh.in(), aFileName.c_str() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
if (theStatus == SMESH::DRS_OK) {
SALOMEDS::StudyBuilder_var aStudyBuilder;
- if ( GetCurrentStudyID() > -1 )
- {
- aStudyBuilder = myCurrentStudy->NewBuilder();
- aStudyBuilder->NewCommand(); // There is a transaction
- }
+ aStudyBuilder = getStudyServant()->NewBuilder();
+ aStudyBuilder->NewCommand(); // There is a transaction
+
aResult->length( aNames.size() );
int i = 0;
// little trick: for MED file theFileName and theFileNameForPython are the same, but they are different for SAUV
// - as names of meshes are stored in MED file, we use them for data publishing
// - as mesh name is not stored in UNV file, we use file name as name of mesh when publishing data
- aSO = PublishMesh( myCurrentStudy, mesh.in(), ( theFileName == theFileNameForPython ) ? (*it).c_str() : aFileName.c_str() );
+ aSO = PublishMesh( mesh.in(), ( theFileName == theFileNameForPython ) ? (*it).c_str() : aFileName.c_str() );
// Python Dump
if ( !aSO->_is_nil() ) {
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import convert ; convert(r'" + sauvfilename + "', 'GIBI', 'MED', 1, r'" + medfilename + "')";
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
#endif
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishInStudy
- ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
+ SALOMEDS::SObject_wrap aSO = PublishInStudy( SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
if (theStatus == SMESH::DRS_OK)
{
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
int i = 0;
// publish mesh in the study
SALOMEDS::SObject_wrap aSO;
if ( CanPublishInStudy( mesh ) )
- aSO = PublishMesh( myCurrentStudy, mesh.in(), meshName.c_str() );
+ aSO = PublishMesh( mesh.in(), meshName.c_str() );
// Python Dump
if ( !aSO->_is_nil() ) {
#endif
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishInStudy
- ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
+ SALOMEDS::SObject_wrap aSO = PublishInStudy( SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
SALOMEDS::SObject_ptr SMESH_Gen_i::GetAlgoSO(const ::SMESH_Algo* algo)
{
if ( algo ) {
- if ( !myCurrentStudy->_is_nil() ) {
+ SALOMEDS::Study_var aStudy = getStudyServant();
+ if ( !aStudy->_is_nil() ) {
// find algo in the study
CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SComponent_wrap father = myCurrentStudy->FindComponent( compDataType.in() );
+ SALOMEDS::SComponent_wrap father = aStudy->FindComponent( compDataType.in() );
if ( !father->_is_nil() ) {
- SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( father );
+ SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( father );
for ( ; itBig->More(); itBig->Next() ) {
SALOMEDS::SObject_wrap gotBranch = itBig->Value();
if ( gotBranch->Tag() == GetAlgorithmsRootTag() ) {
- SALOMEDS::ChildIterator_wrap algoIt = myCurrentStudy->NewChildIterator( gotBranch );
+ SALOMEDS::ChildIterator_wrap algoIt = aStudy->NewChildIterator( gotBranch );
for ( ; algoIt->More(); algoIt->Next() ) {
SALOMEDS::SObject_wrap algoSO = algoIt->Value();
CORBA::Object_var algoIOR = SObjectToObject( algoSO );
//================================================================================
/*!
- * \brief Returns errors of hypotheses definintion
+ * \brief Returns errors of hypotheses definition
* \param theMesh - the mesh
* \param theSubObject - the main or sub- shape
* \retval SMESH::algo_error_array* - sequence of errors
GEOM::GEOM_Gen_ptr geomGen = GetGeomEngine();
// try to find the corresponding SObject
- SALOMEDS::SObject_wrap SObj = ObjectToSObject( myCurrentStudy, geom.in() );
+ SALOMEDS::SObject_wrap SObj = ObjectToSObject( geom.in() );
if ( SObj->_is_nil() ) // submesh can be not found even if published
{
// try to find published submesh
GEOM::ListOfLong_var list = geom->GetSubShapeIndices();
if ( !geom->IsMainShape() && list->length() == 1 ) {
- SALOMEDS::SObject_wrap mainSO = ObjectToSObject( myCurrentStudy, mainShape );
+ SALOMEDS::SObject_wrap mainSO = ObjectToSObject( mainShape );
SALOMEDS::ChildIterator_wrap it;
if ( !mainSO->_is_nil() ) {
- it = myCurrentStudy->NewChildIterator( mainSO );
+ it = getStudyServant()->NewChildIterator( mainSO );
}
if ( !it->_is_nil() ) {
for ( it->InitEx(true); it->More(); it->Next() ) {
}
}
if ( SObj->_is_nil() ) // publish a new subshape
- SObj = geomGen->AddInStudy( myCurrentStudy, geom, theGeomName, mainShape );
+ SObj = geomGen->AddInStudy( geom, theGeomName, mainShape );
// return only published geometry
if ( !SObj->_is_nil() ) {
GEOM::GEOM_Object_var geom = ShapeToGeomObject( meshDS->IndexToShape( shapeID ));
if ( geom->_is_nil() ) {
// try to find a published sub-shape
- SALOMEDS::SObject_wrap mainSO = ObjectToSObject( myCurrentStudy, mainShape );
+ SALOMEDS::SObject_wrap mainSO = ObjectToSObject( mainShape );
SALOMEDS::ChildIterator_wrap it;
if ( !mainSO->_is_nil() ) {
- it = myCurrentStudy->NewChildIterator( mainSO );
+ it = getStudyServant()->NewChildIterator( mainSO );
}
if ( !it->_is_nil() ) {
for ( it->InitEx(true); it->More(); it->Next() ) {
}
if ( geom->_is_nil() ) {
// explode
- GEOM::GEOM_IShapesOperations_wrap op =
- geomGen->GetIShapesOperations( GetCurrentStudyID() );
+ GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
if ( !op->_is_nil() )
geom = op->GetSubShape( mainShape, shapeID );
}
int _assert[( nbNames == SMESH::NB_ELEMENT_TYPES ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
}
string groupName = "Gr";
- SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, theMeshesArray[i] );
+ SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( theMeshesArray[i] );
if ( aMeshSObj ) {
CORBA::String_var name = aMeshSObj->GetName();
groupName += name;
}
// IPAL21468 Change icon of compound because it need not be computed.
- SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, aNewMesh );
+ SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( aNewMesh );
SetPixMap( aMeshSObj, "ICON_SMESH_TREE_MESH" );
if (aNewMeshDS)
SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
if ( !newMesh_i )
THROW_SALOME_CORBA_EXCEPTION( "can't create a mesh", SALOME::INTERNAL_ERROR );
- SALOMEDS::SObject_wrap meshSO = ObjectToSObject(myCurrentStudy, newMesh );
+ SALOMEDS::SObject_wrap meshSO = ObjectToSObject( newMesh );
if ( !meshSO->_is_nil() )
{
SetName( meshSO, meshName, "Mesh" );
return newMesh._retn();
}
+//================================================================================
+/*!
+ * \brief Get version of MED format being used.
+ */
+//================================================================================
+
+char* SMESH_Gen_i::GetMEDFileVersion()
+{
+ MED::TInt majeur, mineur, release;
+ majeur = mineur = release = 0;
+ MED::GetVersionRelease(majeur, mineur, release);
+ std::ostringstream version;
+ version << majeur << "." << mineur << "." << release;
+ return CORBA::string_dup( version.str().c_str() );
+}
+
//================================================================================
/*!
* SMESH_Gen_i::GetMEDVersion
* Get MED version of the file by its name
*/
//================================================================================
-CORBA::Boolean SMESH_Gen_i::GetMEDVersion(const char* theFileName,
- SMESH::MED_VERSION& theVersion)
+char* SMESH_Gen_i::GetMEDVersion(const char* theFileName)
{
- theVersion = SMESH::MED_V2_1;
- MED::EVersion aVersion = MED::GetVersionId( theFileName );
- switch( aVersion ) {
- case MED::eV2_1 : theVersion = SMESH::MED_V2_1; return true;
- case MED::eV2_2 : theVersion = SMESH::MED_V2_2; return true;
- case MED::eLATEST : theVersion = SMESH::MED_LATEST; return true;
- case MED::eMINOR_0 : theVersion = SMESH::MED_MINOR_0; return true;
- case MED::eMINOR_1 : theVersion = SMESH::MED_MINOR_1; return true;
- case MED::eMINOR_2 : theVersion = SMESH::MED_MINOR_2; return true;
- case MED::eMINOR_3 : theVersion = SMESH::MED_MINOR_3; return true;
- case MED::eMINOR_4 : theVersion = SMESH::MED_MINOR_4; return true;
- case MED::eMINOR_5 : theVersion = SMESH::MED_MINOR_5; return true;
- case MED::eMINOR_6 : theVersion = SMESH::MED_MINOR_6; return true;
- case MED::eMINOR_7 : theVersion = SMESH::MED_MINOR_7; return true;
- case MED::eMINOR_8 : theVersion = SMESH::MED_MINOR_8; return true;
- case MED::eMINOR_9 : theVersion = SMESH::MED_MINOR_9; return true;
- case MED::eVUnknown : return false;
- }
- return false;
+ std::string version = MED::GetMEDVersion( theFileName );
+ return CORBA::string_dup( version.c_str() );
+}
+
+//================================================================================
+/*!
+ * SMESH_Gen_i::CheckCompatibility
+ *
+ * Check compatibility of file with MED format being used.
+ */
+//================================================================================
+CORBA::Boolean SMESH_Gen_i::CheckCompatibility(const char* theFileName)
+{
+ return MED::CheckCompatibility( theFileName );
}
//================================================================================
SMESH::string_array* SMESH_Gen_i::GetMeshNames(const char* theFileName)
{
SMESH::string_array_var aResult = new SMESH::string_array();
- MED::PWrapper aMed = MED::CrWrapper( theFileName );
+ MED::PWrapper aMed = MED::CrWrapperR( theFileName );
MED::TErr anErr;
MED::TInt aNbMeshes = aMed->GetNbMeshes( &anErr );
if( anErr >= 0 ) {
const char* theURL,
bool isMultiFile )
{
- // ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() )
- // san -- in case <myCurrentStudy> differs from theComponent's study,
- // use that of the component
- if ( theComponent->GetStudy()->StudyId() != GetCurrentStudyID() )
- SetCurrentStudy( theComponent->GetStudy() );
+ if (!myStudyContext)
+ UpdateStudy();
// Store study contents as a set of python commands
- SavePython(myCurrentStudy);
+ SavePython();
- StudyContext* myStudyContext = GetCurrentStudyContext();
+ SALOMEDS::Study_var aStudy = getStudyServant();
// Declare a byte stream
SALOMEDS::TMPFile_var aStreamFile;
( isMultiFile ) ? TCollection_AsciiString( ( char* )theURL ) : ( char* )SALOMEDS_Tool::GetTmpDir().c_str();
// Create a sequence of files processed
- SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
- aFileSeq->length( NUM_TMP_FILES );
+ SALOMEDS_Tool::ListOfFiles aFileSeq;
+ aFileSeq.reserve( NUM_TMP_FILES );
TCollection_AsciiString aStudyName( "" );
if ( isMultiFile )
- aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ).c_str() );
+ aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(aStudy->URL()) ).c_str() );
// Set names of temporary files
TCollection_AsciiString filename =
aStudyName + TCollection_AsciiString( "_SMESH.hdf" ); // for SMESH data itself
TCollection_AsciiString meshfile =
aStudyName + TCollection_AsciiString( "_SMESH_Mesh.med" ); // for mesh data to be stored in MED file
- aFileSeq[ 0 ] = CORBA::string_dup( filename.ToCString() );
- aFileSeq[ 1 ] = CORBA::string_dup( meshfile.ToCString() );
+ aFileSeq.push_back(CORBA::string_dup( filename.ToCString() ));
+ aFileSeq.push_back(CORBA::string_dup( meshfile.ToCString() ));
filename = tmpDir + filename;
meshfile = tmpDir + meshfile;
// SetStoreName() to groups before storing hypotheses to let them refer to
// groups using "store name", which is "Group <group_persistent_id>"
{
- SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( theComponent );
+ SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( theComponent );
for ( ; itBig->More(); itBig->Next() ) {
SALOMEDS::SObject_wrap gotBranch = itBig->Value();
if ( gotBranch->Tag() > GetAlgorithmsRootTag() ) {
aFile->CreateOnDisk();
// --> iterator for top-level objects
- SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( theComponent );
+ SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( theComponent );
for ( ; itBig->More(); itBig->Next() ) {
SALOMEDS::SObject_wrap gotBranch = itBig->Value();
aTopGroup->CreateOnDisk();
// iterator for all hypotheses
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( gotBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( gotBranch );
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
CORBA::Object_var anObject = SObjectToObject( mySObject );
aTopGroup->CreateOnDisk();
// iterator for all algorithms
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( gotBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( gotBranch );
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
CORBA::Object_var anObject = SObjectToObject( mySObject );
SALOMEDS::SObject_wrap myHypBranch;
found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch.inout() );
if ( found && !shapeRefFound && hasShape) { // remove applied hyps
- myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch );
+ aStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch );
}
if ( found && (shapeRefFound || !hasShape) ) {
aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup );
aGroup->CreateOnDisk();
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myHypBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myHypBranch );
int hypNb = 0;
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(),
myAlgoBranch.inout() );
if ( found && !shapeRefFound && hasShape) { // remove applied algos
- myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch );
+ aStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch );
}
if ( found && (shapeRefFound || !hasShape)) {
aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
aGroup->CreateOnDisk();
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myAlgoBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myAlgoBranch );
int algoNb = 0;
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
{
bool hasShapeRef = false;
SALOMEDS::ChildIterator_wrap itSM =
- myCurrentStudy->NewChildIterator( mySubmeshBranch );
+ aStudy->NewChildIterator( mySubmeshBranch );
for ( ; itSM->More(); itSM->Next() ) {
SALOMEDS::SObject_wrap mySubRef, myShape, mySObject = itSM->Value();
if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef.inout() ))
}
}
}
- myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( mySObject );
+ aStudy->NewBuilder()->RemoveObjectWithChildren( mySObject );
}
} // loop on submeshes of a type
if ( !shapeRefFound || !hasShapeRef ) { // remove the whole submeshes branch
- myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( mySubmeshBranch );
+ aStudy->NewBuilder()->RemoveObjectWithChildren( mySubmeshBranch );
found = false;
}
} // end check if there is shape reference in submeshes
aGroup->CreateOnDisk();
// iterator for all submeshes of given type
- SALOMEDS::ChildIterator_wrap itSM = myCurrentStudy->NewChildIterator( mySubmeshBranch );
+ SALOMEDS::ChildIterator_wrap itSM = aStudy->NewChildIterator( mySubmeshBranch );
for ( ; itSM->More(); itSM->Next() ) {
SALOMEDS::SObject_wrap mySObject = itSM->Value();
CORBA::Object_var anSubObject = SObjectToObject( mySObject );
aSubSubGroup = new HDFgroup( "Applied Hypotheses", aSubGroup );
aSubSubGroup->CreateOnDisk();
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( mySubHypBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( mySubHypBranch );
int hypNb = 0;
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySubSObject = it->Value();
aSubSubGroup->CreateOnDisk();
SALOMEDS::ChildIterator_wrap it =
- myCurrentStudy->NewChildIterator( mySubAlgoBranch );
+ aStudy->NewChildIterator( mySubAlgoBranch );
int algoNb = 0;
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySubSObject = it->Value();
aGroup = new HDFgroup( name_group, aTopGroup );
aGroup->CreateOnDisk();
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myGroupsBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myGroupsBranch );
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
CORBA::Object_var aSubObject = SObjectToObject( mySObject );
delete aFile;
// Convert temporary files to stream
- aStreamFile = SALOMEDS_Tool::PutFilesToStream( tmpDir.ToCString(), aFileSeq.in(), isMultiFile );
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream( tmpDir.ToCString(), aFileSeq, isMultiFile );
// Remove temporary files and directory
if ( !isMultiFile )
- SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq.in(), true );
+ SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq, true );
return aStreamFile._retn();
}
if ( theCompRoot->_is_nil() )
return;
- SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theCompRoot->GetStudy() );
- if ( aStudy->_is_nil() )
- return;
-
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->LoadWith( theCompRoot, GetGeomEngine() );
}
const char* theURL,
bool isMultiFile )
{
- if ( theComponent->GetStudy()->StudyId() != GetCurrentStudyID() )
- SetCurrentStudy( theComponent->GetStudy() );
-
+ if (!myStudyContext)
+ UpdateStudy();
+ SALOMEDS::Study_var aStudy = getStudyServant();
/* if( !theComponent->_is_nil() )
{
- //SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theComponent->GetStudy() );
- if( !myCurrentStudy->FindComponent( "GEOM" )->_is_nil() )
- loadGeomData( myCurrentStudy->FindComponent( "GEOM" ) );
+ if( !aStudy->FindComponent( "GEOM" )->_is_nil() )
+ loadGeomData( aStudy->FindComponent( "GEOM" ) );
}*/
- StudyContext* myStudyContext = GetCurrentStudyContext();
-
// Get temporary files location
TCollection_AsciiString tmpDir =
( char* )( isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir().c_str() );
// Convert the stream into sequence of files to process
- SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
- tmpDir.ToCString(),
- isMultiFile );
+ SALOMEDS_Tool::ListOfFiles aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
+ tmpDir.ToCString(),
+ isMultiFile );
TCollection_AsciiString aStudyName( "" );
if ( isMultiFile ) {
- CORBA::String_var url = myCurrentStudy->URL();
- aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( url.in() ).c_str();
+ CORBA::WString_var url = aStudy->URL();
+ aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(url.in()) ).c_str();
}
// Set names of temporary files
TCollection_AsciiString filename = tmpDir + aStudyName + "_SMESH.hdf";
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
if ( strlen( refFromFile ) > 0 ) {
- SALOMEDS::SObject_wrap shapeSO = myCurrentStudy->FindObjectID( refFromFile );
+ SALOMEDS::SObject_wrap shapeSO = aStudy->FindObjectID( refFromFile );
// Make sure GEOM data are loaded first
//loadGeomData( shapeSO->GetFatherComponent() );
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
// san - it is impossible to recover applied algorithms using their entries within Load() method
- //SALOMEDS::SObject_wrap hypSO = myCurrentStudy->FindObjectID( refFromFile );
+ //SALOMEDS::SObject_wrap hypSO = aStudy->FindObjectID( refFromFile );
//CORBA::Object_var hypObject = SObjectToObject( hypSO );
int id = atoi( refFromFile );
delete [] refFromFile;
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
// san - it is impossible to recover applied hypotheses using their entries within Load() method
- //SALOMEDS::SObject_wrap hypSO = myCurrentStudy->FindObjectID( refFromFile );
+ //SALOMEDS::SObject_wrap hypSO = myStudy->FindObjectID( refFromFile );
//CORBA::Object_var hypObject = SObjectToObject( hypSO );
int id = atoi( refFromFile );
delete [] refFromFile;
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
if ( strlen( refFromFile ) > 0 ) {
- SALOMEDS::SObject_wrap subShapeSO = myCurrentStudy->FindObjectID( refFromFile );
+ SALOMEDS::SObject_wrap subShapeSO = aStudy->FindObjectID( refFromFile );
CORBA::Object_var subShapeObject = SObjectToObject( subShapeSO );
if ( !CORBA::is_nil( subShapeObject ) ) {
aSubShapeObject = GEOM::GEOM_Object::_narrow( subShapeObject );
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
if ( strlen( refFromFile ) > 0 ) {
- SALOMEDS::SObject_wrap shapeSO = myCurrentStudy->FindObjectID( refFromFile );
+ SALOMEDS::SObject_wrap shapeSO = aStudy->FindObjectID( refFromFile );
CORBA::Object_var shapeObject = SObjectToObject( shapeSO );
if ( !CORBA::is_nil( shapeObject ) ) {
aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject );
SMESH_File meshFile( meshfile.ToCString() );
if ( !meshFile ) // no meshfile exists
{
- SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq.in(), true );
+ SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq, true );
}
else
{
// creation of tree nodes for all data objects in the study
// to support tree representation customization and drag-n-drop:
- SALOMEDS::Study_var study = theComponent->GetStudy();
- SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = study->GetUseCaseBuilder();
+ SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
if ( !useCaseBuilder->IsUseCaseNode( theComponent ) ) {
useCaseBuilder->SetRootCurrent();
useCaseBuilder->Append( theComponent ); // component object is added as the top level item
- SALOMEDS::ChildIterator_wrap it = study->NewChildIterator( theComponent );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( theComponent );
for (it->InitEx(true); it->More(); it->Next()) {
useCaseBuilder->AppendTo( it->Value()->GetFather(), it->Value() );
}
{
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Close" );
- // set correct current study
- SALOMEDS::Study_var study = theComponent->GetStudy();
- if ( study->StudyId() != GetCurrentStudyID())
- setCurrentStudy( study, /*IsBeingClosed=*/true );
-
// Clear study contexts data
- int studyId = GetCurrentStudyID();
- if ( myStudyContextMap.find( studyId ) != myStudyContextMap.end() ) {
- delete myStudyContextMap[ studyId ];
- myStudyContextMap.erase( studyId );
- }
+ delete myStudyContext;
+ myStudyContext = 0;
// remove the tmp files meshes are loaded from
SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD( theComponent );
- myCurrentStudy = SALOMEDS::Study::_nil();
return;
}
CORBA::Boolean /*isASCII*/ )
{
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::IORToLocalPersistentID" );
- StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && strcmp( IORString, "" ) != 0 ) {
int anId = myStudyContext->findId( IORString );
CORBA::Boolean /*isASCII*/ )
{
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LocalPersistentIDToIOR(): id = " << aLocalPersistentID );
- StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && strcmp( aLocalPersistentID, "" ) != 0 ) {
int anId = atoi( aLocalPersistentID );
int SMESH_Gen_i::RegisterObject(CORBA::Object_ptr theObject)
{
- StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && !CORBA::is_nil( theObject )) {
CORBA::String_var iorString = GetORB()->object_to_string( theObject );
return myStudyContext->addObject( string( iorString.in() ) );
CORBA::Long SMESH_Gen_i::GetObjectId(CORBA::Object_ptr theObject)
{
- StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && !CORBA::is_nil( theObject )) {
string iorString = GetORB()->object_to_string( theObject );
return myStudyContext->findId( iorString );
{
if ( theIOR && strcmp( theIOR, "" ) ) {
CORBA::Object_var anObject = GetORB()->string_to_object( theIOR );
- SALOMEDS::SObject_wrap aSO = ObjectToSObject( myCurrentStudy, anObject );
+ SALOMEDS::SObject_wrap aSO = ObjectToSObject( anObject );
if ( !aSO->_is_nil() ) {
SetName( aSO, theName );
}
}
}
-int SMESH_Gen_i::GetCurrentStudyID()
-{
- return myCurrentStudy->_is_nil() || myCurrentStudy->_non_existent() ? -1 : myCurrentStudy->StudyId();
-}
-
// Version information
char* SMESH_Gen_i::getVersion()
{
{
if ( CORBA::is_nil( where ) ) return;
- SALOMEDS::Study_var study = where->GetStudy();
- SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
- SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
+ SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = getStudyServant()->GetUseCaseBuilder();
SALOMEDS::SComponent_var father = where->GetFatherComponent();
std::string dataType = father->ComponentDataType();
if ( dataType != "SMESH" ) return; // not a SMESH component
// Get CORBA object corresponding to the SALOMEDS::SObject
static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject );
// Get the SALOMEDS::SObject corresponding to a CORBA object
- static SALOMEDS::SObject_ptr ObjectToSObject(SALOMEDS::Study_ptr theStudy,
- CORBA::Object_ptr theObject);
+ static SALOMEDS::SObject_ptr ObjectToSObject(CORBA::Object_ptr theObject);
+ // Get the SALOMEDS::Study from naming service
+ static SALOMEDS::Study_ptr getStudyServant();
- // Get GEOM Object correspoding to TopoDS_Shape
+ // Get GEOM Object corresponding to TopoDS_Shape
GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape );
- // Get TopoDS_Shape correspoding to GEOM_Object
+ // Get TopoDS_Shape corresponding to GEOM_Object
TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject);
// Default constructor
//GEOM::GEOM_Gen_ptr SetGeomEngine( const char* containerLoc );
void SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo );
- // Set current study
+ // Set embedded mode
void SetEmbeddedMode( CORBA::Boolean theMode );
- // Get current study
+ // Check embedded mode
CORBA::Boolean IsEmbeddedMode();
- // Set current study
- void SetCurrentStudy( SALOMEDS::Study_ptr theStudy );
- // Get current study
- SALOMEDS::Study_ptr GetCurrentStudy();
+ // Set enable publishing in the study
+ void SetEnablePublish( CORBA::Boolean theIsEnablePublish );
+
+ // Check enable publishing
+ CORBA::Boolean IsEnablePublish();
+
+ // Update study
+ void UpdateStudy();
// Create hypothesis/algorothm of given type
SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType,
SMESH::long_array& theShapesId )
throw ( SALOME::SALOME_Exception );
- // Returns errors of hypotheses definintion
+ // Returns errors of hypotheses definition
SMESH::algo_error_array* GetAlgoState( SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theSubObject )
throw ( SALOME::SALOME_Exception );
CORBA::Double mergeTolerance)
throw ( SALOME::SALOME_Exception );
+ // Get version of MED format being used.
+ char* GetMEDFileVersion();
+
// Get MED version of the file by its name
- CORBA::Boolean GetMEDVersion(const char* theFileName,
- SMESH::MED_VERSION& theVersion);
+ char* GetMEDVersion(const char* theFileName);
+
+ // Check compatibility of file with MED format being used.
+ CORBA::Boolean CheckCompatibility(const char* theFileName);
// Get names of meshes defined in file with the specified name
SMESH::string_array* GetMeshNames(const char* theFileName);
// Returns true if object can be published in the study
bool CanPublishInStudy( CORBA::Object_ptr theIOR );
// Publish object in the study
- SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr theSObject,
+ SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theObject,
const char* theName )
throw ( SALOME::SALOME_Exception );
// Dump python
// ============
- virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
+ virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
- void AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString);
+ void AddToPythonScript (const TCollection_AsciiString& theString);
- void RemoveLastFromPythonScript (int theStudyID);
+ void RemoveLastFromPythonScript();
- void SavePython (SALOMEDS::Study_ptr theStudy);
+ void SavePython();
- TCollection_AsciiString DumpPython_impl (SALOMEDS::Study_ptr theStudy,
- Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
+ TCollection_AsciiString DumpPython_impl (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
Resource_DataMapOfAsciiStringAsciiString& theNames,
bool isPublished,
bool isMultiFile,
bool& aValidScript,
TCollection_AsciiString& theSavedTrace);
- TCollection_AsciiString GetNewPythonLines (int theStudyID);
+ TCollection_AsciiString GetNewPythonLines();
- void CleanPythonTrace (int theStudyID);
+ void CleanPythonTrace();
// *****************************************
// Internal methods
static long GetBallElementsGroupsTag();
// publishing methods
- SALOMEDS::SComponent_ptr PublishComponent(SALOMEDS::Study_ptr theStudy);
- SALOMEDS::SObject_ptr PublishMesh (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SALOMEDS::SComponent_ptr PublishComponent();
+ SALOMEDS::SObject_ptr PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
const char* theName = 0);
- SALOMEDS::SObject_ptr PublishHypothesis (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Hypothesis_ptr theHyp,
+ SALOMEDS::SObject_ptr PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
const char* theName = 0);
- SALOMEDS::SObject_ptr PublishSubMesh (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SALOMEDS::SObject_ptr PublishSubMesh (SMESH::SMESH_Mesh_ptr theMesh,
SMESH::SMESH_subMesh_ptr theSubMesh,
GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0);
- SALOMEDS::SObject_ptr PublishGroup (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SALOMEDS::SObject_ptr PublishGroup (SMESH::SMESH_Mesh_ptr theMesh,
SMESH::SMESH_GroupBase_ptr theGroup,
GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0);
- bool AddHypothesisToShape(SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp);
- bool RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ bool RemoveHypothesisFromShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp);
- SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShape);
static void SetName(SALOMEDS::SObject_ptr theSObject,
const char* theName,
const char* thePixMap);
// Get study context
- StudyContext* GetCurrentStudyContext();
+ StudyContext* GetStudyContext();
// Register an object in a StudyContext; return object id
int RegisterObject(CORBA::Object_ptr theObject);
template<class TInterface>
typename TInterface::_var_type GetObjectByOldId( const int oldID )
{
- if ( StudyContext* myStudyContext = GetCurrentStudyContext() ) {
+ if ( myStudyContext ) {
std::string ior = myStudyContext->getIORbyOldId( oldID );
if ( !ior.empty() )
return TInterface::_narrow(GetORB()->string_to_object( ior.c_str() ));
return TInterface::_nil();
}
- // Get current study ID
- int GetCurrentStudyID();
-
/*!
* \brief Find SObject for an algo
*/
const char* theCommandNameForPython,
const char* theFileNameForPython);
- void setCurrentStudy( SALOMEDS::Study_ptr theStudy,
- bool theStudyIsBeingClosed=false);
-
std::vector<long> _GetInside(SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType,
TopoDS_Shape& aShape,
// hypotheses managing
std::map<std::string, GenericHypothesisCreator_i*> myHypCreatorMap;
- std::map<int, StudyContext*> myStudyContextMap; // Map of study context objects
+ StudyContext* myStudyContext; // study context
GEOM_Client* myShapeReader; // Shape reader
- SALOMEDS::Study_var myCurrentStudy; // Current study
CORBA::Boolean myIsEmbeddedMode; // Current mode
+ CORBA::Boolean myIsEnablePublish; // Enable publishing
// Default color of groups
std::string myDefaultGroupColor;
bool myToForgetMeshDataOnHypModif;
// Dump Python: trace of API methods calls
- std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts;
- bool myIsHistoricalPythonDump;
- std::vector< int > myLastParamIndex;
- std::vector< std::string > myLastParameters;
- std::string myLastObj;
+ Handle(TColStd_HSequenceOfAsciiString) myPythonScript;
+ bool myIsHistoricalPythonDump;
+ std::vector< int > myLastParamIndex;
+ std::vector< std::string > myLastParameters;
+ std::string myLastObj;
};
#include <Utils_ExceptHandlers.hxx>
#include <SALOMEDS_wrap.hxx>
#include <SALOMEDS_Attributes_wrap.hxx>
+#include <SALOME_KernelServices.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Solid.hxx>
bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
{
- if(MYDEBUG) MESSAGE("CanPublishInStudy - "<<!CORBA::is_nil(myCurrentStudy));
- if( GetCurrentStudyID() < 0 )
- return false;
+ if(MYDEBUG) MESSAGE("CanPublishInStudy - "<<!CORBA::is_nil(getStudyServant()));
+ if( !myIsEnablePublish )
+ return false;
+
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(theIOR);
if( !aMesh->_is_nil() )
return true;
//purpose : Put a result into a SALOMEDS::SObject_wrap or call UnRegister()!
//=======================================================================
-SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(SALOMEDS::Study_ptr theStudy,
- CORBA::Object_ptr theObject)
+SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(CORBA::Object_ptr theObject)
{
SALOMEDS::SObject_wrap aSO;
- if ( !CORBA::is_nil( theStudy ) && !CORBA::is_nil( theObject ))
+ if ( !CORBA::is_nil( theObject ))
{
CORBA::String_var objStr = SMESH_Gen_i::GetORB()->object_to_string( theObject );
- aSO = theStudy->FindObjectIOR( objStr.in() );
+ aSO = getStudyServant()->FindObjectIOR( objStr.in() );
}
return aSO._retn();
}
+//=======================================================================
+//function : GetStudyPtr
+//purpose : Get study from naming service
+//=======================================================================
+SALOMEDS::Study_ptr SMESH_Gen_i::getStudyServant()
+{
+ return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
+}
+
//=======================================================================
//function : objectToServant
//purpose :
//purpose :
//=======================================================================
-static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy,
- CORBA::Object_ptr theIOR,
+static SALOMEDS::SObject_ptr publish(CORBA::Object_ptr theIOR,
SALOMEDS::SObject_ptr theFatherObject,
const int theTag = 0,
const char* thePixMap = 0,
const bool theSelectable = true)
{
- SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theStudy, theIOR );
+ SALOMEDS::Study_var theStudy = SMESH_Gen_i::getStudyServant();
+ SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theIOR );
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder();
bool isNewSO = false, isInUseCaseTree = false;
const char* theDefaultName)
{
if ( !theSObject->_is_nil() ) {
- SALOMEDS::Study_var aStudy = theSObject->GetStudy();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
SALOMEDS::GenericAttribute_wrap anAttr =
aStudyBuilder->FindOrCreateAttribute( theSObject, "AttributeName" );
SALOMEDS::AttributeName_wrap aNameAttr = anAttr;
{
if ( !theSObject->_is_nil() && thePixMap && strlen( thePixMap ))
{
- SALOMEDS::Study_var aStudy = theSObject->GetStudy();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
SALOMEDS::GenericAttribute_wrap anAttr =
aStudyBuilder->FindOrCreateAttribute( theSObject, "AttributePixMap" );
SALOMEDS::AttributePixMap_wrap aPMAttr = anAttr;
//purpose :
//=======================================================================
-static void addReference (SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr theSObject,
+static void addReference (SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theToObject,
int theTag = 0)
{
- SALOMEDS::SObject_wrap aToObjSO = SMESH_Gen_i::ObjectToSObject( theStudy, theToObject );
+ SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
+ SALOMEDS::SObject_wrap aToObjSO = SMESH_Gen_i::ObjectToSObject( theToObject );
if ( !aToObjSO->_is_nil() && !theSObject->_is_nil() ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::SObject_wrap aReferenceSO;
if ( !theTag ) {
// check if the reference to theToObject already exists
// and find a free label for the reference object
bool isReferred = false;
int tag = 1;
- SALOMEDS::ChildIterator_wrap anIter = theStudy->NewChildIterator( theSObject );
+ SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( theSObject );
for ( ; !isReferred && anIter->More(); anIter->Next(), ++tag ) {
SALOMEDS::SObject_wrap curSO = anIter->Value();
if ( curSO->ReferencedObject( aReferenceSO.inout() )) {
// add reference to the use case tree
// (to support tree representation customization and drag-n-drop)
- SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder();
+ SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
SALOMEDS::UseCaseIterator_wrap useCaseIter = useCaseBuilder->GetUseCaseIterator(theSObject);
for ( ; useCaseIter->More(); useCaseIter->Next() )
{
*/
//=============================================================================
-SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr theSObject,
+SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theIOR,
const char* theName)
throw (SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
SALOMEDS::SObject_wrap aSO;
- if ( CORBA::is_nil( theStudy ) || CORBA::is_nil( theIOR ))
+ if ( CORBA::is_nil( theIOR ))
return aSO._retn();
if(MYDEBUG) MESSAGE("PublishInStudy");
// Publishing a mesh
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( theIOR );
if( !aMesh->_is_nil() )
- aSO = PublishMesh( theStudy, aMesh, theName );
+ aSO = PublishMesh( aMesh, theName );
// Publishing a sub-mesh
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( theIOR );
if( aSO->_is_nil() && !aSubMesh->_is_nil() ) {
GEOM::GEOM_Object_var aShapeObject = aSubMesh->GetSubShape();
aMesh = aSubMesh->GetFather();
- aSO = PublishSubMesh( theStudy, aMesh, aSubMesh, aShapeObject, theName );
+ aSO = PublishSubMesh( aMesh, aSubMesh, aShapeObject, theName );
}
// Publishing a hypothesis or algorithm
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theIOR );
if ( aSO->_is_nil() && !aHyp->_is_nil() )
- aSO = PublishHypothesis( theStudy, aHyp );
+ aSO = PublishHypothesis( aHyp );
// Publishing a group
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(theIOR);
if ( aSO->_is_nil() && !aGroup->_is_nil() ) {
GEOM::GEOM_Object_var aShapeObject;
aMesh = aGroup->GetMesh();
- aSO = PublishGroup( theStudy, aMesh, aGroup, aShapeObject, theName );
+ aSO = PublishGroup( aMesh, aGroup, aShapeObject, theName );
}
if(MYDEBUG) MESSAGE("PublishInStudy_END");
//purpose :
//=======================================================================
-SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theStudy)
+SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent()
{
- if ( CORBA::is_nil( theStudy ))
- return SALOMEDS::SComponent::_nil();
if(MYDEBUG) MESSAGE("PublishComponent");
- SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
- SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
+ SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = getStudyServant()->GetUseCaseBuilder();
CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SComponent_wrap father = theStudy->FindComponent( compDataType.in() );
+ SALOMEDS::SComponent_wrap father = getStudyServant()->FindComponent( compDataType.in() );
if ( !CORBA::is_nil( father ) ) {
// check that the component is added to the use case browser
if ( !useCaseBuilder->IsUseCaseNode( father ) ) {
//purpose :
//=======================================================================
-SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
const char* theName)
{
- if ( CORBA::is_nil( theStudy ) ||
- CORBA::is_nil( theMesh ))
+ if ( CORBA::is_nil( theMesh ))
return SALOMEDS::SComponent::_nil();
if(MYDEBUG) MESSAGE("PublishMesh--IN");
// find or publish a mesh
- SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theStudy, theMesh );
+ SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theMesh );
if ( aMeshSO->_is_nil() )
{
- SALOMEDS::SComponent_wrap father = PublishComponent( theStudy );
+ SALOMEDS::SComponent_wrap father = PublishComponent();
if ( father->_is_nil() )
return aMeshSO._retn();
else
aTag++;
- aMeshSO = publish (theStudy, theMesh, father, aTag, "ICON_SMESH_TREE_MESH_WARN" );
+ aMeshSO = publish ( theMesh, father, aTag, "ICON_SMESH_TREE_MESH_WARN" );
if ( aMeshSO->_is_nil() )
return aMeshSO._retn();
}
GEOM::GEOM_Object_var aShapeObject = theMesh->GetShapeToMesh();
if ( !CORBA::is_nil( aShapeObject )) {
- addReference( theStudy, aMeshSO, aShapeObject, GetRefOnShapeTag() );
+ addReference( aMeshSO, aShapeObject, GetRefOnShapeTag() );
// Publish global hypotheses
for ( CORBA::ULong i = 0; i < hypList->length(); i++ )
{
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]);
- SALOMEDS::SObject_wrap so = PublishHypothesis( theStudy, aHyp );
- AddHypothesisToShape( theStudy, theMesh, aShapeObject, aHyp );
+ SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp );
+ AddHypothesisToShape( theMesh, aShapeObject, aHyp );
}
}
SMESH::SMESH_subMesh_ptr aSubMesh = (*subIt).second->_this();
if ( !CORBA::is_nil( aSubMesh )) {
aShapeObject = aSubMesh->GetSubShape();
- SALOMEDS::SObject_wrap( PublishSubMesh( theStudy, theMesh, aSubMesh, aShapeObject ));
+ SALOMEDS::SObject_wrap( PublishSubMesh( theMesh, aSubMesh, aShapeObject ));
}
}
SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup );
if ( !aGeomGroup->_is_nil() )
aShapeObj = aGeomGroup->GetShape();
- SALOMEDS::SObject_wrap( PublishGroup( theStudy, theMesh, aGroup, aShapeObj ));
+ SALOMEDS::SObject_wrap( PublishGroup( theMesh, aGroup, aShapeObj ));
}
}
//purpose :
//=======================================================================
-SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr theMesh,
SMESH::SMESH_subMesh_ptr theSubMesh,
GEOM::GEOM_Object_ptr theShapeObject,
const char* theName)
{
- if (theStudy->_is_nil() || theMesh->_is_nil() ||
- theSubMesh->_is_nil() || theShapeObject->_is_nil() )
+ if ( theMesh->_is_nil() || theSubMesh->_is_nil() || theShapeObject->_is_nil() )
return SALOMEDS::SObject::_nil();
- SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theStudy, theSubMesh );
+ SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theSubMesh );
if ( aSubMeshSO->_is_nil() )
{
- SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theStudy, theMesh );
+ SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theMesh );
if ( aMeshSO->_is_nil() ) {
- aMeshSO = PublishMesh( theStudy, theMesh );
+ aMeshSO = PublishMesh( theMesh );
if ( aMeshSO->_is_nil())
return SALOMEDS::SObject::_nil();
}
}
// Find or create submesh root
- SALOMEDS::SObject_wrap aRootSO = publish (theStudy, CORBA::Object::_nil(),
- aMeshSO, aRootTag, 0, false );
+ SALOMEDS::SObject_wrap aRootSO = publish ( CORBA::Object::_nil(),
+ aMeshSO, aRootTag, 0, false );
if ( aRootSO->_is_nil() )
return aSubMeshSO._retn();
SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes();
const int isEmpty = ( elemTypes->length() == 0 );
const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" };
- aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, pm[isEmpty] );
+ aSubMeshSO = publish ( theSubMesh, aRootSO, 0, pm[isEmpty] );
if ( aSubMeshSO->_is_nil() )
return aSubMeshSO._retn();
}
// Add reference to theShapeObject
- addReference( theStudy, aSubMeshSO, theShapeObject, 1 );
+ addReference( aSubMeshSO, theShapeObject, 1 );
// Publish hypothesis
SMESH::ListOfHypothesis_var hypList = theMesh->GetHypothesisList( theShapeObject );
for ( CORBA::ULong i = 0; i < hypList->length(); i++ ) {
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]);
- SALOMEDS::SObject_wrap so = PublishHypothesis( theStudy, aHyp );
- AddHypothesisToShape( theStudy, theMesh, theShapeObject, aHyp );
+ SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp );
+ AddHypothesisToShape( theMesh, theShapeObject, aHyp );
}
return aSubMeshSO._retn();
//purpose :
//=======================================================================
-SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SMESH::SMESH_Mesh_ptr theMesh,
SMESH::SMESH_GroupBase_ptr theGroup,
GEOM::GEOM_Object_ptr theShapeObject,
const char* theName)
{
- if (theStudy->_is_nil() || theMesh->_is_nil() || theGroup->_is_nil() )
+ if (theMesh->_is_nil() || theGroup->_is_nil() )
return SALOMEDS::SObject::_nil();
- SALOMEDS::SObject_wrap aGroupSO = ObjectToSObject( theStudy, theGroup );
+ SALOMEDS::SObject_wrap aGroupSO = ObjectToSObject( theGroup );
if ( aGroupSO->_is_nil() )
{
- SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theStudy, theMesh );
+ SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theMesh );
if ( aMeshSO->_is_nil() ) {
- aMeshSO = PublishInStudy( theStudy, SALOMEDS::SObject::_nil(), theMesh, "");
+ aMeshSO = PublishInStudy( SALOMEDS::SObject::_nil(), theMesh, "");
if ( aMeshSO->_is_nil())
return SALOMEDS::SObject::_nil();
}
long aRootTag = GetNodeGroupsTag() + aType - 1;
// Find or create groups root
- SALOMEDS::SObject_wrap aRootSO = publish (theStudy, CORBA::Object::_nil(),
- aMeshSO, aRootTag, 0, false );
+ SALOMEDS::SObject_wrap aRootSO = publish ( CORBA::Object::_nil(),
+ aMeshSO, aRootTag, 0, false );
if ( aRootSO->_is_nil() ) return SALOMEDS::SObject::_nil();
if ( aType < sizeof(aRootNames)/sizeof(char*) )
isEmpty = ( allElemTypes[i] != theGroup->GetType() );
}
}
- aGroupSO = publish (theStudy, theGroup, aRootSO, 0, pm[isEmpty].c_str() );
+ aGroupSO = publish ( theGroup, aRootSO, 0, pm[isEmpty].c_str() );
}
if ( aGroupSO->_is_nil() )
return aGroupSO._retn();
//Add reference to geometry
if ( !theShapeObject->_is_nil() )
- addReference( theStudy, aGroupSO, theShapeObject, 1 );
+ addReference( aGroupSO, theShapeObject, 1 );
return aGroupSO._retn();
}
//=======================================================================
SALOMEDS::SObject_ptr
- SMESH_Gen_i::PublishHypothesis (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Hypothesis_ptr theHyp,
+ SMESH_Gen_i::PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
const char* theName)
{
if(MYDEBUG) MESSAGE("PublishHypothesis")
- if (theStudy->_is_nil() || theHyp->_is_nil())
+ if (theHyp->_is_nil())
return SALOMEDS::SObject::_nil();
CORBA::String_var hypType = theHyp->GetName();
- SALOMEDS::SObject_wrap aHypSO = ObjectToSObject( theStudy, theHyp );
+ SALOMEDS::SObject_wrap aHypSO = ObjectToSObject( theHyp );
if ( aHypSO->_is_nil() )
{
- SALOMEDS::SComponent_wrap father = PublishComponent( theStudy );
+ SALOMEDS::SComponent_wrap father = PublishComponent();
if ( father->_is_nil() )
return aHypSO._retn();
bool isAlgo = ( !SMESH::SMESH_Algo::_narrow( theHyp )->_is_nil() );
int aRootTag = isAlgo ? GetAlgorithmsRootTag() : GetHypothesisRootTag();
SALOMEDS::SObject_wrap aRootSO =
- publish (theStudy, CORBA::Object::_nil(),father, aRootTag,
+ publish (CORBA::Object::_nil(),father, aRootTag,
isAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO", false);
SetName( aRootSO, isAlgo ? "Algorithms" : "Hypotheses" );
string pluginName = myHypCreatorMap[ hypType.in() ]->GetModuleName();
if ( pluginName != "StdMeshers" )
aPmName = pluginName + "::" + aPmName;
- aHypSO = publish( theStudy, theHyp, aRootSO, 0, aPmName.c_str() );
+ aHypSO = publish( theHyp, aRootSO, 0, aPmName.c_str() );
}
SetName( aHypSO, theName, hypType.in() );
//=======================================================================
SALOMEDS::SObject_ptr
- SMESH_Gen_i::GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SMESH_Gen_i::GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShape)
{
if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape")
if ( !aShape.IsNull() && mesh_i && mesh_i->GetImpl().GetMeshDS() ) {
SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS();
if ( aShape.IsSame( meshDS->ShapeToMesh() ))
- aMeshOrSubMesh = ObjectToSObject( theStudy, theMesh );
+ aMeshOrSubMesh = ObjectToSObject( theMesh );
else {
int shapeID = meshDS->ShapeToIndex( aShape );
SMESH::SMESH_subMesh_var aSubMesh = mesh_i->getSubMesh(shapeID);
if ( !aSubMesh->_is_nil() )
- aMeshOrSubMesh = ObjectToSObject( theStudy, aSubMesh );
+ aMeshOrSubMesh = ObjectToSObject( aSubMesh );
}
}
if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape--END")
//purpose :
//=======================================================================
-bool SMESH_Gen_i::AddHypothesisToShape(SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+bool SMESH_Gen_i::AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShape,
SMESH::SMESH_Hypothesis_ptr theHyp)
{
if(MYDEBUG) MESSAGE("AddHypothesisToShape")
- if (theStudy->_is_nil() || theMesh->_is_nil() ||
+ if (theMesh->_is_nil() ||
theHyp->_is_nil() || (theShape->_is_nil()
&& theMesh->HasShapeToMesh()) )
return false;
- SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theStudy, theMesh );
+ SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theMesh );
if ( aMeshSO->_is_nil() )
- aMeshSO = PublishMesh( theStudy, theMesh );
- SALOMEDS::SObject_wrap aHypSO = PublishHypothesis( theStudy, theHyp );
+ aMeshSO = PublishMesh( theMesh );
+ SALOMEDS::SObject_wrap aHypSO = PublishHypothesis( theHyp );
if ( aMeshSO->_is_nil() || aHypSO->_is_nil())
return false;
// Find a mesh or submesh referring to theShape
SALOMEDS::SObject_wrap aMeshOrSubMesh =
- GetMeshOrSubmeshByShape( theStudy, theMesh, theShape );
+ GetMeshOrSubmeshByShape( theMesh, theShape );
if ( aMeshOrSubMesh->_is_nil() )
{
// publish submesh
SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS();
int shapeID = meshDS->ShapeToIndex( aShape );
SMESH::SMESH_subMesh_var aSubMesh = mesh_i->getSubMesh(shapeID);
- aMeshOrSubMesh = PublishSubMesh( theStudy, theMesh, aSubMesh, theShape );
+ aMeshOrSubMesh = PublishSubMesh( theMesh, aSubMesh, theShape );
}
if ( aMeshOrSubMesh->_is_nil() )
return false;
//Find or Create Applied Hypothesis root
bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( theHyp )->_is_nil();
SALOMEDS::SObject_wrap AHR =
- publish (theStudy, CORBA::Object::_nil(), aMeshOrSubMesh,
+ publish (CORBA::Object::_nil(), aMeshOrSubMesh,
aIsAlgo ? GetRefOnAppliedAlgorithmsTag() : GetRefOnAppliedHypothesisTag(),
aIsAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO", false);
SetName( AHR, aIsAlgo ? "Applied algorithms" : "Applied hypotheses" );
- addReference( theStudy, AHR, theHyp );
+ addReference( AHR, theHyp );
if(MYDEBUG) MESSAGE("AddHypothesisToShape--END")
return true;
//purpose :
//=======================================================================
-bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+bool SMESH_Gen_i::RemoveHypothesisFromShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShape,
SMESH::SMESH_Hypothesis_ptr theHyp)
{
- if (theStudy->_is_nil() || theMesh->_is_nil() ||
+ if (theMesh->_is_nil() ||
theHyp->_is_nil() || (theShape->_is_nil()
&& theMesh->HasShapeToMesh()))
return false;
- SALOMEDS::SObject_wrap aHypSO = ObjectToSObject( theStudy, theHyp );
+ SALOMEDS::SObject_wrap aHypSO = ObjectToSObject( theHyp );
if ( aHypSO->_is_nil() )
return false;
// Find a mesh or sub-mesh referring to theShape
SALOMEDS::SObject_wrap aMeshOrSubMesh =
- GetMeshOrSubmeshByShape( theStudy, theMesh, theShape );
+ GetMeshOrSubmeshByShape( theMesh, theShape );
if ( aMeshOrSubMesh->_is_nil() )
return false;
// Find and remove a reference to aHypSO
SALOMEDS::SObject_wrap aRef, anObj;
- SALOMEDS::ChildIterator_wrap it = theStudy->NewChildIterator( aMeshOrSubMesh );
+ SALOMEDS::ChildIterator_wrap it = getStudyServant()->NewChildIterator( aMeshOrSubMesh );
bool found = false;
for ( it->InitEx( true ); ( it->More() && !found ); it->Next() ) {
anObj = it->Value();
}
if ( found )
{
- SALOMEDS::StudyBuilder_var builder = theStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var builder = getStudyServant()->NewBuilder();
builder->RemoveObject( anObj );
}
}
* \brief Stores names of variables that WILL be passes as parameters when calling
* some method of a given object.
* \param [in] theObject - the object whose a method WILL be called with \a theParameters.
- * \param [in] theParameters - a string contating parameters separated by ':'.
+ * \param [in] theParameters - a string containing parameters separated by ':'.
*/
//================================================================================
void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
{
- SALOMEDS::Study_var aStudy = GetCurrentStudy();
- if ( aStudy->_is_nil() )
- return;
-
// find variable names within theParameters
myLastObj.clear();
if ( prevPos < pos )
{
string val( theParameters + prevPos, theParameters + pos );
- if ( !aStudy->IsVariable( val.c_str() ))
+ if ( !getStudyServant()->IsVariable( val.c_str() ))
val.clear();
myLastParameters.push_back( val );
nbVars += (! myLastParameters.back().empty() );
// (2) indices of found variables in myLastParamIndex.
// remember theObject
- SALOMEDS::SObject_wrap aSObj = ObjectToSObject(aStudy,theObject);
+ SALOMEDS::SObject_wrap aSObj = ObjectToSObject(theObject);
if ( aSObj->_is_nil() )
return;
CORBA::String_var anObjEntry = aSObj->GetID();
myLastObj = anObjEntry.in();
// get a string of variable names
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
SALOMEDS::GenericAttribute_wrap anAttr =
aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString" );
SALOMEDS::AttributeString_wrap aStringAttr = anAttr;
std::vector< std::string > SMESH_Gen_i::GetAllParameters(const std::string& theObjectEntry) const
{
std::vector< std::string > varNames;
- if ( myCurrentStudy->_is_nil() )
- return varNames;
- SALOMEDS::SObject_wrap aSObj = myCurrentStudy->FindObjectID( theObjectEntry.c_str() );
- if ( myCurrentStudy->_is_nil() )
- return varNames;
+ SALOMEDS::SObject_wrap aSObj = getStudyServant()->FindObjectID( theObjectEntry.c_str() );
// get a string of variable names
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
SALOMEDS::GenericAttribute_wrap anAttr =
aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString" );
SALOMEDS::AttributeString_wrap aStringAttr = anAttr;
// //const char* aParameters = theParameters;
// // const char* aParameters = CORBA::string_dup(theParameters);
// TCollection_AsciiString anInputParams;
-// SALOMEDS::Study_var aStudy = GetCurrentStudy();
+// SALOMEDS::Study_var aStudy = getStudyServant();
// if( !aStudy->_is_nil() ) {
// // SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(theParameters);
// // for(int j=0;j<aSections->length();j++) {
{
CORBA::String_var aResult("");
- SALOMEDS::SObject_wrap aSObj = ObjectToSObject( myCurrentStudy, theObject );
+ SALOMEDS::SObject_wrap aSObj = ObjectToSObject( theObject );
if ( !aSObj->_is_nil() )
{
SALOMEDS::GenericAttribute_wrap attr;
SMDSAbs_ElementType myPreviewType; // type to show
//!< Constructor
TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
- _isShapeToMesh = (_id =_studyId = 0);
+ _isShapeToMesh = (_id = 0);
_myMeshDS = new SMESHDS_Mesh( _id, true );
myPreviewType = previewElements;
}
//=============================================================================
/*!
* Find better splitting of the given quadrangle.
- * \param IDOfQuad ID of the quadrangle to be splitted.
+ * \param IDOfQuad ID of the quadrangle to be split.
* \param Criterion A criterion to choose a diagonal for splitting.
* \return 1 if 1-3 diagonal is better, 2 if 2-4
* diagonal is better, 0 if error occurs.
{
SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
SMESH::SMESH_Mesh_var mesh = gen->CreateEmptyMesh();
- SALOMEDS::Study_var study = gen->GetCurrentStudy();
- SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( study, mesh );
+ SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( mesh );
gen->SetName( meshSO, theMeshName, "Mesh" );
gen->SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
if ( !CORBA::is_nil( theModifiedElems ) )
aModifiedElems = theModifiedElems->GetListOfID();
else
- {
aModifiedElems = new SMESH::long_array;
- aModifiedElems->length( 0 );
- }
TPythonDump pyDump; // suppress dump by the next line
{
SMESH_TRY;
SMESH::ListOfGroups_var aListOfGroups = new SMESH::ListOfGroups();
- bool isEdgeGroup = false;
- bool isFaceGroup = false;
- bool isVolumeGroup = false;
- SMESH::SMESH_Group_var aNewEdgeGroup = myMesh_i->CreateGroup(SMESH::EDGE, "affectedEdges");
- SMESH::SMESH_Group_var aNewFaceGroup = myMesh_i->CreateGroup(SMESH::FACE, "affectedFaces");
- SMESH::SMESH_Group_var aNewVolumeGroup = myMesh_i->CreateGroup(SMESH::VOLUME, "affectedVolumes");
+ SMESH::SMESH_Group_var aNewEdgeGroup = SMESH::SMESH_Group::_nil();
+ SMESH::SMESH_Group_var aNewFaceGroup = SMESH::SMESH_Group::_nil();
+ SMESH::SMESH_Group_var aNewVolumeGroup = SMESH::SMESH_Group::_nil();
initData();
SMESHDS_Mesh* aMeshDS = getMeshDS();
TIDSortedElemSet anElems, aNodes;
- listOfGroupToSet(theElems, aMeshDS, anElems, false);
+ bool isNodeGrp = theElems.length() ? theElems[0]->GetType() == SMESH::NODE : false;
+ listOfGroupToSet(theElems, aMeshDS, anElems, isNodeGrp);
listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true);
TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape(theShape);
TIDSortedElemSet anAffected;
bool aResult = aMeshEditor.AffectedElemGroupsInRegion(anElems, aNodes, aShape, anAffected);
-
declareMeshModified( /*isReComputeSafe=*/ !aResult );
TPythonDump pyDump;
- if (aResult)
+ if ( aResult && anAffected.size() > 0 )
{
- int lg = anAffected.size();
SMESH::long_array_var volumeIds = new SMESH::long_array;
- volumeIds->length(lg);
- SMESH::long_array_var faceIds = new SMESH::long_array;
- faceIds->length(lg);
- SMESH::long_array_var edgeIds = new SMESH::long_array;
- edgeIds->length(lg);
+ SMESH::long_array_var faceIds = new SMESH::long_array;
+ SMESH::long_array_var edgeIds = new SMESH::long_array;
+ volumeIds->length( anAffected.size() );
+ faceIds ->length( anAffected.size() );
+ edgeIds ->length( anAffected.size() );
+
int ivol = 0;
int iface = 0;
int iedge = 0;
-
TIDSortedElemSet::const_iterator eIt = anAffected.begin();
for (; eIt != anAffected.end(); ++eIt)
{
const SMDS_MeshElement* anElem = *eIt;
- if (!anElem)
- continue;
int elemId = anElem->GetID();
- if (myMesh->GetElementType(elemId, true) == SMDSAbs_Volume)
- volumeIds[ivol++] = elemId;
- else if (myMesh->GetElementType(elemId, true) == SMDSAbs_Face)
- faceIds[iface++] = elemId;
- else if (myMesh->GetElementType(elemId, true) == SMDSAbs_Edge)
- edgeIds[iedge++] = elemId;
+ switch ( anElem->GetType() ) {
+ case SMDSAbs_Volume: volumeIds[ivol++] = elemId; break;
+ case SMDSAbs_Face: faceIds[iface++] = elemId; break;
+ case SMDSAbs_Edge: edgeIds[iedge++] = elemId; break;
+ default:;
+ }
}
volumeIds->length(ivol);
faceIds->length(iface);
edgeIds->length(iedge);
- aNewVolumeGroup->Add(volumeIds);
- aNewFaceGroup->Add(faceIds);
- aNewEdgeGroup->Add(edgeIds);
- isVolumeGroup = (aNewVolumeGroup->Size() > 0);
- isFaceGroup = (aNewFaceGroup->Size() > 0);
- isEdgeGroup = (aNewEdgeGroup->Size() > 0);
+ int nbGroups = 0;
+ if ( ivol > 0 )
+ {
+ aNewVolumeGroup = myMesh_i->CreateGroup(SMESH::VOLUME,
+ generateGroupName("affectedVolumes").c_str());
+ aNewVolumeGroup->Add(volumeIds);
+ aListOfGroups->length( nbGroups+1 );
+ aListOfGroups[ nbGroups++ ] = aNewVolumeGroup._retn();
+ }
+ if ( iface > 0 )
+ {
+ aNewFaceGroup = myMesh_i->CreateGroup(SMESH::FACE,
+ generateGroupName("affectedFaces").c_str());
+ aNewFaceGroup->Add(faceIds);
+ aListOfGroups->length( nbGroups+1 );
+ aListOfGroups[ nbGroups++ ] = aNewFaceGroup._retn();
+ }
+ if ( iedge > 0 )
+ {
+ aNewEdgeGroup = myMesh_i->CreateGroup(SMESH::EDGE,
+ generateGroupName("affectedEdges").c_str());
+ aNewEdgeGroup->Add(edgeIds);
+ aListOfGroups->length( nbGroups+1 );
+ aListOfGroups[ nbGroups++ ] = aNewEdgeGroup._retn();
+ }
}
- int nbGroups = 0;
- if (isEdgeGroup) nbGroups++;
- if (isFaceGroup) nbGroups++;
- if (isVolumeGroup) nbGroups++;
- aListOfGroups->length(nbGroups);
-
- int i = 0;
- if (isEdgeGroup) aListOfGroups[i++] = aNewEdgeGroup._retn();
- if (isFaceGroup) aListOfGroups[i++] = aNewFaceGroup._retn();
- if (isVolumeGroup) aListOfGroups[i++] = aNewVolumeGroup._retn();
-
// Update Python script
- pyDump << "[ ";
- if (isEdgeGroup) pyDump << aNewEdgeGroup << ", ";
- if (isFaceGroup) pyDump << aNewFaceGroup << ", ";
- if (isVolumeGroup) pyDump << aNewVolumeGroup << ", ";
- pyDump << "] = ";
- pyDump << this << ".AffectedElemGroupsInRegion( "
+ pyDump << aListOfGroups << " = " << this << ".AffectedElemGroupsInRegion( "
<< &theElems << ", " << &theNodesNot << ", " << theShape << " )";
return aListOfGroups._retn();
//================================================================================
/*!
\brief Generated skin mesh (containing 2D cells) from 3D mesh
- The created 2D mesh elements based on nodes of free faces of boundary volumes
+ The created 2D mesh elements based on nodes of free faces of boundary volumes
\return TRUE if operation has been completed successfully, FALSE otherwise
*/
//================================================================================
//=============================================================================
SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
- SMESH_Gen_i* gen_i,
- CORBA::Long studyId )
+ SMESH_Gen_i* gen_i )
: SALOME::GenericObj_i( thePOA )
{
_impl = NULL;
_gen_i = gen_i;
_id = _idGenerator++;
- _studyId = studyId;
_editor = NULL;
_previewEditor = NULL;
_preMeshInfo = NULL;
for ( ; data != _geomGroupData.end(); ++data )
if ( data->_smeshObject->_is_equivalent( _this() ))
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- if ( study->_is_nil() ) break;
- SALOMEDS::SObject_wrap so = study->FindObjectID( data->_groupEntry.c_str() );
+ SALOMEDS::SObject_wrap so = SMESH_Gen_i::getStudyServant()->FindObjectID( data->_groupEntry.c_str() );
CORBA::Object_var obj = _gen_i->SObjectToObject( so );
aShapeObj = GEOM::GEOM_Object::_narrow( obj );
break;
CreateGroupServants();
int major, minor, release;
- if( !MED::getMEDVersion( theFileName, major, minor, release ) )
- major = minor = release = -1;
+ major = minor = release = 0;
+ MED::GetMEDVersion(theFileName, major, minor, release);
_medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = theFileName;
_medFileInfo->fileSize = 0;
return ConvertDriverMEDReadStatus(status);
}
-//================================================================================
-/*!
- * \brief Return string representation of a MED file version comprising nbDigits
- */
-//================================================================================
-
-char* SMESH_Mesh_i::GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits)
-{
- string ver = DriverMED_W_SMESHDS_Mesh::GetVersionString(MED::EVersion(version),
- nbDigits);
- return CORBA::string_dup( ver.c_str() );
-}
-
//=============================================================================
/*!
* ImportUNVFile
std::string name = _impl->STLToMesh( theFileName );
if ( !name.empty() )
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( study, _this() );
+ SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( _this() );
_gen_i->SetName( meshSO, name.c_str() );
}
SMESH::SMESH_Mesh_var mesh( _this() );
if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- _gen_i->AddHypothesisToShape( study, mesh, aSubShape, anHyp );
+ _gen_i->AddHypothesisToShape( mesh, aSubShape, anHyp );
}
if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- _gen_i->RemoveHypothesisFromShape( study, mesh, aSubShape, anHyp );
+ _gen_i->RemoveHypothesisFromShape( mesh, aSubShape, anHyp );
}
// Update Python script
if(_impl->HasShapeToMesh())
subMesh = createSubMesh( aSubShape );
if ( _gen_i->CanPublishInStudy( subMesh ))
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishSubMesh( study, aMesh, subMesh, aSubShape, theName );
+ _gen_i->PublishSubMesh( aMesh, subMesh, aSubShape, theName );
if ( !aSO->_is_nil()) {
// Update Python script
TPythonDump() << aSO << " = " << aMesh << ".GetSubMesh( "
return;
GEOM::GEOM_Object_var aSubShape;
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- // Remove submesh's SObject
- SALOMEDS::SObject_wrap anSO = _gen_i->ObjectToSObject( aStudy, theSubMesh );
- if ( !anSO->_is_nil() ) {
- long aTag = SMESH_Gen_i::GetRefOnShapeTag();
- SALOMEDS::SObject_wrap anObj, aRef;
- if ( anSO->FindSubObject( aTag, anObj.inout() ) &&
- anObj->ReferencedObject( aRef.inout() ))
- {
- CORBA::Object_var obj = aRef->GetObject();
- aSubShape = GEOM::GEOM_Object::_narrow( obj );
- }
- // if ( aSubShape->_is_nil() ) // not published shape (IPAL13617)
- // aSubShape = theSubMesh->GetSubShape();
+ // Remove submesh's SObject
+ SALOMEDS::SObject_wrap anSO = _gen_i->ObjectToSObject( theSubMesh );
+ if ( !anSO->_is_nil() ) {
+ long aTag = SMESH_Gen_i::GetRefOnShapeTag();
+ SALOMEDS::SObject_wrap anObj, aRef;
+ if ( anSO->FindSubObject( aTag, anObj.inout() ) &&
+ anObj->ReferencedObject( aRef.inout() ))
+ {
+ CORBA::Object_var obj = aRef->GetObject();
+ aSubShape = GEOM::GEOM_Object::_narrow( obj );
+ }
+ // if ( aSubShape->_is_nil() ) // not published shape (IPAL13617)
+ // aSubShape = theSubMesh->GetSubShape();
- SALOMEDS::StudyBuilder_var builder = aStudy->NewBuilder();
- builder->RemoveObjectWithChildren( anSO );
+ SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
+ builder->RemoveObjectWithChildren( anSO );
- // Update Python script
- TPythonDump() << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )";
- }
+ // Update Python script
+ TPythonDump() << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )";
}
if ( removeSubMesh( theSubMesh, aSubShape.in() ))
if ( _gen_i->CanPublishInStudy( aNewGroup ) )
{
SMESH::SMESH_Mesh_var mesh = _this();
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishGroup( study, mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName);
+ _gen_i->PublishGroup( mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName);
if ( !aSO->_is_nil())
// Update Python script
TPythonDump() << aSO << " = " << mesh << ".CreateGroup( "
if ( _gen_i->CanPublishInStudy( aNewGroup ) )
{
SMESH::SMESH_Mesh_var mesh = _this();
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishGroup( study, mesh, aNewGroup, theGeomObj, theName );
+ _gen_i->PublishGroup( mesh, aNewGroup, theGeomObj, theName );
if ( !aSO->_is_nil())
TPythonDump() << aSO << " = " << mesh << ".CreateGroupFromGEOM( "
<< theElemType << ", '" << theName << "', " << theGeomObj << " )";
if ( _gen_i->CanPublishInStudy( aNewGroup ) )
{
SMESH::SMESH_Mesh_var mesh = _this();
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishGroup( study, mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName );
+ _gen_i->PublishGroup( mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName );
if ( !aSO->_is_nil())
pd << aSO << " = " << mesh << ".CreateGroupFromFilter( "
if ( !aGroup )
return;
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( !aStudy->_is_nil() )
+ SALOMEDS::SObject_wrap aGroupSO = _gen_i->ObjectToSObject( theGroup );
+ if ( !aGroupSO->_is_nil() )
{
- SALOMEDS::SObject_wrap aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
- if ( !aGroupSO->_is_nil() )
- {
- // Update Python script
- TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
+ // Update Python script
+ TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
- // Remove group's SObject
- SALOMEDS::StudyBuilder_var builder = aStudy->NewBuilder();
- builder->RemoveObjectWithChildren( aGroupSO );
- }
+ // Remove group's SObject
+ SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
+ builder->RemoveObjectWithChildren( aGroupSO );
}
aGroup->Modified(/*removed=*/true); // notify dependent Filter with FT_BelongToMeshGroup criterion
if ( CORBA::is_nil( theGeomObj ) || theGeomObj->GetType() != GEOM_GROUP )
return;
// group SO
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( study, theGeomObj );
+ SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( theGeomObj );
if ( groupSO->_is_nil() )
return;
// group indices
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine();
GEOM::GEOM_IGroupOperations_wrap groupOp =
- geomGen->GetIGroupOperations( _gen_i->GetCurrentStudyID() );
+ geomGen->GetIGroupOperations();
GEOM::ListOfLong_var ids = groupOp->GetObjects( theGeomObj );
// store data
TopoDS_Shape newShape;
// get geom group
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- if ( study->_is_nil() ) return newShape; // means "not changed"
- SALOMEDS::SObject_wrap groupSO = study->FindObjectID( groupData._groupEntry.c_str() );
+ SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( groupData._groupEntry.c_str() );
if ( !groupSO->_is_nil() )
{
CORBA::Object_var groupObj = _gen_i->SObjectToObject( groupSO );
set<int> curIndices;
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine();
GEOM::GEOM_IGroupOperations_wrap groupOp =
- geomGen->GetIGroupOperations( _gen_i->GetCurrentStudyID() );
+ geomGen->GetIGroupOperations();
GEOM::ListOfLong_var ids = groupOp->GetObjects( geomGroup );
for ( CORBA::ULong i = 0; i < ids->length(); ++i )
curIndices.insert( ids[i] );
{
if ( !_impl->HasShapeToMesh() ) return;
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- if ( study->_is_nil() ) return;
-
GEOM::GEOM_Object_var mainGO = _gen_i->ShapeToGeomObject( _impl->GetShapeToMesh() );
//if ( mainGO->_is_nil() ) return;
{
if ( !_impl->HasShapeToMesh() ) return;
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- if ( study->_is_nil() ) return;
-
CORBA::Long nbEntities = NbNodes() + NbElements();
// Check if group contents changed
if ( _mapGroups.find( oldID ) == _mapGroups.end() )
continue;
// get group name
- SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( study,_mapGroups[oldID] );
+ SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( _mapGroups[oldID] );
CORBA::String_var name = groupSO->GetName();
// update
SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>(_mapGroups[oldID] );
if ( newNbEntities != nbEntities )
{
// Add all SObjects with icons to soToUpdateIcons
- soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, _this() )); // mesh
+ soToUpdateIcons.push_back( _gen_i->ObjectToSObject( _this() )); // mesh
for (map<int, SMESH::SMESH_subMesh_ptr>::iterator i_sm = _mapSubMeshIor.begin();
i_sm != _mapSubMeshIor.end(); ++i_sm ) // submeshes
- soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, i_sm->second ));
+ soToUpdateIcons.push_back( _gen_i->ObjectToSObject( i_sm->second ));
for ( map<int, SMESH::SMESH_GroupBase_ptr>::iterator i_gr = _mapGroups.begin();
i_gr != _mapGroups.end(); ++i_gr ) // groups
- soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, i_gr->second ));
+ soToUpdateIcons.push_back( _gen_i->ObjectToSObject( i_gr->second ));
}
list< SALOMEDS::SObject_wrap >::iterator so = soToUpdateIcons.begin();
SALOMEDS::StudyBuilder_var builder;
SALOMEDS::SObject_wrap aGroupSO;
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
+ SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
if ( !aStudy->_is_nil() ) {
builder = aStudy->NewBuilder();
- aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
+ aGroupSO = _gen_i->ObjectToSObject( theGroup );
if ( !aGroupSO->_is_nil() )
{
// remove reference to geometry
return _id;
}
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception)
-{
- return _studyId;
-}
-
//=============================================================================
namespace
{
// Perform Export
PrepareForWriting(file, overwrite);
string aMeshName = "Mesh";
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
+ SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( aStudy, _this() );
+ SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( _this() );
if ( !aMeshSO->_is_nil() ) {
CORBA::String_var name = aMeshSO->GetName();
aMeshName = name;
//================================================================================
/*!
- * \brief Export to med file
+ * \brief Export to MED file
*/
//================================================================================
-void SMESH_Mesh_i::ExportToMEDX (const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION theVersion,
- CORBA::Boolean overwrite,
- CORBA::Boolean autoDimension)
+void SMESH_Mesh_i::ExportMED(const char* file,
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean overwrite,
+ CORBA::Boolean autoDimension)
throw(SALOME::SALOME_Exception)
{
//MESSAGE("SMESH::MED_VERSION:"<< theVersion);
_preMeshInfo->FullLoadFromFile();
string aMeshName = prepareMeshNameAndGroups(file, overwrite);
- _impl->ExportMED( file, aMeshName.c_str(), auto_groups, theVersion, 0, autoDimension );
+ _impl->ExportMED( file, aMeshName.c_str(), auto_groups, 0, autoDimension );
- TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportToMEDX( r'"
+ TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
<< file << "', " << auto_groups << ", "
- << theVersion << ", " << overwrite << ", "
+ << overwrite << ", "
<< autoDimension << " )";
SMESH_CATCH( SMESH::throwCorbaException );
}
-//================================================================================
-/*!
- * \brief Export a mesh to a med file
- */
-//================================================================================
-
-void SMESH_Mesh_i::ExportToMED (const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION theVersion)
- throw(SALOME::SALOME_Exception)
-{
- //MESSAGE("SMESH::MED_VERSION:"<< theVersion);
- ExportToMEDX(file,auto_groups,theVersion,true);
-}
-
-//================================================================================
-/*!
- * \brief Export a mesh to a med file
- */
-//================================================================================
-
-void SMESH_Mesh_i::ExportMED (const char* file,
- CORBA::Boolean auto_groups)
- throw(SALOME::SALOME_Exception)
-{
- //MESSAGE("SMESH::MED_VERSION:"<< SMESH::MED_LATEST);
- ExportToMEDX(file,auto_groups,SMESH::MED_LATEST,true);
-}
-
//================================================================================
/*!
* \brief Export a mesh to a SAUV file
<< ".ExportSTL( r'" << file << "', " << isascii << " )";
CORBA::String_var name;
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, _this() );
+ SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( _this() );
if ( !so->_is_nil() )
name = so->GetName();
void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version,
CORBA::Boolean overwrite,
CORBA::Boolean autoDimension,
const GEOM::ListOfFields& fields,
{
aMeshName = prepareMeshNameAndGroups(file, overwrite);
_impl->ExportMED( file, aMeshName.c_str(), auto_groups,
- version, 0, autoDimension, /*addODOnVertices=*/have0dField);
+ 0, autoDimension, /*addODOnVertices=*/have0dField);
meshDS = _impl->GetMeshDS();
}
else
PrepareForWriting(file, overwrite);
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( aStudy, meshPart );
- if ( !SO->_is_nil() ) {
- CORBA::String_var name = SO->GetName();
- aMeshName = name;
- }
+ SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( meshPart );
+ if ( !SO->_is_nil() ) {
+ CORBA::String_var name = SO->GetName();
+ aMeshName = name;
}
+
SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart );
_impl->ExportMED( file, aMeshName.c_str(), auto_groups,
- version, partDS, autoDimension, /*addODOnVertices=*/have0dField);
+ partDS, autoDimension, /*addODOnVertices=*/have0dField);
meshDS = tmpDSDeleter._obj = partDS;
}
}
TPythonDump() << _this() << ".ExportPartToMED( "
<< meshPart << ", r'" << file << "', "
- << auto_groups << ", " << version << ", " << overwrite << ", "
+ << auto_groups << ", " << overwrite << ", "
<< autoDimension << ", " << goList
<< ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
PrepareForWriting(file);
CORBA::String_var name;
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, meshPart );
+ SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( meshPart );
if ( !so->_is_nil() )
name = so->GetName();
PrepareForWriting(file,overwrite);
std::string meshName("");
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, meshPart );
+ SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( meshPart );
if ( !so->_is_nil() )
{
CORBA::String_var name = so->GetName();
groups[ ++iG ] = createGroup( SMESH::ElementType(i), theGroupName );
if ( _gen_i->CanPublishInStudy( groups[ iG ] ))
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SMESH::SMESH_Mesh_var mesh = _this();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishGroup( study, mesh, groups[ iG ],
+ _gen_i->PublishGroup( mesh, groups[ iG ],
GEOM::GEOM_Object::_nil(), theGroupName);
}
SMESH_GroupBase_i* grp_i = SMESH::DownCast< SMESH_GroupBase_i* >( groups[ iG ]);
void SMESH_Mesh_i::CreateGroupServants()
{
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
SMESH::SMESH_Mesh_var aMesh = _this();
set<int> addedIDs;
else { nextId = 0; } // avoid "unused variable" warning in release mode
// publishing the groups in the study
- if ( !aStudy->_is_nil() ) {
- GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape );
- _gen_i->PublishGroup( aStudy, aMesh, groupVar, shapeVar, group->GetName());
- }
+ GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape );
+ _gen_i->PublishGroup( aMesh, groupVar, shapeVar, group->GetName());
}
if ( !addedIDs.empty() )
{
int nbGrp = NbGroups();
if ( !nbGrp )
return;
-
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( aStudy->_is_nil() )
- return; // nothing to do
SMESH::ListOfGroups* grpList = 0;
// avoid dump of "GetGroups"
SMESH::SMESH_GroupBase_ptr aGrp = (*grpList)[ gIndx ];
if ( !aGrp )
continue;
- SALOMEDS::SObject_wrap aGrpSO = _gen_i->ObjectToSObject( aStudy, aGrp );
+ SALOMEDS::SObject_wrap aGrpSO = _gen_i->ObjectToSObject( aGrp );
if ( aGrpSO->_is_nil() )
continue;
// correct name of the mesh group if necessary
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
if(gen) {
CORBA::String_var aParameters = GetParameters();
- SALOMEDS::Study_var aStudy = gen->GetCurrentStudy();
- if ( !aStudy->_is_nil()) {
- SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
- if ( aSections->length() > 0 ) {
- SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
- aResult->length( aVars.length() );
- for ( CORBA::ULong i = 0;i < aVars.length(); i++ )
- aResult[i] = CORBA::string_dup( aVars[i] );
- }
+ SALOMEDS::ListOfListOfStrings_var aSections = SMESH_Gen_i::getStudyServant()->ParseVariables(aParameters);
+ if ( aSections->length() > 0 ) {
+ SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
+ aResult->length( aVars.length() );
+ for ( CORBA::ULong i = 0;i < aVars.length(); i++ )
+ aResult[i] = CORBA::string_dup( aVars[i] );
}
}
return aResult._retn();
//-----------------------------------------------------------------------------
/*!
- * \brief Internal structure used to find concurent submeshes
+ * \brief Internal structure used to find concurrent submeshes
*
- * It represents a pair < submesh, concurent dimension >, where
- * 'concurrent dimension' is dimension of shape where the submesh can concurent
+ * It represents a pair < submesh, concurrent dimension >, where
+ * 'concurrent dimension' is dimension of shape where the submesh can concurrent
* with another submesh. In other words, it is dimension of a hypothesis assigned
* to submesh.
*/
removeDimHyps(dimHypListArr);
- // now, minimise the number of concurrent groups
+ // now, minimize the number of concurrent groups
// Here we assume that lists of submeshes can have same submesh
// in case of multi-dimension algorithms, as result
// list with common submesh has to be united into one list
continue;
if ( theIsDump )
aPythonDump << "[ ";
- // convert shape indeces into interfaces
+ // convert shape indices into interfaces
SMESH::submesh_array_var aResSubSet = new SMESH::submesh_array();
aResSubSet->length(aSubOrder.size());
TListOfInt::const_iterator subIt = aSubOrder.begin();
--- /dev/null
- char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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, 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
+//
+// File : SMESH_DumpPython.cxx
+// Created : Thu Mar 24 17:17:59 2005
+// Author : Julia DOROVSKIKH
+// Module : SMESH
+
+#include "SMESH_PythonDump.hxx"
+
+#include "SMESH_2smeshpy.hxx"
+#include "SMESH_Comment.hxx"
+#include "SMESH_Filter_i.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_MeshEditor_i.hxx"
+
+#include <SALOMEDS_wrap.hxx>
+
+#include <LDOMParser.hxx>
+#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+#include "SMESH_TryCatch.hxx"
+
+namespace SMESH
+{
+
+ size_t TPythonDump::myCounter = 0;
+ const char theNotPublishedObjectName[] = "__NOT__Published__Object__";
+
+ TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Long value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Short value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(const SMESH::double_array& value):myVals(value.length()), myIsList(true)
+ {
+ for ( size_t i = 0; i < value.length(); i++)
+ myVals[i] = SMESH_Comment(value[i]);
+ }
+
+ TPythonDump::
+ TPythonDump():myVarsCounter(0)
+ {
+ ++myCounter;
+ }
+ TPythonDump::
+ ~TPythonDump()
+ {
+ if(--myCounter == 0){
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ std::string aString = myStream.str();
+ TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
+ if(!aCollection.IsEmpty())
+ {
+ const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
+ if ( !objEntry.empty() )
+ aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
+ aSMESHGen->AddToPythonScript(aCollection);
+ if(MYDEBUG) MESSAGE(aString);
+ // prevent misuse of already treated variables
+ aSMESHGen->UpdateParameters(CORBA::Object_var().in(),"");
+ }
+ }
+ }
+
+ TPythonDump& //!< store a variable value. Write either a value or '$varID$'
+ TPythonDump::
+ operator<<(const TVar& theVarValue)
+ {
+ const std::vector< int >& varIDs = SMESH_Gen_i::GetSMESHGen()->GetLastParamIndices();
+ if ( theVarValue.myIsList )
+ {
+ myStream << "[ ";
+ for ( size_t i = 1; i <= theVarValue.myVals.size(); ++i )
+ {
+ if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
+ myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
+ else
+ myStream << theVarValue.myVals[i-1];
+ if ( i < theVarValue.myVals.size() )
+ myStream << ", ";
+ ++myVarsCounter;
+ }
+ myStream << " ]";
+ }
+ else
+ {
+ if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
+ myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
+ else
+ myStream << theVarValue.myVals[0];
+ ++myVarsCounter;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(long int theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(int theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(double theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(float theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const void* theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const char* theArg){
+ if ( theArg )
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const std::string& theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::ElementType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case ALL: myStream<<"ALL"; break;
+ case NODE: myStream<<"NODE"; break;
+ case EDGE: myStream<<"EDGE"; break;
+ case FACE: myStream<<"FACE"; break;
+ case VOLUME: myStream<<"VOLUME"; break;
+ case ELEM0D: myStream<<"ELEM0D"; break;
+ case BALL: myStream<<"BALL"; break;
+ default: myStream<<"__UNKNOWN__ElementType: " << theArg;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::GeometryType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case Geom_POINT: myStream<<"Geom_POINT"; break;
+ case Geom_EDGE: myStream<<"Geom_EDGE"; break;
+ case Geom_TRIANGLE: myStream<<"Geom_TRIANGLE"; break;
+ case Geom_QUADRANGLE: myStream<<"Geom_QUADRANGLE"; break;
+ case Geom_POLYGON: myStream<<"Geom_POLYGON"; break;
+ case Geom_TETRA: myStream<<"Geom_TETRA"; break;
+ case Geom_PYRAMID: myStream<<"Geom_PYRAMID"; break;
+ case Geom_HEXA: myStream<<"Geom_HEXA"; break;
+ case Geom_PENTA: myStream<<"Geom_PENTA"; break;
+ case Geom_POLYHEDRA: myStream<<"Geom_POLYHEDRA"; break;
+ case Geom_BALL: myStream<<"Geom_BALL"; break;
+ default: myStream<<"__UNKNOWN__GeometryType: " << theArg;
+ }
+ return *this;
+ }
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::EntityType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case Entity_0D: myStream<<"Entity_0D"; break;
+ case Entity_Edge: myStream<<"Entity_Edge"; break;
+ case Entity_Quad_Edge: myStream<<"Entity_Quad_Edge"; break;
+ case Entity_Triangle: myStream<<"Entity_Triangle"; break;
+ case Entity_Quad_Triangle: myStream<<"Entity_Quad_Triangle"; break;
+ case Entity_BiQuad_Triangle: myStream<<"Entity_BiQuad_Triangle"; break;
+ case Entity_Quadrangle: myStream<<"Entity_Quadrangle"; break;
+ case Entity_Quad_Quadrangle: myStream<<"Entity_Quad_Quadrangle"; break;
+ case Entity_BiQuad_Quadrangle: myStream<<"Entity_BiQuad_Quadrangle"; break;
+ case Entity_Polygon: myStream<<"Entity_Polygon"; break;
+ case Entity_Quad_Polygon: myStream<<"Entity_Quad_Polygon"; break;
+ case Entity_Tetra: myStream<<"Entity_Tetra"; break;
+ case Entity_Quad_Tetra: myStream<<"Entity_Quad_Tetra"; break;
+ case Entity_Pyramid: myStream<<"Entity_Pyramid"; break;
+ case Entity_Quad_Pyramid: myStream<<"Entity_Quad_Pyramid"; break;
+ case Entity_Hexa: myStream<<"Entity_Hexa"; break;
+ case Entity_Quad_Hexa: myStream<<"Entity_Quad_Hexa"; break;
+ case Entity_TriQuad_Hexa: myStream<<"Entity_TriQuad_Hexa"; break;
+ case Entity_Penta: myStream<<"Entity_Penta"; break;
+ case Entity_Quad_Penta: myStream<<"Entity_Quad_Penta"; break;
+ case Entity_BiQuad_Penta: myStream<<"Entity_BiQuad_Penta"; break;
+ case Entity_Hexagonal_Prism: myStream<<"Entity_Hexagonal_Prism"; break;
+ case Entity_Polyhedra: myStream<<"Entity_Polyhedra"; break;
+ case Entity_Quad_Polyhedra: myStream<<"Entity_Quad_Polyhedra"; break;
+ case Entity_Ball: myStream<<"Entity_Ball"; break;
+ case Entity_Last: myStream<<"Entity_Last"; break;
+ default: myStream<<"__UNKNOWN__EntityType: " << theArg;
+ }
+ return *this;
+ }
+
+ template<class TArray>
+ void DumpArray(const TArray& theArray, TPythonDump & theStream)
+ {
+ if ( theArray.length() == 0 )
+ {
+ theStream << "[]";
+ }
+ else
+ {
+ theStream << "[ ";
+ for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
+ theStream << theArray[i-1];
+ if ( i < theArray.length() )
+ theStream << ", ";
+ }
+ theStream << " ]";
+ }
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::long_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::double_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::nodes_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::string_array& theArray)
+ {
+ myStream << "[ ";
+ for ( CORBA::ULong i = 1; i <= theArray.length(); i++ ) {
+ myStream << "'" << theArray[i-1] << "'";
+ if ( i < theArray.length() )
+ myStream << ", ";
+ }
+ myStream << " ]";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SALOMEDS::SObject_ptr aSObject)
+ {
+ if ( !aSObject->_is_nil() ) {
+ CORBA::String_var entry = aSObject->GetID();
+ myStream << entry.in();
+ }
+ else {
+ myStream << theNotPublishedObjectName;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(CORBA::Object_ptr theArg)
+ {
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(!aSObject->_is_nil()) {
+ CORBA::String_var id = aSObject->GetID();
+ myStream << id;
+ } else if ( !CORBA::is_nil(theArg)) {
+ if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object
+ myStream << "smeshObj_" << size_t(theArg);
+ else
+ myStream << theNotPublishedObjectName;
+ }
+ else
+ myStream << "None";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
+ {
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
+ myStream << "hyp_" << theArg->GetId();
+ else
+ *this << aSObject;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::SMESH_IDSource_ptr theArg)
+ {
+ if ( CORBA::is_nil( theArg ) )
+ return *this << "None";
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(!aSObject->_is_nil())
+ {
+ return *this << aSObject;
+ }
+ if ( SMESH::Filter_i* filter = SMESH::DownCast<SMESH::Filter_i*>( theArg ))
+ {
+ return *this << filter;
+ }
+ if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theArg ))
+ {
+ SMESH::SMESH_Mesh_var mesh = theArg->GetMesh();
+ SMESH::long_array_var anElementsId = theArg->GetIDs();
+ SMESH::array_of_ElementType_var types = theArg->GetTypes();
+ SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
+ SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(mesh);
+ if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
+ return *this << mesh << ".GetIDSource([], " << type << ")";
+ else
+ return *this << mesh << ".GetIDSource(" << anElementsId << ", " << type << ")";
+ }
+ return *this << theNotPublishedObjectName;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::FilterLibrary_i* theArg)
+ {
+ myStream<<"aFilterLibrary"<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::FilterManager_i* theArg)
+ {
+ myStream<<"aFilterManager";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Filter_i* theArg)
+ {
+ myStream<<"aFilter"<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Functor_i* theArg)
+ {
+ if ( theArg ) {
+ FunctorType aFunctorType = theArg->GetFunctorType();
+ switch(aFunctorType) {
+ case FT_AspectRatio: myStream<< "aAspectRatio"; break;
+ case FT_AspectRatio3D: myStream<< "aAspectRatio3D"; break;
+ case FT_Warping: myStream<< "aWarping"; break;
+ case FT_MinimumAngle: myStream<< "aMinimumAngle"; break;
+ case FT_Taper: myStream<< "aTaper"; break;
+ case FT_Skew: myStream<< "aSkew"; break;
+ case FT_Area: myStream<< "aArea"; break;
+ case FT_Volume3D: myStream<< "aVolume3D"; break;
+ case FT_MaxElementLength2D: myStream<< "aMaxElementLength2D"; break;
+ case FT_MaxElementLength3D: myStream<< "aMaxElementLength3D"; break;
+ case FT_FreeBorders: myStream<< "aFreeBorders"; break;
+ case FT_FreeEdges: myStream<< "aFreeEdges"; break;
+ case FT_FreeNodes: myStream<< "aFreeNodes"; break;
+ case FT_FreeFaces: myStream<< "aFreeFaces"; break;
+ case FT_EqualNodes: myStream<< "aEqualNodes"; break;
+ case FT_EqualEdges: myStream<< "aEqualEdges"; break;
+ case FT_EqualFaces: myStream<< "aEqualFaces"; break;
+ case FT_EqualVolumes: myStream<< "aEqualVolumes"; break;
+ case FT_MultiConnection: myStream<< "aMultiConnection"; break;
+ case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break;
+ case FT_Length: myStream<< "aLength"; break;
+ case FT_Length2D: myStream<< "aLength2D"; break;
+ case FT_Deflection2D: myStream<< "aDeflection2D"; break;
+ case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
+ case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break;
+ case FT_BelongToGeom: myStream<< "aBelongToGeom"; break;
+ case FT_BelongToPlane: myStream<< "aBelongToPlane"; break;
+ case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
+ case FT_BelongToGenSurface: myStream<< "aBelongToGenSurface"; break;
+ case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break;
+ case FT_RangeOfIds: myStream<< "aRangeOfIds"; break;
+ case FT_BadOrientedVolume: myStream<< "aBadOrientedVolume"; break;
+ case FT_BareBorderVolume: myStream<< "aBareBorderVolume"; break;
+ case FT_BareBorderFace: myStream<< "aBareBorderFace"; break;
+ case FT_OverConstrainedVolume: myStream<< "aOverConstrainedVolume"; break;
+ case FT_OverConstrainedFace: myStream<< "aOverConstrainedFace"; break;
+ case FT_LinearOrQuadratic: myStream<< "aLinearOrQuadratic"; break;
+ case FT_GroupColor: myStream<< "aGroupColor"; break;
+ case FT_ElemGeomType: myStream<< "aElemGeomType"; break;
+ case FT_EntityType: myStream<< "aEntityType"; break;
+ case FT_CoplanarFaces: myStream<< "aCoplanarFaces"; break;
+ case FT_BallDiameter: myStream<< "aBallDiameter"; break;
+ case FT_ConnectedElements: myStream<< "aConnectedElements"; break;
+ case FT_LessThan: myStream<< "aLessThan"; break;
+ case FT_MoreThan: myStream<< "aMoreThan"; break;
+ case FT_EqualTo: myStream<< "aEqualTo"; break;
+ case FT_LogicalNOT: myStream<< "aLogicalNOT"; break;
+ case FT_LogicalAND: myStream<< "aLogicalAND"; break;
+ case FT_LogicalOR: myStream<< "aLogicalOR"; break;
+ case FT_Undefined: myStream<< "anUndefined"; break;
+ //default: -- commented to have a compilation warning
+ }
+ myStream<<theArg;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Measurements_i* theArg)
+ {
+ myStream<<"aMeasurements";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
+ {
+ myStream << SMESHGenName(); return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(SMESH_MeshEditor_i* theArg)
+ {
+ myStream << MeshEditorName() << "_" << ( theArg ? theArg->GetMeshId() : -1 ); return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const TCollection_AsciiString & theStr)
+ {
+ myStream << theStr; return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::AxisStruct & theAxis)
+ {
+ *this << "SMESH.AxisStruct( "
+ << TVar( theAxis.x ) << ", "
+ << TVar( theAxis.y ) << ", "
+ << TVar( theAxis.z ) << ", "
+ << TVar( theAxis.vx ) << ", "
+ << TVar( theAxis.vy ) << ", "
+ << TVar( theAxis.vz ) << " )";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::DirStruct & theDir)
+ {
+ const SMESH::PointStruct & P = theDir.PS;
+ *this << "SMESH.DirStruct( SMESH.PointStruct ( "
+ << TVar( P.x ) << ", "
+ << TVar( P.y ) << ", "
+ << TVar( P.z ) << " ))";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::PointStruct & P)
+ {
+ *this << "SMESH.PointStruct ( "
+ << TVar( P.x ) << ", "
+ << TVar( P.y ) << ", "
+ << TVar( P.z ) << " )";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups * theList)
+ {
+ DumpArray( *theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGO& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGBO& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfIDSources& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
+ {
+ // dump CoincidentFreeBorders as a list of lists, each enclosed list
+ // contains node IDs of a group of coincident free borders where
+ // each consequent triple of IDs describe a free border: (n1, n2, nLast)
+ // For example [[1, 2, 10, 20, 21, 40], [11, 12, 15, 55, 54, 41]] describes
+ // two groups of coincident free borders, each group including two borders
+
+ myStream << "[";
+ for ( CORBA::ULong i = 0; i < theCFB.coincidentGroups.length(); ++i )
+ {
+ const SMESH::FreeBordersGroup& aGRP = theCFB.coincidentGroups[ i ];
+ if ( i ) myStream << ",";
+ myStream << "[";
+ for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
+ {
+ const SMESH::FreeBorderPart& aPART = aGRP[ iP ];
+ if ( 0 <= aPART.border && aPART.border < (CORBA::Long)theCFB.borders.length() )
+ {
+ if ( iP ) myStream << ", ";
+ const SMESH::FreeBorder& aBRD = theCFB.borders[ aPART.border ];
+ myStream << aBRD.nodeIDs[ aPART.node1 ] << ",";
+ myStream << aBRD.nodeIDs[ aPART.node2 ] << ",";
+ myStream << aBRD.nodeIDs[ aPART.nodeLast ];
+ }
+ }
+ myStream << "]";
+ }
+ myStream << "]";
+
+ return *this;
+ }
+
+ const char* TPythonDump::NotPublishedObjectName()
+ {
+ return theNotPublishedObjectName;
+ }
+
+ TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
+ TCollection_AsciiString myLongStringEnd ( "TPythonDump::LongStringEnd" );
+
+ //================================================================================
+ /*!
+ * \brief Return marker of long string literal beginning
+ * \param type - a name of functionality producing the string literal
+ * \retval TCollection_AsciiString - the marker string to be written into
+ * a raw python script
+ */
+ //================================================================================
+
+ TCollection_AsciiString TPythonDump::LongStringStart(const char* type)
+ {
+ return
+ myLongStringStart +
+ (Standard_Integer) strlen(type) +
+ " " +
+ (char*) type;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Return marker of long string literal end
+ * \retval TCollection_AsciiString - the marker string to be written into
+ * a raw python script
+ */
+ //================================================================================
+
+ TCollection_AsciiString TPythonDump::LongStringEnd()
+ {
+ return myLongStringEnd;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Cut out a long string literal from a string
+ * \param theText - text possibly containing string literals
+ * \param theFrom - position in the text to search from
+ * \param theLongString - the retrieved literal
+ * \param theStringType - a name of functionality produced the literal
+ * \retval bool - true if a string literal found
+ *
+ * The literal is removed from theText; theFrom points position right after
+ * the removed literal
+ */
+ //================================================================================
+
+ bool TPythonDump::CutoutLongString( TCollection_AsciiString & theText,
+ int & theFrom,
+ TCollection_AsciiString & theLongString,
+ TCollection_AsciiString & theStringType)
+ {
+ if ( theFrom < 1 || theFrom > theText.Length() )
+ return false;
+
+ // ...script \ beg marker \ \ type \ literal \ end marker \ script...
+ // "theText myLongStringStart7 Pattern!!! SALOME Mesh Pattern file myLongStringEndtextEnd"
+ // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+ // 0 1 2 3 4 5 6 7 8
+
+ theFrom = theText.Location( myLongStringStart, theFrom, theText.Length() ); // = 09
+ if ( !theFrom )
+ return false;
+
+ // find where literal begins
+ int literalBeg = theFrom + myLongStringStart.Length(); // = 26
+ char* typeLenStr = (char*) theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
+ int typeLen = atoi ( typeLenStr ); // = 7
+ while ( *typeLenStr != ' ' ) { // look for ' ' after typeLen
+ literalBeg++; // 26 -> 27
+ typeLenStr++;
+ }
+ literalBeg += typeLen + 1; // = 35
+ if ( literalBeg > theText.Length() )
+ return false;
+
+ // where literal ends (i.e. end marker begins)
+ int literalEnd = theText.Location( myLongStringEnd, literalBeg, theText.Length() ); // = 64
+ if ( !literalEnd )
+ literalEnd = theText.Length();
+
+ // literal
+ theLongString = theText.SubString( literalBeg, literalEnd - 1); // "!!! SALOME Mesh Pattern file "
+ // type
+ theStringType = theText.SubString( literalBeg - typeLen, literalBeg - 1 ); // "Pattern"
+ // cut off literal
+ literalEnd += myLongStringEnd.Length(); // = 79
+ TCollection_AsciiString textEnd = theText.SubString( literalEnd, theText.Length() ); // "textE..."
+ theText = theText.SubString( 1, theFrom - 1 ) + textEnd;
+
+ return true;
+ }
+
+ void printException( const char* text )
+ {
+#ifdef _DEBUG_
+ cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl;
+#endif
+ }
+}
+
+//=======================================================================
+//function : RemoveTabulation
+//purpose :
+//=======================================================================
+void RemoveTabulation( TCollection_AsciiString& theScript )
+{
+ std::string aString( theScript.ToCString() );
+ std::string::size_type aPos = 0;
+ while( aPos < aString.length() )
+ {
+ aPos = aString.find( "\n\t", aPos );
+ if( aPos == std::string::npos )
+ break;
+ aString.replace( aPos, 2, "\n" );
+ aPos++;
+ }
+ theScript = aString.c_str();
+}
+
+//=======================================================================
+//function : DumpPython
+//purpose :
+//=======================================================================
+Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean& isValidScript)
+{
+ SALOMEDS::Study_var aStudy = getStudyServant();
+ if (CORBA::is_nil(aStudy))
+ return new Engines::TMPFile(0);
+
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SObject_wrap aSO = aStudy->FindComponent( compDataType.in() );
+ if (CORBA::is_nil(aSO))
+ return new Engines::TMPFile(0);
+
+ // Map study entries to object names
+ Resource_DataMapOfAsciiStringAsciiString aMap;
+ Resource_DataMapOfAsciiStringAsciiString aMapNames;
+
+ SALOMEDS::ChildIterator_wrap Itr = aStudy->NewChildIterator(aSO);
+ for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
+ SALOMEDS::SObject_wrap aValue = Itr->Value();
+ CORBA::String_var anID = aValue->GetID();
+ CORBA::String_var aName = aValue->GetName();
+ TCollection_AsciiString aGUIName ( (char*) aName.in() );
+ TCollection_AsciiString anEntry ( (char*) anID.in() );
+ if (aGUIName.Length() > 0) {
+ aMapNames.Bind( anEntry, aGUIName );
+ aMap.Bind( anEntry, aGUIName );
+ }
+ }
+
+ // Get trace of restored study
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_wrap anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+ SALOMEDS::AttributePythonObject_var pyAttr =
+ SALOMEDS::AttributePythonObject::_narrow(anAttr);
+ CORBA::String_var oldValue = pyAttr->GetObject();
+ TCollection_AsciiString aSavedTrace (oldValue.in());
+
+ // Add trace of API methods calls and replace study entries by names
+ TCollection_AsciiString aScript;
+ aScript += DumpPython_impl(aMap, aMapNames, isPublished, isMultiFile,
+ myIsHistoricalPythonDump, isValidScript, aSavedTrace);
+
+ int aLen = aScript.Length();
+ unsigned char* aBuffer = new unsigned char[aLen+1];
+ strcpy((char*)aBuffer, aScript.ToCString());
+
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
+
+ bool hasNotPublishedObjects = aScript.Location( SMESH::theNotPublishedObjectName, 1, aLen);
+ isValidScript = isValidScript && !hasNotPublishedObjects;
+
+ return aStreamFile._retn();
+}
+
+//=============================================================================
+/*!
+ * AddToPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::AddToPythonScript (const TCollection_AsciiString& theString)
+{
+ if (myPythonScript.IsNull()) {
+ myPythonScript = new TColStd_HSequenceOfAsciiString;
+ }
+ myPythonScript->Append(theString);
+}
+
+//=============================================================================
+/*!
+ * RemoveLastFromPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::RemoveLastFromPythonScript()
+{
+ if (!myPythonScript.IsNull()) {
+ int aLen = myPythonScript->Length();
+ myPythonScript->Remove(aLen);
+ }
+}
+
+//=======================================================================
+//function : SavePython
+//purpose :
+//=======================================================================
+void SMESH_Gen_i::SavePython()
+{
+ // Dump trace of API methods calls
+ TCollection_AsciiString aScript = GetNewPythonLines();
+
+ // Check contents of PythonObject attribute
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SObject_wrap aSO = getStudyServant()->FindComponent( compDataType.in() );
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
+ SALOMEDS::GenericAttribute_wrap anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+ SALOMEDS::AttributePythonObject_var pyAttr =
+ SALOMEDS::AttributePythonObject::_narrow(anAttr);
+ CORBA::String_var oldValue = pyAttr->GetObject();
+ TCollection_AsciiString oldScript (oldValue.in());
+
+ if (oldScript.Length() > 0) {
+ oldScript += "\n";
+ oldScript += aScript;
+ } else {
+ oldScript = aScript;
+ }
+
+ // Store in PythonObject attribute
+ pyAttr->SetObject(oldScript.ToCString(), 1);
+
+ // Clean trace of API methods calls
+ CleanPythonTrace();
+}
+
+
+// impl
+
+
+//=============================================================================
+/*!
+ * FindEntries: Returns a sequence of start/end positions of entries in the string
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
+{
+ Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+ Standard_Integer aLen = theString.Length();
+ Standard_Boolean isFound = Standard_False;
+
+ char* arr = (char*) theString.ToCString();
+ Standard_Integer i = 0, j;
+
+ while(i < aLen) {
+ int c = (int)arr[i];
+ j = i+1;
+ if ( isdigit( c )) { //Is digit?
+
+ isFound = Standard_False;
+ while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry
+ c = (int)arr[j++];
+ if(c == ':') isFound = Standard_True;
+ }
+
+ if (isFound) {
+ int prev = (i < 1) ? 0 : (int)arr[i - 1];
+ // to distinguish from a sketcher command:
+ // last char should be a digit, not ":",
+ // previous char should not be '"'.
+ if (arr[j-2] != ':' && prev != '"') {
+ aSeq->Append(i+1); // +1 because AsciiString starts from 1
+ aSeq->Append(j-1);
+ }
+ }
+ }
+
+ i = j;
+ }
+
+ return aSeq;
+}
+
+namespace {
+
+ //================================================================================
+ /*!
+ * \brief Make a string be a valid python name
+ * \param aName - a string to fix
+ * \retval bool - true if aName was not modified
+ */
+ //================================================================================
+
+ bool fixPythonName(TCollection_AsciiString & aName)
+ {
+ bool isValidName = true;
+ int nbUnderscore = 0;
+ int p;
+ // replace not allowed chars by underscore
+ const char* name = aName.ToCString();
+ for ( p = 0; name[p]; ++p ) {
+ if ( !isalnum( name[p] ) && name[p] != '_' )
+ {
+ if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
+ {
+ aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
+ --p;
+ name = aName.ToCString();
+ }
+ else
+ {
+ aName.SetValue( p+1, '_');
+ nbUnderscore++;
+ }
+ isValidName = false;
+ }
+ }
+ // aName must not start with a digit
+ if ( aName.IsIntegerValue() ) {
+ aName.Insert( 1, 'a' );
+ isValidName = false;
+ }
+ // shorten names like CartesianParameters3D_400_400_400_1000000_1
+ const int nbAllowedUnderscore = 3; /* changed from 2 to 3 by an user request
+ posted to SALOME Forum */
+ if ( aName.Length() > 20 && nbUnderscore > nbAllowedUnderscore )
+ {
+ p = aName.Location( "_", 20, aName.Length());
+ if ( p > 1 )
+ aName.Trunc( p-1 );
+ }
+ return isValidName;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Return Python module names of available plug-ins.
+ */
+ //================================================================================
+
+ std::vector<std::string> getPluginNames()
+ {
+ std::vector<std::string> pluginNames;
+ std::vector< std::string > xmlPaths = SMESH_Gen::GetPluginXMLPaths();
+ LDOMParser xmlParser;
+ for ( size_t i = 0; i < xmlPaths.size(); ++i )
+ {
+ bool error = xmlParser.parse( xmlPaths[i].c_str() );
+ if ( error )
+ {
+ TCollection_AsciiString data;
+ INFOS( xmlParser.GetError(data) );
+ continue;
+ }
+ // <meshers-group name="Standard Meshers"
+ // resources="StdMeshers"
+ // idl-module="StdMeshers"
+ // server-lib="StdMeshersEngine"
+ // gui-lib="StdMeshersGUI">
+ LDOM_Document xmlDoc = xmlParser.getDocument();
+ LDOM_NodeList nodeList = xmlDoc.getElementsByTagName( "meshers-group" );
+ for ( int i = 0; i < nodeList.getLength(); ++i )
+ {
+ LDOM_Node node = nodeList.item( i );
+ LDOM_Element& elem = (LDOM_Element&) node;
+ LDOMString idlModule = elem.getAttribute( "idl-module" );
+ if ( strlen( idlModule.GetString() ) > 0 )
+ pluginNames.push_back( idlModule.GetString() );
+ }
+ }
+ return pluginNames;
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Createa a Dump Python script
+ * \param [in,out] theObjectNames - map of an entry to a study and python name
+ * \param [in] theNames - - map of an entry to a study name
+ * \param [in] isPublished - \c true if dump of object publication in study is needed
+ * \param [in] isMultiFile - \c true if dump of each module goes to a separate file
+ * \param [in] isHistoricalDump - \c true if removed object should be dumped
+ * \param [out] aValidScript - returns \c true if the returned script seems valid
+ * \param [in,out] theSavedTrace - the dump stored in the study. It's cleared to
+ * decrease memory usage.
+ * \return TCollection_AsciiString - the result dump script.
+ */
+//================================================================================
+
+TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
+ (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
+ Resource_DataMapOfAsciiStringAsciiString& theNames,
+ bool isPublished,
+ bool isMultiFile,
+ bool isHistoricalDump,
+ bool& aValidScript,
+ TCollection_AsciiString& theSavedTrace)
+{
+ SMESH_TRY;
+
+ const TCollection_AsciiString aSmeshpy ( SMESH_2smeshpy::SmeshpyName() );
+ const TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() );
+ const TCollection_AsciiString anOldGen ( SMESH::TPythonDump::SMESHGenName() );
+ const TCollection_AsciiString helper; // to comfortably append C strings to TCollection_AsciiString
+ const TCollection_AsciiString tab( isMultiFile ? "\t" : "" ), nt = helper + "\n" + tab;
+
+ std::list< TCollection_AsciiString > lines; // lines of a script
+ std::list< TCollection_AsciiString >::iterator linesIt;
+
+ if ( isPublished )
+ lines.push_back( aSMESHGen + " = smeshBuilder.New()" );
+ else
+ lines.push_back( aSMESHGen + " = smeshBuilder.New(False)" );
+ lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
+ lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );
+
+ // Treat dump trace of restored study
+ if (theSavedTrace.Length() > 0)
+ {
+ linesIt = --lines.end();
+ // Split theSavedTrace into lines
+ int from = 1, end = theSavedTrace.Length(), to;
+ while ( from < end && ( to = theSavedTrace.Location( "\n", from, end )))
+ {
+ if ( theSavedTrace.ToCString()[from-1] == '\t' )
+ ++from;
+ if ( to != from )
+ lines.push_back( theSavedTrace.SubString( from, to - 1 ));
+ from = to + 1;
+ }
+ // For the conversion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
+ // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()).
+ // Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API
+ bool isNewVersion =
+ theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() );
+ theSavedTrace.Clear();
+ if ( !isNewVersion )
+ {
+ const TCollection_AsciiString aSmeshCall ( "smesh." ), gen( "gen" );
+ int beg, end, from;
+ for ( ++linesIt; linesIt != lines.end(); ++linesIt )
+ {
+ TCollection_AsciiString& aSavedLine = *linesIt;
+ end = aSavedLine.Length(), from = 1;
+ while ( from < end && ( beg = aSavedLine.Location( aSmeshCall, from, end )))
+ {
+ char charBefore = ( beg == 1 ) ? ' ' : aSavedLine.Value( beg - 1 );
+ if ( isspace( charBefore ) || charBefore == '=' ) { // "smesh." is not a part of a long word
+ aSavedLine.Insert( beg + aSmeshCall.Length() - 1, gen );// "smesh" -> "smeshgen"
+ end += gen.Length();
+ }
+ from = beg + aSmeshCall.Length();
+ }
+ }
+ }
+ }
+
+ // Add new dump trace of API methods calls to script lines
+ if (!myPythonScript.IsNull())
+ {
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
+ Standard_Integer istr, aLen = aPythonScript->Length();
+ for (istr = 1; istr <= aLen; istr++)
+ lines.push_back( aPythonScript->Value( istr ));
+ }
+
+ // Convert IDL API calls into smeshBuilder.py API.
+ // Some objects are wrapped with python classes and
+ // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects
+ Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
+ std::set< TCollection_AsciiString > aRemovedObjIDs;
+ if ( !getenv("NO_2smeshpy_conversion"))
+ SMESH_2smeshpy::ConvertScript( lines, anEntry2AccessorMethod,
+ theObjectNames, aRemovedObjIDs,
+ isHistoricalDump );
+
+ bool importGeom = false;
+ GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
+ {
+ // Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects
+ GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
+ int ign = 0, nbgn = aGeomNames->length();
+ for (; ign < nbgn; ign++) {
+ TCollection_AsciiString aName = aGeomNames[ign].in();
+ theObjectNames.Bind(aName, "1");
+ }
+ }
+
+ TCollection_AsciiString anUpdatedScript;
+
+ Resource_DataMapOfAsciiStringAsciiString mapRemoved;
+ Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
+ Standard_Integer objectCounter = 0;
+ TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
+
+ // Treat every script line and add it to anUpdatedScript
+ for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
+ {
+ TCollection_AsciiString& aLine = *linesIt;
+ anUpdatedScript += tab;
+ {
+ //Replace characters used instead of quote marks to quote notebook variables
+ int pos = 1;
+ while (( pos = aLine.Location( 1, SMESH::TVar::Quote(), pos, aLine.Length() )))
+ aLine.SetValue( pos, '"' );
+ }
+ // Find entries to be replaced by names
+ Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aLine);
+ const Standard_Integer aSeqLen = aSeq->Length();
+ Standard_Integer aStart = 1;
+ for (Standard_Integer i = 1; i <= aSeqLen; i += 2)
+ {
+ if ( aStart < aSeq->Value(i) )
+ anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
+ anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
+ // is a GEOM object?
+ CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() );
+ if ( !geomName.in() || !geomName.in()[0] ) {
+ // is a SMESH object
+ if ( theObjectNames.IsBound( anEntry )) {
+ // The Object is in Study
+ aName = theObjectNames.Find( anEntry );
+ // check validity of aName
+ bool isValidName = fixPythonName( aName );
+ if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
+ // diff objects have same name - make a new name by appending a digit
+ TCollection_AsciiString aName2;
+ Standard_Integer i = 0;
+ do {
+ aName2 = aName + "_" + ++i;
+ } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
+ aName = aName2;
+ isValidName = false;
+ }
+ if ( !isValidName )
+ theObjectNames(anEntry) = aName;
+
+ if ( aLine.Value(1) != '#' )
+ mapEntries.Bind(anEntry, aName);
+ }
+ else
+ {
+ // Removed Object
+ do {
+ aName = aBaseName + (++objectCounter);
+ } while (theObjectNames.IsBound(aName));
+
+ if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
+ mapRemoved.Bind(anEntry, aName);
+
+ theObjectNames.Bind(anEntry, aName);
+ }
+ theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
+ }
+ else
+ {
+ aName = geomName.in();
+ importGeom = true;
+ }
+ anUpdatedScript += aName;
+ aStart = aSeq->Value(i + 1) + 1;
+
+ } // loop on entries within aLine
+
+ if ( aSeqLen == 0 )
+ anUpdatedScript += aLine;
+ else if ( aSeq->Value( aSeqLen ) < aLine.Length() )
+ anUpdatedScript += aLine.SubString( aSeq->Value(aSeqLen) + 1, aLine.Length() );
+
+ anUpdatedScript += '\n';
+ }
+
+ // Make an initial part of aSript
+
+ TCollection_AsciiString initPart = "import ";
+ if ( isMultiFile )
+ initPart += "salome, ";
+ initPart += " SMESH, SALOMEDS\n";
+ initPart += "from salome.smesh import smeshBuilder\n";
+ if ( importGeom && isMultiFile )
+ {
+ initPart += ("\n## import GEOM dump file ## \n"
+ "import string, os, sys, re, inspect\n"
+ "thisFile = inspect.getfile( inspect.currentframe() )\n"
+ "thisModule = os.path.splitext( os.path.basename( thisFile ))[0]\n"
+ "sys.path.insert( 0, os.path.dirname( thisFile ))\n"
+ "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",thisModule)+\" import *\")\n\n");
+ }
+ // import python files corresponding to plugins if they are used in anUpdatedScript
+ {
+ TCollection_AsciiString importStr;
+ std::vector<std::string> pluginNames = getPluginNames();
+ for ( size_t i = 0; i < pluginNames.size(); ++i )
+ {
+ // Convert access to plugin members:
+ // e.g. StdMeshers.QUAD_REDUCED -> StdMeshersBuilder.QUAD_REDUCED
+ TCollection_AsciiString pluginAccess = (pluginNames[i] + ".").c_str() ;
+ int iFrom = 1, iPos;
+ while (( iPos = anUpdatedScript.Location( pluginAccess, iFrom, anUpdatedScript.Length() )))
+ {
+ anUpdatedScript.Insert( iPos + pluginNames[i].size(), "Builder" );
+ iFrom = iPos + pluginNames[i].size() + 8;
+ }
+ // if any plugin member is used, import the plugin
+ if ( iFrom > 1 )
+ importStr += ( helper + "\n" "from salome." + pluginNames[i].c_str() +
+ " import " + pluginNames[i].c_str() +"Builder" );
+ }
+ if ( !importStr.IsEmpty() )
+ initPart += importStr + "\n";
+ }
+
+ if ( isMultiFile )
+ initPart += "def RebuildData():";
+ initPart += "\n";
+
+ anUpdatedScript.Prepend( initPart );
+
+ // Make a final part of aScript
+
+ // Dump object removal
+ TCollection_AsciiString removeObjPart;
+ if ( !mapRemoved.IsEmpty() ) {
+ removeObjPart += nt + "## some objects were removed";
+ removeObjPart += nt + "aStudyBuilder = salome.myStudy.NewBuilder()";
+ Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapRemovedIt;
+ for ( mapRemovedIt.Initialize( mapRemoved ); mapRemovedIt.More(); mapRemovedIt.Next() ) {
+ aName = mapRemovedIt.Value(); // python name
+ anEntry = mapRemovedIt.Key();
+ removeObjPart += nt + "SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(";
+ removeObjPart += aName;
+ // for object wrapped by class of smeshBuilder.py
+ if ( anEntry2AccessorMethod.IsBound( anEntry ) )
+ removeObjPart += helper + "." + anEntry2AccessorMethod( anEntry );
+ removeObjPart += helper + "))" + nt + "if SO: aStudyBuilder.RemoveObjectWithChildren(SO)";
+ }
+ }
+
+ // Set object names
+ TCollection_AsciiString setNamePart;
+ Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapEntriesIt;
+ for ( mapEntriesIt.Initialize( mapEntries ); mapEntriesIt.More(); mapEntriesIt.Next() )
+ {
+ anEntry = mapEntriesIt.Key();
+ aName = mapEntriesIt.Value(); // python name
+ if ( theNames.IsBound( anEntry ))
+ {
+ aGUIName = theNames.Find(anEntry);
+ aGUIName.RemoveAll('\''); // remove a quote from a name (issue 22360)
+ setNamePart += nt + aSMESHGen + ".SetName(" + aName;
+ if ( anEntry2AccessorMethod.IsBound( anEntry ) )
+ setNamePart += helper + "." + anEntry2AccessorMethod( anEntry );
+ setNamePart += helper + ", '" + aGUIName + "')";
+ }
+ }
+ if ( !setNamePart.IsEmpty() )
+ {
+ setNamePart.Insert( 1, nt + "## Set names of Mesh objects" );
+ }
+
+ // Store visual properties of displayed objects
+
+ TCollection_AsciiString visualPropertiesPart;
+ if (isPublished)
+ {
+ //Output the script that sets up the visual parameters.
+ CORBA::String_var compDataType = ComponentDataType();
+ CORBA::String_var script = getStudyServant()->GetDefaultScript( compDataType.in(), tab.ToCString() );
+ if ( script.in() && script.in()[0] ) {
+ visualPropertiesPart += nt + "### Store presentation parameters of displayed objects\n";
+ visualPropertiesPart += script.in();
+ }
+ }
+
+ anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart;
+
+ if ( isMultiFile )
+ {
+ anUpdatedScript +=
+ "\n\tpass"
+ "\n"
+ "\nif __name__ == '__main__':"
+ "\n\tSMESH_RebuildData = RebuildData"
+ "\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
+ "\n\tGEOM_dump.RebuildData()"
+ "\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
+ "\n\tSMESH_RebuildData()";
+ }
+ anUpdatedScript += "\n";
+
+ // no need now as we use 'tab' and 'nt' variables depending on isMultiFile
+ // if( !isMultiFile ) // remove unnecessary tabulation
+ // RemoveTabulation( anUpdatedScript );
+
+ // -----------------------------------------------------------------
+ // put string literals describing patterns into separate functions
+ // -----------------------------------------------------------------
+
+ TCollection_AsciiString aLongString, aFunctionType;
+ int where = 1;
+ std::set< std::string > functionNameSet;
+ while ( SMESH::TPythonDump::CutoutLongString( anUpdatedScript, where, aLongString, aFunctionType ))
+ {
+ // make a python string literal
+ aLongString.Prepend(":\n\treturn '''\n");
+ aLongString += "\n\t'''\n\tpass\n";
+
+ TCollection_AsciiString functionName;
+
+ // check if the function returning this literal is already defined
+ int posAlready = anUpdatedScript.Location( aLongString, where, anUpdatedScript.Length() );
+ if ( posAlready ) // already defined
+ {
+ // find the function name
+ int functBeg = posAlready;
++ char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def function()"
+ while ( *script != ' ' ) {
+ script--;
+ functBeg--;
+ }
+ functBeg++; // do not take ' '
+ posAlready--; // do not take ':'
+ functionName = anUpdatedScript.SubString( functBeg, posAlready );
+ }
+ else // not defined yet
+ {
+ // find a unique function name
+ fixPythonName( aFunctionType );
+ Standard_Integer nb = 0;
+ do functionName = aFunctionType + "_" + ( nb++ ) + "()";
+ while ( !functionNameSet.insert( functionName.ToCString() ).second );
+
+ // define function
+ TCollection_AsciiString funDef = helper + "def " + functionName + aLongString;
+ if ( isMultiFile )
+ {
+ anUpdatedScript += helper + "\n\n" + funDef;
+ }
+ else
+ {
+ funDef += "\n\n";
+ anUpdatedScript.Insert( 1, funDef);
+ where += funDef.Length();
+ }
+ }
+ anUpdatedScript.InsertBefore( where, functionName ); // call function
+ }
+
+ aValidScript = true;
+
+ return anUpdatedScript;
+
+ SMESH_CATCH( SMESH::printException );
+
+ aValidScript = false;
+ return "";
+}
+
+//=============================================================================
+/*!
+ * GetNewPythonLines
+ */
+//=============================================================================
+TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines()
+{
+ TCollection_AsciiString aScript;
+
+ // Dump trace of API methods calls
+ if (!myPythonScript.IsNull()) {
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
+ Standard_Integer istr, aLen = aPythonScript->Length();
+ for (istr = 1; istr <= aLen; istr++) {
+ aScript += "\n";
+ aScript += aPythonScript->Value(istr);
+ }
+ aScript += "\n";
+ }
+
+ return aScript;
+}
+
+//=============================================================================
+/*!
+ * CleanPythonTrace
+ */
+//=============================================================================
+void SMESH_Gen_i::CleanPythonTrace()
+{
+ TCollection_AsciiString aScript;
+
+ // Clean trace of API methods calls
+ if (!myPythonScript.IsNull()) {
+ myPythonScript->Clear();
+ }
+}
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
- # SMESH SMESH_SWIG : binding of C++ implementaion with Python
+ # SMESH SMESH_SWIG : binding of C++ implementation with Python
# File : SMESH_blocks.py
# Author : Julia DOROVSKIKH
# Module : SMESH
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
import math
GEOM_Spanner.MakeSpanner(geompy, math, isBlocksTest, isMeshTest, smesh)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
def LengthNearVertex(self, length, vertex=0, UseExisting=0):
import types
store_geom = self.geom
- if type(vertex) is types.IntType:
+ if isinstance(vertex, int):
if vertex == 0 or vertex == 1:
from salome.geom import geomBuilder
vertex = self.mesh.geompyD.ExtractShapes(self.geom, geomBuilder.geomBuilder.ShapeType["VERTEX"],True)[vertex]
# 0D algorithm
if self.geom is None:
self.geom = store_geom
- raise RuntimeError, "Attempt to create SegmentAroundVertex_0D algorithm on None shape"
+ raise RuntimeError("Attempt to create SegmentAroundVertex_0D algorithm on None shape")
from salome.smesh.smeshBuilder import AssureGeomPublished, GetName, TreatHypoStatus
AssureGeomPublished( self.mesh, self.geom )
name = GetName(self.geom)
## Return 3D hypothesis holding the 1D one
def Get3DHypothesis(self):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
return self.distribHyp
# hypothesis. Returns the created hypothesis
def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
if not self.nbLayers is None:
self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
- study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
- self.mesh.smeshpyD.SetCurrentStudy( None )
+ self.mesh.smeshpyD.SetEnablePublish( False ) # prevents publishing own 1D hypothesis
hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
- self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
+ self.mesh.smeshpyD.SetEnablePublish( True ) # enables publishing
if not self.distribHyp:
self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
self.distribHyp.SetLayerDistribution( hyp )
# the same parameters, else (default) - creates a new one
def NumberOfLayers(self, n, UseExisting=0):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
from salome.smesh.smeshBuilder import IsEqual
# @param p the precision of rounding
def LocalLength(self, l, p=1e-07):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
hyp = self.OwnHypothesis("LocalLength", [l,p])
hyp.SetLength(l)
# @param s the scale factor (optional)
def NumberOfSegments(self, n, s=[]):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
if not s:
hyp = self.OwnHypothesis("NumberOfSegments", [n])
# @param end the length of the last segment
def Arithmetic1D(self, start, end ):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
hyp.SetLength(start, 1)
# @param ratio the common ratio of the geometric progression
def GeometricProgression(self, start, ratio ):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
hyp.SetStartLength( start )
# @param end for the length of the last segment
def StartEndLength(self, start, end):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
hyp = self.OwnHypothesis("StartEndLength", [start, end])
hyp.SetLength(start, 1)
# @param fineness defines the quality of the mesh within the range [0-1]
def AutomaticLength(self, fineness=0):
if self.algoType != "RadialPrism_3D":
- print("Prism_3D algorith doesn't support any hyposesis")
- print "Prism_3D algorithm doesn't support any hypothesis"
++ print("Prism_3D algorithm doesn't support any hypothesis")
return None
hyp = self.OwnHypothesis("AutomaticLength")
hyp.SetFineness( fineness )
self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
else:
self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
- study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
- self.mesh.smeshpyD.SetCurrentStudy( None )
+ self.mesh.smeshpyD.SetEnablePublish( False )
hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
- self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
+ self.mesh.smeshpyD.SetEnablePublish( True )
self.distribHyp.SetLayerDistribution( hyp )
return hyp
self.mesh.AddHypothesis( self.hyp, self.geom )
for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef] ):
- if not gridDef: raise ValueError, "Empty grid definition"
+ if not gridDef: raise ValueError("Empty grid definition")
if isinstance( gridDef, str ):
self.hyp.SetGridSpacing( [gridDef], [], axis )
elif isinstance( gridDef[0], str ):
from salome.geom import geomBuilder
import SMESH # This is necessary for back compatibility
+import omniORB # back compatibility
+SMESH.MED_V2_1 = omniORB.EnumItem("MED_V2_1", 0) # back compatibility
+SMESH.MED_V2_2 = omniORB.EnumItem("MED_V2_2", 1) # back compatibility
+
from SMESH import *
from salome.smesh.smesh_algorithm import Mesh_Algorithm
import SALOME
import SALOMEDS
import os
+import inspect
+
+# In case the omniORBpy EnumItem class does not fully support Python 3
+# (for instance in version 4.2.1-2), the comparison ordering methods must be
+# defined
+#
+try:
+ SMESH.Entity_Triangle < SMESH.Entity_Quadrangle
+except TypeError:
+ def enumitem_eq(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v == other._v
+ else:
+ return self._parent_id == other._parent_id
+ else:
+ return id(self) == id(other)
+ except:
+ return id(self) == id(other)
+
+ def enumitem_lt(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v < other._v
+ else:
+ return self._parent_id < other._parent_id
+ else:
+ return id(self) < id(other)
+ except:
+ return id(self) < id(other)
+
+ def enumitem_le(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v <= other._v
+ else:
+ return self._parent_id <= other._parent_id
+ else:
+ return id(self) <= id(other)
+ except:
+ return id(self) <= id(other)
+
+ def enumitem_gt(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v > other._v
+ else:
+ return self._parent_id > other._parent_id
+ else:
+ return id(self) > id(other)
+ except:
+ return id(self) > id(other)
+
+ def enumitem_ge(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v >= other._v
+ else:
+ return self._parent_id >= other._parent_id
+ else:
+ return id(self) >= id(other)
+ except:
+ return id(self) >= id(other)
+
+ omniORB.EnumItem.__eq__ = enumitem_eq
+ omniORB.EnumItem.__lt__ = enumitem_lt
+ omniORB.EnumItem.__le__ = enumitem_le
+ omniORB.EnumItem.__gt__ = enumitem_gt
+ omniORB.EnumItem.__ge__ = enumitem_ge
+
## Private class used to workaround a problem that sometimes isinstance(m, Mesh) returns False
#
Parameters = ""
hasVariables = False
varModifFun=None
- if args and callable( args[-1] ):
+ if args and callable(args[-1]):
args, varModifFun = args[:-1], args[-1]
for parameter in args:
if isinstance(parameter,str):
# check if there is an inexistent variable name
if not notebook.isVariable(parameter):
- raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
+ raise ValueError("Variable with name '" + parameter + "' doesn't exist!!!")
parameter = notebook.get(parameter)
hasVariables = True
if varModifFun:
# Parameters are stored in AxisStruct.parameters attribute
def __initAxisStruct(ax,*args):
if len( args ) != 6:
- raise RuntimeError,\
- "Bad nb args (%s) passed in SMESH.AxisStruct(x,y,z,dx,dy,dz)"%(len( args ))
+ raise RuntimeError("Bad nb args (%s) passed in SMESH.AxisStruct(x,y,z,dx,dy,dz)"%(len( args )))
ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
pass
SMESH.AxisStruct.__init__ = __initAxisStruct
except:
ior = None
if ior:
- # CORBA object
- studies = salome.myStudyManager.GetOpenStudies()
- for sname in studies:
- s = salome.myStudyManager.GetStudyByName(sname)
- if not s: continue
- sobj = s.FindObjectIOR(ior)
- if not sobj: continue
+ sobj = salome.myStudy.FindObjectIOR(ior)
+ if sobj:
return sobj.GetName()
if hasattr(obj, "GetName"):
# unknown CORBA object, having GetName() method
# unknown non-CORBA object, having GetName() method
return obj.GetName()
pass
- raise RuntimeError, "Null or invalid object"
+ raise RuntimeError("Null or invalid object")
## Print error message if a hypothesis was not assigned.
def TreatHypoStatus(status, hypName, geomName, isAlgo, mesh):
pass
reason = ""
if hasattr( status, "__getitem__" ):
- status,reason = status[0],status[1]
- if status == HYP_UNKNOWN_FATAL :
+ status, reason = status[0], status[1]
+ if status == HYP_UNKNOWN_FATAL:
reason = "for unknown reason"
- elif status == HYP_INCOMPATIBLE :
+ elif status == HYP_INCOMPATIBLE:
reason = "this hypothesis mismatches the algorithm"
- elif status == HYP_NOTCONFORM :
+ elif status == HYP_NOTCONFORM:
reason = "a non-conform mesh would be built"
- elif status == HYP_ALREADY_EXIST :
+ elif status == HYP_ALREADY_EXIST:
if isAlgo: return # it does not influence anything
reason = hypType + " of the same dimension is already assigned to this shape"
- elif status == HYP_BAD_DIM :
+ elif status == HYP_BAD_DIM:
reason = hypType + " mismatches the shape"
- elif status == HYP_CONCURENT :
+ elif status == HYP_CONCURENT:
reason = "there are concurrent hypotheses on sub-shapes"
- elif status == HYP_BAD_SUBSHAPE :
+ elif status == HYP_BAD_SUBSHAPE:
reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
elif status == HYP_BAD_GEOMETRY:
reason = "the algorithm is not applicable to this geometry"
if meshName and meshName != NO_NAME:
where = '"%s" shape in "%s" mesh ' % ( geomName, meshName )
if status < HYP_UNKNOWN_FATAL and where:
- print '"%s" was assigned to %s but %s' %( hypName, where, reason )
+ print('"%s" was assigned to %s but %s' %( hypName, where, reason ))
elif where:
- print '"%s" was not assigned to %s : %s' %( hypName, where, reason )
+ print('"%s" was not assigned to %s : %s' %( hypName, where, reason ))
else:
- print '"%s" was not assigned : %s' %( hypName, reason )
+ print('"%s" was not assigned : %s' %( hypName, reason ))
pass
## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
def AssureGeomPublished(mesh, geom, name=''):
if not isinstance( geom, geomBuilder.GEOM._objref_GEOM_Object ):
return
- if not geom.GetStudyEntry() and \
- mesh.smeshpyD.GetCurrentStudy():
- ## set the study
- studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
- if studyID != mesh.geompyD.myStudyId:
- mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
+ if not geom.GetStudyEntry():
## get a name
if not name and geom.GetShapeType() != geomBuilder.GEOM.COMPOUND:
# for all groups SubShapeName() return "Compound_-1"
def FirstVertexOnCurve(mesh, edge):
vv = mesh.geompyD.SubShapeAll( edge, geomBuilder.geomBuilder.ShapeType["VERTEX"])
if not vv:
- raise TypeError, "Given object has no vertices"
+ raise TypeError("Given object has no vertices")
if len( vv ) == 1: return vv[0]
v0 = mesh.geompyD.MakeVertexOnCurve(edge,0.)
xyz = mesh.geompyD.PointCoordinates( v0 ) # coords of the first vertex
else:
return vv[1]
+## Return a long value from enumeration
+def EnumToLong(theItem):
+ return theItem._v
+
# end of l1_auxiliary
## @}
## This class allows to create, load or manipulate meshes.
# It has a set of methods to create, load or copy meshes, to combine several meshes, etc.
# It also has methods to get infos and measure meshes.
-class smeshBuilder(object, SMESH._objref_SMESH_Gen):
+class smeshBuilder(SMESH._objref_SMESH_Gen):
# MirrorType enumeration
POINT = SMESH_MeshEditor.POINT
PrecisionConfusion = smeshPrecisionConfusion
# TopAbs_State enumeration
- [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
+ [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = list(range(4))
# Methods of splitting a hexahedron into tetrahedra
Hex_5Tet, Hex_6Tet, Hex_24Tet, Hex_2Prisms, Hex_4Prisms = 1, 2, 3, 1, 2
- def __new__(cls):
+ def __new__(cls, *args):
global engine
global smeshInst
global doLcc
#print "====2 ", smeshInst
return smeshInst
- def __init__(self):
+ def __init__(self, *args):
global created
#print "--------------- smeshbuilder __init__ ---", created
if not created:
- created = True
- SMESH._objref_SMESH_Gen.__init__(self)
+ created = True
+ SMESH._objref_SMESH_Gen.__init__(self, *args)
## Dump component to the Python script
# This method overrides IDL function to allow default values for the parameters.
# @ingroup l1_auxiliary
- def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
- return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
+ def DumpPython(self, theIsPublished=True, theIsMultiFile=True):
+ return SMESH._objref_SMESH_Gen.DumpPython(self, theIsPublished, theIsMultiFile)
## Set mode of DumpPython(), \a historical or \a snapshot.
# In the \a historical mode, the Python Dump script includes all commands
else: val = "false"
SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
- ## Set the current study and Geometry component
+ ## Set Geometry component
# @ingroup l1_auxiliary
- def init_smesh(self,theStudy,geompyD = None):
+ def init_smesh(self,isPublished = True,geompyD = None):
#print "init_smesh"
- self.SetCurrentStudy(theStudy,geompyD)
- if theStudy:
+ self.UpdateStudy(geompyD)
+ if isPublished:
global notebook
- notebook.myStudy = theStudy
+ notebook.myStudy = salome.myStudy
## Create a mesh. This can be either an empty mesh, possibly having an underlying geometry,
# or a mesh wrapping a CORBA mesh given as a parameter.
obj,name = name,obj
return Mesh(self,self.geompyD,obj,name)
- ## Return a long value from enumeration
- # @ingroup l1_auxiliary
- def EnumToLong(self,theItem):
- return theItem._v
-
## Return a string representation of the color.
# To be used with filters.
# @param c color value (SALOMEDS.Color)
elif isinstance(c, str):
val = c
else:
- raise ValueError, "Color value should be of string or SALOMEDS.Color type"
+ raise ValueError("Color value should be of string or SALOMEDS.Color type")
return val
## Get PointStruct from vertex
def GetDirStruct(self,theVector):
vertices = self.geompyD.SubShapeAll( theVector, geomBuilder.geomBuilder.ShapeType["VERTEX"] )
if(len(vertices) != 2):
- print "Error: vector object is incorrect."
+ print("Error: vector object is incorrect.")
return None
p1 = self.geompyD.PointCoordinates(vertices[0])
p2 = self.geompyD.PointCoordinates(vertices[1])
# @ingroup l1_auxiliary
def IsEmbeddedMode(self):
return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
-
- ## Set the current study. Calling SetCurrentStudy( None ) allows to
- # switch OFF automatic pubilishing in the Study of mesh objects.
+
+ ## Update the current study. Calling UpdateStudy() allows to
+ # update meshes at switching GEOM->SMESH
# @ingroup l1_auxiliary
- def SetCurrentStudy( self, theStudy, geompyD = None ):
+ def UpdateStudy( self, geompyD = None ):
+ #self.UpdateStudy()
if not geompyD:
from salome.geom import geomBuilder
geompyD = geomBuilder.geom
pass
self.geompyD=geompyD
self.SetGeomEngine(geompyD)
- SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
- global notebook
- if theStudy:
- notebook = salome_notebook.NoteBook( theStudy )
- else:
- notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() )
- if theStudy:
- sb = theStudy.NewBuilder()
- sc = theStudy.FindComponent("SMESH")
- if sc: sb.LoadWith(sc, self)
- pass
+ SMESH._objref_SMESH_Gen.UpdateStudy(self)
+ sb = salome.myStudy.NewBuilder()
+ sc = salome.myStudy.FindComponent("SMESH")
+ if sc: sb.LoadWith(sc, self)
pass
-
- ## Get the current study
+
+ ## Sets enable publishing in the study. Calling SetEnablePublish( false ) allows to
+ # switch OFF publishing in the Study of mesh objects.
# @ingroup l1_auxiliary
- def GetCurrentStudy(self):
- return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
+ def SetEnablePublish( self, theIsEnablePublish ):
+ #self.SetEnablePublish(theIsEnablePublish)
+ SMESH._objref_SMESH_Gen.SetEnablePublish(self,theIsEnablePublish)
+ global notebook
+ notebook = salome_notebook.NoteBook( theIsEnablePublish )
## Create a Mesh object importing data from the given UNV file
# @return an instance of Mesh class
aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,
theFileName,
True)
- if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment
+ if error.comment: print("*** CreateMeshesFromGMF() errors:\n", error.comment)
return Mesh(self, self.geompyD, aSmeshMesh), error
## Concatenate the given meshes into one mesh. All groups of input meshes will be
def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
- ## Create a pattern mapper.
+ ## Create a pattern mapper.
# @return an instance of SMESH_Pattern
#
# <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
# @return SMESH.Filter.Criterion
# @ingroup l1_controls
def GetEmptyCriterion(self):
- Type = self.EnumToLong(FT_Undefined)
- Compare = self.EnumToLong(FT_Undefined)
+ Type = EnumToLong(FT_Undefined)
+ Compare = EnumToLong(FT_Undefined)
Threshold = 0
ThresholdStr = ""
ThresholdID = ""
- UnaryOp = self.EnumToLong(FT_Undefined)
- BinaryOp = self.EnumToLong(FT_Undefined)
+ UnaryOp = EnumToLong(FT_Undefined)
+ BinaryOp = EnumToLong(FT_Undefined)
Tolerance = 1e-07
TypeOfElement = ALL
Precision = -1 ##@1e-07
BinaryOp=FT_Undefined,
Tolerance=1e-07):
if not CritType in SMESH.FunctorType._items:
- raise TypeError, "CritType should be of SMESH.FunctorType"
+ raise TypeError("CritType should be of SMESH.FunctorType")
aCriterion = self.GetEmptyCriterion()
aCriterion.TypeOfElement = elementType
- aCriterion.Type = self.EnumToLong(CritType)
+ aCriterion.Type = EnumToLong(CritType)
aCriterion.Tolerance = Tolerance
aThreshold = Threshold
if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
- aCriterion.Compare = self.EnumToLong(Compare)
+ aCriterion.Compare = EnumToLong(Compare)
elif Compare == "=" or Compare == "==":
- aCriterion.Compare = self.EnumToLong(FT_EqualTo)
+ aCriterion.Compare = EnumToLong(FT_EqualTo)
elif Compare == "<":
- aCriterion.Compare = self.EnumToLong(FT_LessThan)
+ aCriterion.Compare = EnumToLong(FT_LessThan)
elif Compare == ">":
- aCriterion.Compare = self.EnumToLong(FT_MoreThan)
+ aCriterion.Compare = EnumToLong(FT_MoreThan)
elif Compare != FT_Undefined:
- aCriterion.Compare = self.EnumToLong(FT_EqualTo)
+ aCriterion.Compare = EnumToLong(FT_EqualTo)
aThreshold = Compare
if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
elif isinstance( aThreshold, str ):
aCriterion.ThresholdStr = aThreshold
else:
- raise TypeError, "The Threshold should be a shape."
+ raise TypeError("The Threshold should be a shape.")
if isinstance(UnaryOp,float):
aCriterion.Tolerance = UnaryOp
UnaryOp = FT_Undefined
# Check that Threshold is a group
if isinstance(aThreshold, SMESH._objref_SMESH_GroupBase):
if aThreshold.GetType() != elementType:
- raise ValueError, "Group type mismatches Element type"
+ raise ValueError("Group type mismatches Element type")
aCriterion.ThresholdStr = aThreshold.GetName()
aCriterion.ThresholdID = salome.orb.object_to_string( aThreshold )
- study = self.GetCurrentStudy()
+ study = salome.myStudy
if study:
so = study.FindObjectIOR( aCriterion.ThresholdID )
if so:
if entry:
aCriterion.ThresholdID = entry
else:
- raise TypeError, "The Threshold should be a Mesh Group"
+ raise TypeError("The Threshold should be a Mesh Group")
elif CritType == FT_RangeOfIds:
# Check that Threshold is string
if isinstance(aThreshold, str):
aCriterion.ThresholdStr = aThreshold
else:
- raise TypeError, "The Threshold should be a string."
+ raise TypeError("The Threshold should be a string.")
elif CritType == FT_CoplanarFaces:
# Check the Threshold
if isinstance(aThreshold, int):
elif isinstance(aThreshold, str):
ID = int(aThreshold)
if ID < 1:
- raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
+ raise ValueError("Invalid ID of mesh face: '%s'"%aThreshold)
aCriterion.ThresholdID = aThreshold
else:
- raise TypeError,\
- "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
+ raise TypeError("The Threshold should be an ID of mesh face and not '%s'"%aThreshold)
elif CritType == FT_ConnectedElements:
# Check the Threshold
if isinstance(aThreshold, geomBuilder.GEOM._objref_GEOM_Object): # shape
aCriterion.Threshold = aThreshold
elif isinstance(aThreshold, list): # 3 point coordinates
if len( aThreshold ) < 3:
- raise ValueError, "too few point coordinates, must be 3"
+ raise ValueError("too few point coordinates, must be 3")
aCriterion.ThresholdStr = " ".join( [str(c) for c in aThreshold[:3]] )
elif isinstance(aThreshold, str):
if aThreshold.isdigit():
else:
aCriterion.ThresholdStr = aThreshold # hope that it's point coordinates
else:
- raise TypeError,\
- "The Threshold should either a VERTEX, or a node ID, "\
- "or a list of point coordinates and not '%s'"%aThreshold
+ raise TypeError("The Threshold should either a VERTEX, or a node ID, "\
+ "or a list of point coordinates and not '%s'"%aThreshold)
elif CritType == FT_ElemGeomType:
# Check the Threshold
try:
- aCriterion.Threshold = self.EnumToLong(aThreshold)
+ aCriterion.Threshold = EnumToLong(aThreshold)
assert( aThreshold in SMESH.GeometryType._items )
except:
if isinstance(aThreshold, int):
aCriterion.Threshold = aThreshold
else:
- raise TypeError, "The Threshold should be an integer or SMESH.GeometryType."
+ raise TypeError("The Threshold should be an integer or SMESH.GeometryType.")
pass
pass
elif CritType == FT_EntityType:
# Check the Threshold
try:
- aCriterion.Threshold = self.EnumToLong(aThreshold)
+ aCriterion.Threshold = EnumToLong(aThreshold)
assert( aThreshold in SMESH.EntityType._items )
except:
if isinstance(aThreshold, int):
aCriterion.Threshold = aThreshold
else:
- raise TypeError, "The Threshold should be an integer or SMESH.EntityType."
+ raise TypeError("The Threshold should be an integer or SMESH.EntityType.")
pass
pass
-
+
elif CritType == FT_GroupColor:
# Check the Threshold
try:
aCriterion.ThresholdStr = self.ColorToString(aThreshold)
except:
- raise TypeError, "The threshold value should be of SALOMEDS.Color type"
+ raise TypeError("The threshold value should be of SALOMEDS.Color type")
pass
elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
FT_LinearOrQuadratic, FT_BadOrientedVolume,
FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
# At this point the Threshold is unnecessary
if aThreshold == FT_LogicalNOT:
- aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
+ aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
aCriterion.BinaryOp = aThreshold
else:
aThreshold = float(aThreshold)
aCriterion.Threshold = aThreshold
except:
- raise TypeError, "The Threshold should be a number."
+ raise TypeError("The Threshold should be a number.")
return None
if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
- aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
+ aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
if Threshold in [FT_LogicalAND, FT_LogicalOR]:
- aCriterion.BinaryOp = self.EnumToLong(Threshold)
+ aCriterion.BinaryOp = EnumToLong(Threshold)
if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
- aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
+ aCriterion.BinaryOp = EnumToLong(UnaryOp)
if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
- aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
+ aCriterion.BinaryOp = EnumToLong(BinaryOp)
return aCriterion
# @ingroup l1_controls
def GetFilterFromCriteria(self,criteria, binOp=SMESH.FT_LogicalAND):
for i in range( len( criteria ) - 1 ):
- if criteria[i].BinaryOp == self.EnumToLong( SMESH.FT_Undefined ):
- criteria[i].BinaryOp = self.EnumToLong( binOp )
+ if criteria[i].BinaryOp == EnumToLong( SMESH.FT_Undefined ):
+ criteria[i].BinaryOp = EnumToLong( binOp )
aFilterMgr = self.CreateFilterManager()
aFilter = aFilterMgr.CreateFilter()
aFilter.SetCriteria(criteria)
elif theCriterion == FT_BallDiameter:
functor = aFilterMgr.CreateBallDiameter()
else:
- print "Error: given parameter is not numerical functor type."
+ print("Error: given parameter is not numerical functor type.")
aFilterMgr.UnRegister()
return functor
d = {}
if hasattr(obj, "GetMeshInfo"):
values = obj.GetMeshInfo()
- for i in range(SMESH.Entity_Last._v):
+ for i in range(EnumToLong(SMESH.Entity_Last)):
if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
pass
return d
aMeasurements.UnRegister()
return value
+ ## Get gravity center of all nodes of the mesh object.
+ # @param obj mesh, submesh or group
+ # @return three components of the gravity center: x,y,z
+ # @ingroup l1_measurements
+ def GetGravityCenter(self, obj):
+ if isinstance(obj, Mesh): obj = obj.mesh
+ if isinstance(obj, Mesh_Algorithm): obj = obj.GetSubMesh()
+ aMeasurements = self.CreateMeasurements()
+ pointStruct = aMeasurements.GravityCenter(obj)
+ aMeasurements.UnRegister()
+ return pointStruct.x, pointStruct.y, pointStruct.z
+
pass # end of class smeshBuilder
import omniORB
# import salome
# salome.salome_init()
# from salome.smesh import smeshBuilder
-# smesh = smeshBuilder.New(salome.myStudy)
+# smesh = smeshBuilder.New()
# \endcode
-# @param study SALOME study, generally obtained by salome.myStudy.
+# @param isPublished If False, the notebool will not be used.
# @param instance CORBA proxy of SMESH Engine. If None, the default Engine is used.
# @return smeshBuilder instance
-def New( study, instance=None):
+def New( isPublished = True, instance=None):
"""
Create a new smeshBuilder instance.The smeshBuilder class provides the Python
interface to create or load meshes.
import salome
salome.salome_init()
from salome.smesh import smeshBuilder
- smesh = smeshBuilder.New(salome.myStudy)
+ smesh = smeshBuilder.New()
Parameters:
- study SALOME study, generally obtained by salome.myStudy.
+ isPublished If False, the notebool will not be used.
instance CORBA proxy of SMESH Engine. If None, the default Engine is used.
Returns:
smeshBuilder instance
global doLcc
engine = instance
if engine is None:
- doLcc = True
+ doLcc = True
smeshInst = smeshBuilder()
assert isinstance(smeshInst,smeshBuilder), "Smesh engine class is %s but should be smeshBuilder.smeshBuilder. Import salome.smesh.smeshBuilder before creating the instance."%smeshInst.__class__
- smeshInst.init_smesh(study)
+ smeshInst.init_smesh(isPublished)
return smeshInst
# It also has methods to define groups of mesh elements, to modify a mesh (by addition of
# new nodes and elements and by changing the existing entities), to get information
# about a mesh and to export a mesh in different formats.
-class Mesh:
- __metaclass__ = MeshMeta
-
+class Mesh(metaclass=MeshMeta):
geom = 0
mesh = 0
editor = 0
# @param name Study name of the mesh
# @ingroup l2_construct
def __init__(self, smeshpyD, geompyD, obj=0, name=0):
- self.smeshpyD=smeshpyD
- self.geompyD=geompyD
+ self.smeshpyD = smeshpyD
+ self.geompyD = geompyD
if obj is None:
obj = 0
objHasName = False
self.geom = obj
objHasName = True
# publish geom of mesh (issue 0021122)
- if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
+ if not self.geom.GetStudyEntry():
objHasName = False
- studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
- if studyID != geompyD.myStudyId:
- geompyD.init_geom( smeshpyD.GetCurrentStudy())
- pass
+ geompyD.init_geom()
if name:
geo_name = name + " shape"
else:
self.geom = self.mesh.GetShapeToMesh()
self.editor = self.mesh.GetMeshEditor()
- self.functors = [None] * SMESH.FT_Undefined._v
+ self.functors = [None] * EnumToLong(SMESH.FT_Undefined)
# set self to algoCreator's
for attrName in dir(self):
#self.mesh.UnRegister()
pass
pass
-
+
## Initialize the Mesh object from an instance of SMESH_Mesh interface
# @param theMesh a SMESH_Mesh object
# @ingroup l2_construct
if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
self.mesh.Clear()
ok = self.smeshpyD.Compute(self.mesh, geom)
- except SALOME.SALOME_Exception, ex:
- print "Mesh computation failed, exception caught:"
- print " ", ex.details.text
+ except SALOME.SALOME_Exception as ex:
+ print("Mesh computation failed, exception caught:")
+ print(" ", ex.details.text)
except:
import traceback
- print "Mesh computation failed, exception caught:"
+ print("Mesh computation failed, exception caught:")
traceback.print_exc()
if True:#not ok:
allReasons = ""
else: msg += " has not been computed"
if allReasons != "": msg += ":"
else: msg += "."
- print msg
- print allReasons
+ print(msg)
+ print(allReasons)
pass
- if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
+ if salome.sg.hasDesktop():
if not isinstance( refresh, list): # not a call from subMesh.Compute()
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
return ok
try:
shapeText = ""
mainIOR = salome.orb.object_to_string( self.GetShape() )
- for sname in salome.myStudyManager.GetOpenStudies():
- s = salome.myStudyManager.GetStudyByName(sname)
- if not s: continue
- mainSO = s.FindObjectIOR(mainIOR)
- if not mainSO: continue
+ s = salome.myStudy
+ mainSO = s.FindObjectIOR(mainIOR)
+ if mainSO:
if subShapeID == 1:
shapeText = '"%s"' % mainSO.GetName()
subIt = s.NewChildIterator(mainSO)
continue
if ids == subShapeID:
shapeText = '"%s"' % subSO.GetName()
- break
if not shapeText:
shape = self.geompyD.GetSubShape( self.GetShape(), [subShapeID])
if shape:
pass
groups = []
- for algoName, shapes in algo2shapes.items():
+ for algoName, shapes in list(algo2shapes.items()):
while shapes:
- groupType = self.smeshpyD.EnumToLong( shapes[0].GetShapeType() )
+ groupType = EnumToLong( shapes[0].GetShapeType() )
otherTypeShapes = []
sameTypeShapes = []
group = self.geompyD.CreateGroup( self.geom, groupType )
# @ingroup l2_construct
def Clear(self, refresh=False):
self.mesh.Clear()
- if ( salome.sg.hasDesktop() and
- salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() ) ):
+ if ( salome.sg.hasDesktop() ):
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
## Remove all nodes and elements of indicated shape
# @param refresh if @c True, Object browser is automatically updated (when running in GUI)
self.mesh.ClearSubMesh(geomId)
if salome.sg.hasDesktop():
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
## Compute a tetrahedral mesh using AutomaticLength + MEFISTO + Tetrahedron
# @param fineness [0.0,1.0] defines mesh fineness
AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
status = self.mesh.AddHypothesis(geom, hyp)
else:
- status = HYP_BAD_GEOMETRY,""
+ status = HYP_BAD_GEOMETRY, ""
hyp_name = GetName( hyp )
geom_name = ""
if geom:
return self.mesh.RemoveHypothesis( shape, hyp )
hypName = GetName( hyp )
geoName = GetName( shape )
- print "WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName )
+ print("WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName ))
return None
## Get the list of hypotheses added on a geometry
## Export the mesh in a file in MED format
## allowing to overwrite the file if it exists or add the exported data to its contents
- # @param f is the file name
+ # @param fileName is the file name
# @param auto_groups boolean parameter for creating/not creating
# the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
# the typical use is auto_groups=False.
- # @param version MED format version
- # - MED_V2_1 is obsolete.
- # - MED_V2_2 means current version (kept for compatibility reasons)
- # - MED_LATEST means current version.
- # - MED_MINOR_x where x from 0 to 9 indicates the minor version of MED
- # to use for writing MED files, for backward compatibility :
- # for instance, with SALOME 8.4 use MED 3.2 (minor=2) instead of 3.3,
- # to allow the file to be read with SALOME 8.3.
# @param overwrite boolean parameter for overwriting/not overwriting the file
# @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
# @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
# - 3D in the rest cases.<br>
# If @a autoDimension is @c False, the space dimension is always 3.
# @param fields list of GEOM fields defined on the shape to mesh.
- # @param geomAssocFields each character of this string means a need to export a
+ # @param geomAssocFields each character of this string means a need to export a
# corresponding field; correspondence between fields and characters is following:
# - 'v' stands for "_vertices _" field;
# - 'e' stands for "_edges _" field;
# - 'f' stands for "_faces _" field;
# - 's' stands for "_solids _" field.
# @ingroup l2_impexp
- def ExportMED(self, f, auto_groups=0, version=MED_LATEST,
- overwrite=1, meshPart=None, autoDimension=True, fields=[], geomAssocFields=''):
+ def ExportMED(self, *args, **kwargs):
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ meshPart = args[3] if len(args) > 3 else None
+ autoDimension = args[4] if len(args) > 4 else True
+ fields = args[5] if len(args) > 5 else []
+ geomAssocFields = args[6] if len(args) > 6 else ''
+ # process keywords arguments
+ auto_groups = kwargs.get("auto_groups", auto_groups)
+ overwrite = kwargs.get("overwrite", overwrite)
+ meshPart = kwargs.get("meshPart", meshPart)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ fields = kwargs.get("fields", fields)
+ geomAssocFields = kwargs.get("geomAssocFields", geomAssocFields)
+ # invoke engine's function
if meshPart or fields or geomAssocFields:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
- self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension,
+ self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, overwrite, autoDimension,
fields, geomAssocFields)
else:
- self.mesh.ExportToMEDX(f, auto_groups, version, overwrite, autoDimension)
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
## Export the mesh in a file in SAUV format
# @param f is the file name
## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
# Export the mesh in a file in MED format
# allowing to overwrite the file if it exists or add the exported data to its contents
- # @param f the file name
- # @param version MED format version:
- # - MED_V2_1 is obsolete.
- # - MED_V2_2 means current version (kept for compatibility reasons)
- # - MED_LATEST means current version.
- # - MED_MINOR_x where x from 0 to 9 indicates the minor version of MED
- # to use for writing MED files, for backward compatibility :
- # for instance, with SALOME 8.4 use MED 3.2 (minor=2) instead of 3.3,
- # to allow the file to be read with SALOME 8.3.
+ # @param fileName the file name
+ # @param opt boolean parameter for creating/not creating
+ # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
+ # @param overwrite boolean parameter for overwriting/not overwriting the file
+ # @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
+ # - 1D if all mesh nodes lie on OX coordinate axis, or
+ # - 2D if all mesh nodes lie on XOY coordinate plane, or
+ # - 3D in the rest cases.<br>
+ # If @a autoDimension is @c False, the space dimension is always 3.
+ # @ingroup l2_impexp
+ def ExportToMED(self, *args, **kwargs):
+ print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ autoDimension = args[3] if len(args) > 3 else True
+ # process keywords arguments
+ auto_groups = kwargs.get("opt", auto_groups) # old keyword name
+ auto_groups = kwargs.get("auto_groups", auto_groups) # new keyword name
+ overwrite = kwargs.get("overwrite", overwrite)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ # invoke engine's function
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+
+ ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
+ # Export the mesh in a file in MED format
+ # allowing to overwrite the file if it exists or add the exported data to its contents
+ # @param fileName the file name
# @param opt boolean parameter for creating/not creating
# the groups Group_On_All_Nodes, Group_On_All_Faces, ...
# @param overwrite boolean parameter for overwriting/not overwriting the file
# - 3D in the rest cases.<br>
# If @a autoDimension is @c False, the space dimension is always 3.
# @ingroup l2_impexp
- def ExportToMED(self, f, version=MED_LATEST, opt=0, overwrite=1, autoDimension=True):
- self.mesh.ExportToMEDX(f, opt, version, overwrite, autoDimension)
+ def ExportToMEDX(self, *args, **kwargs):
+ print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ autoDimension = args[3] if len(args) > 3 else True
+ # process keywords arguments
+ auto_groups = kwargs.get("auto_groups", auto_groups)
+ overwrite = kwargs.get("overwrite", overwrite)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ # invoke engine's function
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
# Operations with groups:
# ----------------------
## Create an empty mesh group
- # @param elementType the type of elements in the group; either of
+ # @param elementType the type of elements in the group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME)
# @param name the name of the mesh group
# @return SMESH_Group
# the name is the same as the geometrical group name
# @param grp a geometrical group, a vertex, an edge, a face or a solid
# @param name the name of the mesh group
- # @param typ the type of elements in the group; either of
+ # @param typ the type of elements in the group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME). If not set, it is
# automatically detected by the type of the geometry
# @return SMESH_GroupOnGeom
elif tgeo == "COMPOUND":
sub = self.geompyD.SubShapeAll( shape, self.geompyD.ShapeType["SHAPE"])
if not sub:
- raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
+ raise ValueError("_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape))
return self._groupTypeFromShape( sub[0] )
else:
- raise ValueError, \
- "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
+ raise ValueError("_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape))
return typ
## Create a mesh group with given \a name based on the \a filter which
## is a special type of group dynamically updating it's contents during
## mesh modification
- # @param typ the type of elements in the group; either of
+ # @param typ the type of elements in the group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
# @param name the name of the mesh group
# @param filter the filter defining group contents
## Create a mesh group by the given ids of elements
# @param groupName the name of the mesh group
- # @param elementType the type of elements in the group; either of
+ # @param elementType the type of elements in the group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
# @param elemIDs either the list of ids, group, sub-mesh, or filter
# @return SMESH_Group
## Get the list of groups existing in the mesh in the order
# of creation (starting from the oldest one)
- # @param elemType type of elements the groups contain; either of
+ # @param elemType type of elements the groups contain; either of
# (SMESH.ALL, SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME);
# by default groups of elements of all types are returned
# @return a sequence of SMESH_GroupBase
## Find groups by name and type
# @param name name of the group of interest
- # @param elemType type of elements the groups contain; either of
+ # @param elemType type of elements the groups contain; either of
# (SMESH.ALL, SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME);
# by default one group of any type of elements is returned
# if elemType == SMESH.ALL then all groups of any type are returned
if group.GetName() == name:
if elemType is None:
return [group]
- if ( elemType == SMESH.ALL or
+ if ( elemType == SMESH.ALL or
group.GetType() == elemType ):
groups.append( group )
return groups
# @return an instance of SMESH_Group
# @ingroup l2_grps_operon
def UnionListOfGroups(self, groups, name):
- return self.mesh.UnionListOfGroups(groups, name)
+ return self.mesh.UnionListOfGroups(groups, name)
## Prodice an intersection of two groups.
# A new group is created. All mesh elements that are common
# @return an instance of SMESH_Group
# @ingroup l2_grps_operon
def IntersectListOfGroups(self, groups, name):
- return self.mesh.IntersectListOfGroups(groups, name)
+ return self.mesh.IntersectListOfGroups(groups, name)
## Produce a cut of two groups.
# A new group is created. All mesh elements that are present in
##
# Create a standalone group of entities basing on nodes of other groups.
# \param groups - list of reference groups, sub-meshes or filters, of any type.
- # \param elemType - a type of elements to include to the new group; either of
+ # \param elemType - a type of elements to include to the new group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
# \param name - a name of the new group.
# \param nbCommonNodes - a criterion of inclusion of an element to the new group
def GetId(self):
return self.mesh.GetId()
- ## Get the study Id
- # @return integer value, which is the study Id of the mesh
- # @ingroup l1_auxiliary
- def GetStudyId(self):
- return self.mesh.GetStudyId()
-
## Check the group names for duplications.
# Consider the maximum group name length stored in MED file.
# @return True or False
def Add0DElement( self, IDOfNode, DuplicateElements=True ):
return self.editor.Add0DElement( IDOfNode, DuplicateElements )
- ## Create 0D elements on all nodes of the given elements except those
+ ## Create 0D elements on all nodes of the given elements except those
# nodes on which a 0D element already exists.
# @param theObject an object on whose nodes 0D elements will be created.
# It can be mesh, sub-mesh, group, list of element IDs or a holder
# and/or found on nodes of \a theObject.
# @param DuplicateElements to add one more 0D element to a node or not
# @return an object (a new group or a temporary SMESH_IDSource) holding
- # IDs of new and/or found 0D elements. IDs of 0D elements
+ # IDs of new and/or found 0D elements. IDs of 0D elements
# can be retrieved from the returned object by calling GetIDs()
# @ingroup l2_modif_add
def Add0DElementsToAllNodes(self, theObject, theGroupName="", DuplicateElements=False):
VertexID = Vertex
try:
self.editor.SetNodeOnVertex(NodeID, VertexID)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
EdgeID = Edge
try:
self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
## @brief Stores node position on a face
FaceID = Face
try:
self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
## @brief Binds a node to a solid
SolidID = Solid
try:
self.editor.SetNodeInVolume(NodeID, SolidID)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
## @brief Bind an element to a shape
ShapeID = Shape
try:
self.editor.SetMeshElementOnShape(ElementID, ShapeID)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
# @param x the X coordinate of a point
# @param y the Y coordinate of a point
# @param z the Z coordinate of a point
- # @param elementType type of elements to find; either of
+ # @param elementType type of elements to find; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME); SMESH.ALL type
# means elements of any type excluding nodes, discrete and 0D elements.
# @param meshPart a part of mesh (group, sub-mesh) to search within
return self.editor.TriToQuadObject(theObject, Functor, MaxAngle)
## Split quadrangles into triangles.
- # @param IDsOfElements the faces to be splitted.
+ # @param IDsOfElements the faces to be split.
# @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
# choose a diagonal for splitting. If @a theCriterion is None, which is a default
# value, then quadrangles will be split by the smallest diagonal.
## Split each of given quadrangles into 4 triangles. A node is added at the center of
# a quadrangle.
- # @param theElements the faces to be splitted. This can be either mesh, sub-mesh,
+ # @param theElements the faces to be split. This can be either mesh, sub-mesh,
# group or a list of face IDs. By default all quadrangles are split
# @ingroup l2_modif_cutquadr
def QuadTo4Tri (self, theElements=[]):
return self.editor.QuadTo4Tri( theElements )
## Split quadrangles into triangles.
- # @param IDsOfElements the faces to be splitted
+ # @param IDsOfElements the faces to be split
# @param Diag13 is used to choose a diagonal for splitting.
# @return TRUE in case of success, FALSE otherwise.
# @ingroup l2_modif_cutquadr
return self.editor.SplitQuadObject(theObject, Diag13)
## Find a better splitting of the given quadrangle.
- # @param IDOfQuad the ID of the quadrangle to be splitted.
+ # @param IDOfQuad the ID of the quadrangle to be split.
# @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
# choose a diagonal for splitting.
# Type SMESH.FunctorType._items in the Python Console to see all items.
pattern = self.smeshpyD.GetPattern()
isDone = pattern.LoadFromFile(pattern_tetra)
if not isDone:
- print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
+ print('Pattern.LoadFromFile :', pattern.GetErrorCode())
return isDone
pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
isDone = pattern.MakeMesh(self.mesh, False, False)
- if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
+ if not isDone: print('Pattern.MakeMesh :', pattern.GetErrorCode())
# split quafrangle faces near triangular facets of volumes
self.SplitQuadsNearTriangularFacets()
pattern = self.smeshpyD.GetPattern()
isDone = pattern.LoadFromFile(pattern_prism)
if not isDone:
- print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
+ print('Pattern.LoadFromFile :', pattern.GetErrorCode())
return isDone
pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
isDone = pattern.MakeMesh(self.mesh, False, False)
- if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
+ if not isDone: print('Pattern.MakeMesh :', pattern.GetErrorCode())
# Split quafrangle faces near triangular facets of volumes
self.SplitQuadsNearTriangularFacets()
self.editor.ConvertToQuadratic(theForce3d)
error = self.editor.GetLastError()
if error and error.comment:
- print error.comment
+ print(error.comment)
return error
-
+
## Convert the mesh from quadratic to ordinary,
# deletes old quadratic elements, \n replacing
# them with ordinary mesh elements with the same id.
return mesh, group
##
- # @brief Create missing boundary elements around either the whole mesh or
+ # @brief Create missing boundary elements around either the whole mesh or
# groups of elements
# @param dimension - defines type of boundary elements to create, either of
# { SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D }
# @param groupName - a name of group to store all boundary elements in,
# "" means not to create the group
- # @param meshName - a name of a new mesh, which is a copy of the initial
+ # @param meshName - a name of a new mesh, which is a copy of the initial
# mesh + created boundary elements; "" means not to create the new mesh
# @param toCopyAll - if true, the whole initial mesh will be copied into
# the new mesh else only boundary elements will be copied into the new mesh
if isinstance( basePoint, int):
xyz = self.GetNodeXYZ( basePoint )
if not xyz:
- raise RuntimeError, "Invalid node ID: %s" % basePoint
+ raise RuntimeError("Invalid node ID: %s" % basePoint)
basePoint = xyz
if isinstance( basePoint, geomBuilder.GEOM._objref_GEOM_Object ):
basePoint = self.geompyD.PointCoordinates( basePoint )
Elements = [ Elements.GetMesh() ]
if isinstance( Elements, list ):
if not Elements:
- raise RuntimeError, "Elements empty!"
+ raise RuntimeError("Elements empty!")
if isinstance( Elements[0], int ):
Elements = self.GetIDSource( Elements, SMESH.ALL )
unRegister.set( Elements )
if ( isinstance( thePoint, list )):
thePoint = PointStruct( thePoint[0], thePoint[1], thePoint[2] )
if ( isinstance( theScaleFact, float )):
- theScaleFact = [theScaleFact]
+ theScaleFact = [theScaleFact]
if ( isinstance( theScaleFact, int )):
- theScaleFact = [ float(theScaleFact)]
+ theScaleFact = [ float(theScaleFact)]
self.mesh.SetParameters(thePoint.parameters)
if ( isinstance( thePoint, list )):
thePoint = PointStruct( thePoint[0], thePoint[1], thePoint[2] )
if ( isinstance( theScaleFact, float )):
- theScaleFact = [theScaleFact]
+ theScaleFact = [theScaleFact]
if ( isinstance( theScaleFact, int )):
- theScaleFact = [ float(theScaleFact)]
+ theScaleFact = [ float(theScaleFact)]
self.mesh.SetParameters(thePoint.parameters)
mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
if holeNodes and isinstance( holeNodes, list ) and isinstance( holeNodes[0], int ):
holeNodes = SMESH.FreeBorder(nodeIDs=holeNodes)
if not isinstance( holeNodes, SMESH.FreeBorder ):
- raise TypeError, "holeNodes must be either SMESH.FreeBorder or list of integer and not %s" % holeNodes
+ raise TypeError("holeNodes must be either SMESH.FreeBorder or list of integer and not %s" % holeNodes)
self.editor.FillHole( holeNodes )
## Return groups of FreeBorder's coincident within the given tolerance.
# @ingroup l2_modif_trsf
def FindCoincidentFreeBorders (self, tolerance=0.):
return self.editor.FindCoincidentFreeBorders( tolerance )
-
+
## Sew FreeBorder's of each group
# @param freeBorders either a SMESH.CoincidentFreeBorders structure or a list of lists
# where each enclosed list contains node IDs of a group of coincident free
coincidentGroups = []
for nodeList in freeBorders:
if not nodeList or len( nodeList ) % 3:
- raise ValueError, "Wrong number of nodes in this group: %s" % nodeList
+ raise ValueError("Wrong number of nodes in this group: %s" % nodeList)
group = []
while nodeList:
group.append ( SMESH.FreeBorderPart( len(borders), 0, 1, 2 ))
def ClearLastCreated(self):
self.editor.ClearLastCreated()
- ## Create duplicates of given elements, i.e. create new elements based on the
+ ## Create duplicates of given elements, i.e. create new elements based on the
# same nodes as the given ones.
# @param theElements - container of elements to duplicate. It can be a Mesh,
# sub-mesh, group, filter or a list of element IDs. If \a theElements is
# @param theGroupName - a name of group to contain the generated elements.
# If a group with such a name already exists, the new elements
# are added to the existng group, else a new group is created.
- # If \a theGroupName is empty, new elements are not added
+ # If \a theGroupName is empty, new elements are not added
# in any group.
# @return a group where the new elements are added. None if theGroupName == "".
# @ingroup l2_modif_duplicat
# @return TRUE if operation has been completed successfully, FALSE otherwise
# @ingroup l2_modif_duplicat
def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems, onAllBoundaries=False ):
- return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems, onAllBoundaries )
+ return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems, onAllBoundaries )
## Double nodes on some external faces and create flat elements.
# Flat elements are mainly used by some types of mechanic calculations.
- #
+ #
# Each group of the list must be constituted of faces.
# Triangles are transformed in prisms, and quadrangles in hexahedrons.
# @param theGroupsOfFaces - list of groups of faces
# @ingroup l2_modif_duplicat
def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
-
+
## identify all the elements around a geom shape, get the faces delimiting the hole
#
def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords):
if not fn:
fn = self.smeshpyD.GetFunctor(funcType)
fn.SetMesh(self.mesh)
- self.functors[ funcType._v ] = fn
+ self.functors[ EnumToLong(funcType) ] = fn
return fn
## Return value of a functor for a given element
# with old dump scripts which call SMESH_Mesh directly and not via smeshBuilder.Mesh
#
class meshProxy(SMESH._objref_SMESH_Mesh):
- def __init__(self):
- SMESH._objref_SMESH_Mesh.__init__(self)
+ def __init__(self, *args):
+ SMESH._objref_SMESH_Mesh.__init__(self, *args)
def __deepcopy__(self, memo=None):
- new = self.__class__()
+ new = self.__class__(self)
return new
def CreateDimGroup(self,*args): # 2 args added: nbCommonNodes, underlyingOnly
if len( args ) == 3:
args += SMESH.ALL_NODES, True
- return SMESH._objref_SMESH_Mesh.CreateDimGroup( self, *args )
+ return SMESH._objref_SMESH_Mesh.CreateDimGroup(self, *args)
+ def ExportToMEDX(self, *args): # function removed
+ print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
+ def ExportToMED(self, *args): # function removed
+ print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ while len(args) < 4: # !!!! nb of parameters for ExportToMED IDL's method
+ args.append(True)
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
+ def ExportPartToMED(self, *args): # 'version' parameter removed
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ SMESH._objref_SMESH_Mesh.ExportPartToMED(self, *args)
+ def ExportMED(self, *args): # signature of method changed
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ while len(args) < 4: # !!!! nb of parameters for ExportToMED IDL's method
+ args.append(True)
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
pass
omniORB.registerObjref(SMESH._objref_SMESH_Mesh._NP_RepositoryId, meshProxy)
## Private class wrapping SMESH.SMESH_SubMesh in order to add Compute()
#
class submeshProxy(SMESH._objref_SMESH_subMesh):
- def __init__(self):
- SMESH._objref_SMESH_subMesh.__init__(self)
+ def __init__(self, *args):
+ SMESH._objref_SMESH_subMesh.__init__(self, *args)
self.mesh = None
def __deepcopy__(self, memo=None):
- new = self.__class__()
+ new = self.__class__(self)
return new
## Compute the sub-mesh and return the status of the computation
ok = self.mesh.Compute( self.GetSubShape(),refresh=[] )
- if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
+ if salome.sg.hasDesktop():
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self ), ok, (self.GetNumberOfElements()==0) )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
pass
return ok
# smeshBuilder.Mesh
#
class meshEditor(SMESH._objref_SMESH_MeshEditor):
- def __init__(self):
- SMESH._objref_SMESH_MeshEditor.__init__(self)
+ def __init__(self, *args):
+ SMESH._objref_SMESH_MeshEditor.__init__(self, *args)
self.mesh = None
def __getattr__(self, name ): # method called if an attribute not found
if not self.mesh: # look for name() method in Mesh class
return getattr( self.mesh, name )
if name == "ExtrusionAlongPathObjX":
return getattr( self.mesh, "ExtrusionAlongPathX" ) # other method name
- print "meshEditor: attribute '%s' NOT FOUND" % name
+ print("meshEditor: attribute '%s' NOT FOUND" % name)
return None
def __deepcopy__(self, memo=None):
- new = self.__class__()
+ new = self.__class__(self)
return new
def FindCoincidentNodes(self,*args): # a 2nd arg added (SeparateCornerAndMediumNodes)
if len( args ) == 1: args += False,
# Store a python class of algorithm
def add(self, algoClass):
- if type( algoClass ).__name__ == 'classobj' and \
- hasattr( algoClass, "algoType"):
+ if inspect.isclass(algoClass) and \
+ hasattr(algoClass, "algoType"):
self.algoTypeToClass[ algoClass.algoType ] = algoClass
if not self.defaultAlgoType and \
hasattr( algoClass, "isDefault") and algoClass.isDefault:
algoType = self.defaultAlgoType
if not algoType and self.algoTypeToClass:
algoType = sorted( self.algoTypeToClass.keys() )[0]
- if self.algoTypeToClass.has_key( algoType ):
+ if algoType in self.algoTypeToClass:
#print "Create algo",algoType
+
return self.algoTypeToClass[ algoType ]( self.mesh, shape )
- raise RuntimeError, "No class found for algo type %s" % algoType
+ raise RuntimeError( "No class found for algo type %s" % algoType)
return None
## Private class used to substitute and store variable parameters of hypotheses.
except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
# maybe there is a replaced string arg which is not variable
result = self.method( self.hyp, *args )
- except ValueError, detail: # raised by ParseParameters()
+ except ValueError as detail: # raised by ParseParameters()
try:
result = self.method( self.hyp, *args )
except omniORB.CORBA.BAD_PARAM:
- raise ValueError, detail # wrong variable name
+ raise ValueError(detail) # wrong variable name
return result
pass
pluginBuilderName = pluginName + "Builder"
try:
exec( "from salome.%s.%s import *" % (pluginName, pluginBuilderName))
- except Exception, e:
- from salome_utils import verbose
- if verbose(): print "Exception while loading %s: %s" % ( pluginBuilderName, e )
+ except Exception as e:
+ from salome_utils import verbose
+ if verbose(): print("Exception while loading %s: %s" % ( pluginBuilderName, e ))
continue
exec( "from salome.%s import %s" % (pluginName, pluginBuilderName))
plugin = eval( pluginBuilderName )
if k[0] == '_': continue
algo = getattr( plugin, k )
#print " algo:", str(algo)
- if type( algo ).__name__ == 'classobj' and hasattr( algo, "meshMethod" ):
+ if inspect.isclass(algo) and hasattr(algo, "meshMethod"):
#print " meshMethod:" , str(algo.meshMethod)
if not hasattr( Mesh, algo.meshMethod ):
setattr( Mesh, algo.meshMethod, algoCreator( algo.meshMethod ))
# @ingroup l2_algorithms
class Mesh_Algorithm:
- ## Private constuctor
+ ## Private constructor
def __init__(self):
self.mesh = None
self.geom = None
# Finds only the hypotheses created in smeshpyD engine.
# @return SMESH.SMESH_Hypothesis
def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
- study = smeshpyD.GetCurrentStudy()
+ study = salome.myStudy
if not study: return None
#to do: find component by smeshpyD object, not by its data type
scomp = study.FindComponent(smeshpyD.ComponentDataType())
# Finds only the algorithms, which have been created in smeshpyD engine.
# @return SMESH.SMESH_Algo
def FindAlgorithm (self, algoname, smeshpyD):
- study = smeshpyD.GetCurrentStudy()
+ study = salome.myStudy
if not study: return None
#to do: find component by smeshpyD object, not by its data type
scomp = study.FindComponent(smeshpyD.ComponentDataType())
## Private method.
def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
if geom is None and mesh.mesh.HasShapeToMesh():
- raise RuntimeError, "Attempt to create " + hypo + " algorithm on None shape"
+ raise RuntimeError("Attempt to create " + hypo + " algorithm on None shape")
algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
if algo is None:
algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
def Assign(self, algo, mesh, geom):
from salome.smesh.smeshBuilder import AssureGeomPublished, TreatHypoStatus, GetName
if geom is None and mesh.mesh.HasShapeToMesh():
- raise RuntimeError, "Attempt to create " + algo + " algorithm on None shape"
+ raise RuntimeError("Attempt to create " + algo + " algorithm on None shape")
self.mesh = mesh
if not geom or geom.IsSame( mesh.geom ):
self.geom = mesh.geom
return
def CompareHyp (self, hyp, args):
- print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
+ print("CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName())
return False
def CompareEqualHyp (self, hyp, args):
def ViscousLayers(self, thickness, numberOfLayers, stretchFactor,
faces=[], isFacesToIgnore=True, extrMethod=StdMeshers.SURF_OFFSET_SMOOTH ):
if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
- raise TypeError, "ViscousLayers are supported by 3D algorithms only"
+ raise TypeError("ViscousLayers are supported by 3D algorithms only")
if not "ViscousLayers" in self.GetCompatibleHypothesis():
- raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
+ raise TypeError("ViscousLayers are not supported by %s"%self.algo.GetName())
if faces and isinstance( faces, geomBuilder.GEOM._objref_GEOM_Object ):
faces = [ faces ]
if faces and isinstance( faces[0], geomBuilder.GEOM._objref_GEOM_Object ):
def ViscousLayers2D(self, thickness, numberOfLayers, stretchFactor,
edges=[], isEdgesToIgnore=True ):
if not isinstance(self.algo, SMESH._objref_SMESH_2D_Algo):
- raise TypeError, "ViscousLayers2D are supported by 2D algorithms only"
+ raise TypeError("ViscousLayers2D are supported by 2D algorithms only")
if not "ViscousLayers2D" in self.GetCompatibleHypothesis():
- raise TypeError, "ViscousLayers2D are not supported by %s"%self.algo.GetName()
+ raise TypeError("ViscousLayers2D are not supported by %s"%self.algo.GetName())
if edges and not isinstance( edges, list ) and not isinstance( edges, tuple ):
edges = [edges]
if edges and isinstance( edges[0], geomBuilder.GEOM._objref_GEOM_Object ):
if isinstance( i, int ):
s = geompy.SubShapes(self.mesh.geom, [i])[0]
if s.GetShapeType() != geomBuilder.GEOM.EDGE:
- raise TypeError, "Not EDGE index given"
+ raise TypeError("Not EDGE index given")
resList.append( i )
elif isinstance( i, geomBuilder.GEOM._objref_GEOM_Object ):
if i.GetShapeType() != geomBuilder.GEOM.EDGE:
- raise TypeError, "Not an EDGE given"
+ raise TypeError("Not an EDGE given")
resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
elif len( i ) > 1:
e = i[0]
v = i[1]
if not isinstance( e, geomBuilder.GEOM._objref_GEOM_Object ) or \
not isinstance( v, geomBuilder.GEOM._objref_GEOM_Object ):
- raise TypeError, "A list item must be a tuple (edge, 1st_vertex_of_edge)"
+ raise TypeError("A list item must be a tuple (edge, 1st_vertex_of_edge)")
if v.GetShapeType() == geomBuilder.GEOM.EDGE and \
e.GetShapeType() == geomBuilder.GEOM.VERTEX:
v,e = e,v
if e.GetShapeType() != geomBuilder.GEOM.EDGE or \
v.GetShapeType() != geomBuilder.GEOM.VERTEX:
- raise TypeError, "A list item must be a tuple (edge, 1st_vertex_of_edge)"
+ raise TypeError("A list item must be a tuple (edge, 1st_vertex_of_edge)")
vFirst = FirstVertexOnCurve( self.mesh, e )
tol = geompy.Tolerance( vFirst )[-1]
if geompy.MinDistance( v, vFirst ) > 1.5*tol:
resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
else:
- raise TypeError, "Item must be either an edge or tuple (edge, 1st_vertex_of_edge)"
+ raise TypeError("Item must be either an edge or tuple (edge, 1st_vertex_of_edge)")
return resList
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Arithmetic1D.cxx
// Author : Damien COQUERET, OCC
// Module : SMESH
*/
//=============================================================================
-StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_begLength = 1.;
_endLength = 10.;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Arithmetic1D.hxx
// Author : Damien COQUERET, OCC
// Module : SMESH
public SMESH_Hypothesis
{
public:
- StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Arithmetic1D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_Arithmetic1D();
void SetLength(double length, bool isStartLength) throw(SALOME_Exception);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_AutomaticLength.cxx
// Author : Edward AGAPOV, OCC
// Module : SMESH
*/
//=============================================================================
-StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_name = "AutomaticLength";
_param_algo_dim = 1; // is used by SMESH_Regular_1D
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_AutomaticLength.hxx
// Author : Edward AGAPOV, OCC
// Module : SMESH
class STDMESHERS_EXPORT StdMeshers_AutomaticLength:public SMESH_Hypothesis
{
public:
- StdMeshers_AutomaticLength(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_AutomaticLength(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_AutomaticLength();
/*!
*/
//=============================================================================
-StdMeshers_Cartesian_3D::StdMeshers_Cartesian_3D(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_Cartesian_3D::StdMeshers_Cartesian_3D(int hypId, SMESH_Gen * gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "Cartesian_3D";
_shapeType = (1 << TopAbs_SOLID); // 1 bit /shape type
ip._faceIDs = e2fIt->second;
ip._shapeID = edgeID;
- // discretize the EGDE
+ // discretize the EDGE
GCPnts_UniformDeflection discret( curve, deflection, true );
if ( !discret.IsDone() || discret.NbPoints() < 2 )
continue;
}
//================================================================================
/*!
- * \brief Classify a point by grid paremeters
+ * \brief Classify a point by grid parameters
*/
bool Hexahedron::isOutParam(const double uvw[3]) const
{
facesItersectors[i].Intersect();
#endif
- // put interesection points onto the GridLine's; this is done after intersection
+ // put intersection points onto the GridLine's; this is done after intersection
// to avoid contention of facesItersectors for writing into the same GridLine
// in case of parallel work of facesItersectors
for ( size_t i = 0; i < facesItersectors.size(); ++i )
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_CompositeHexa_3D.cxx
// Module : SMESH
// Created : Tue Nov 25 11:04:59 2008
//================================================================================
/*!
- * \brief Convertor of a pair of integers to a sole index
+ * \brief Converter of a pair of integers to a sole index
*/
struct _Indexer
{
*/
//================================================================================
-StdMeshers_CompositeHexa_3D::StdMeshers_CompositeHexa_3D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_CompositeHexa_3D::StdMeshers_CompositeHexa_3D(int hypId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "CompositeHexa_3D";
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
if ( !fTop )
return error(COMPERR_BAD_SHAPE);
- // orient bottom egde of faces along axes of the unit box
+ // orient bottom edge of faces along axes of the unit box
fBottom->ReverseEdges();
fBack ->ReverseEdges();
fLeft ->ReverseEdges();
* \brief Computes hexahedral mesh on a box with composite sides
* \param aMesh - mesh to compute
* \param aShape - shape to mesh
- * \retval bool - succes sign
+ * \retval bool - success sign
*/
//================================================================================
myGrid.resize( myIndexer.size() );
- // strore nodes bound to the bottom edge
+ // store nodes bound to the bottom edge
mySides.GetSide( Q_BOTTOM )->StoreNodes( mesh, myGrid, myReverse );
// store the rest nodes row by row
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_CompositeBlock_3D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_CompositeHexa_3D: public SMESH_3D_Algo
{
public:
- StdMeshers_CompositeHexa_3D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_CompositeHexa_3D(int hypId, SMESH_Gen* gen);
//virtual ~StdMeshers_CompositeHexa_3D();
virtual bool Compute(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_CompositeSegment_1D.cxx
// Module : SMESH
//
//=============================================================================
StdMeshers_CompositeSegment_1D::StdMeshers_CompositeSegment_1D(int hypId,
- int studyId,
SMESH_Gen * gen)
- :StdMeshers_Regular_1D(hypId, studyId, gen)
+ :StdMeshers_Regular_1D(hypId, gen)
{
_name = AlgoName();
}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_CompositeSegment_1D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_CompositeSegment_1D: public StdMeshers_Regular_1D
{
public:
- StdMeshers_CompositeSegment_1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_CompositeSegment_1D(int hypId, SMESH_Gen* gen);
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers_Deflection1D : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers_Deflection1D : implementation of SMESH idl descriptions
// File : StdMeshers_Deflection1D.cxx
// Module : SMESH
//
//=============================================================================
StdMeshers_Deflection1D::StdMeshers_Deflection1D(int hypId,
- int studyId,
SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_value = 1.;
_name = "Deflection1D";
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers : implementation of SMESH idl descriptions
// File : StdMeshers_Deflection1D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_Deflection1D:public SMESH_Hypothesis
{
public:
- StdMeshers_Deflection1D(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_Deflection1D(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_Deflection1D();
void SetDeflection(double value) throw(SALOME_Exception);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_FixedPoints1D.cxx
// Author : Damien COQUERET, OCC
// Module : SMESH
*/
//=============================================================================
-StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, int studyId,
+StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId,
SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_name = "FixedPoints1D";
_param_algo_dim = 1;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_FixedPoints1D.hxx
// Author : Damien COQUERET, OCC
// Module : SMESH
public SMESH_Hypothesis
{
public:
- StdMeshers_FixedPoints1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_FixedPoints1D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_FixedPoints1D();
void SetPoints(std::vector<double>& listParams)
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Geometric1D.cxx
// Module : SMESH
//
*/
//=============================================================================
-StdMeshers_Geometric1D::StdMeshers_Geometric1D(int hypId, int studyId, SMESH_Gen * gen)
- :StdMeshers_Reversible1D(hypId, studyId, gen)
+StdMeshers_Geometric1D::StdMeshers_Geometric1D(int hypId, SMESH_Gen * gen)
+ :StdMeshers_Reversible1D(hypId, gen)
{
_begLength = 1.;
_ratio = 1.;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Geometric1D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_Geometric1D: public StdMeshers_Reversible1D
{
public:
- StdMeshers_Geometric1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Geometric1D(int hypId, SMESH_Gen* gen);
void SetStartLength(double length) throw(SALOME_Exception);
void SetCommonRatio(double factor) throw(SALOME_Exception);
//================================================================================
/*!
- * \brief Convertor of a pair of integers to a sole index
+ * \brief Converter of a pair of integers to a sole index
*/
struct _Indexer
{
};
//================================================================================
/*!
- * \brief Oriented convertor of a pair of integers to a sole index
+ * \brief Oriented converter of a pair of integers to a sole index
*/
class _OrientedIndexer : public _Indexer
{
//purpose :
//=======================================================================
-StdMeshers_HexaFromSkin_3D::StdMeshers_HexaFromSkin_3D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_HexaFromSkin_3D::StdMeshers_HexaFromSkin_3D(int hypId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "HexaFromSkin_3D";
}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Hexa_3D.cxx
// Moved here from SMESH_Hexa_3D.cxx
// Author : Paul RASCLE, EDF
*/
//=============================================================================
-StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, SMESH_Gen * gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "Hexa_3D";
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
//================================================================================
/*!
- * \brief Convertor of a pair of integers to a sole index
+ * \brief Converter of a pair of integers to a sole index
*/
struct _Indexer
{
TopExp::MapShapes( aShape, TopAbs_FACE, FF);
if ( FF.Extent() != 6)
{
- static StdMeshers_CompositeHexa_3D compositeHexa(_gen->GetANewId(), 0, _gen);
+ static StdMeshers_CompositeHexa_3D compositeHexa(_gen->GetANewId(), _gen);
if ( !compositeHexa.Compute( aMesh, aShape ))
return error( compositeHexa.GetComputeError() );
return true;
// ---------------------
FaceQuadStructPtr quad[ 6 ];
- StdMeshers_Quadrangle_2D quadAlgo( _gen->GetANewId(), GetStudyId(), _gen);
+ StdMeshers_Quadrangle_2D quadAlgo( _gen->GetANewId(), _gen);
for ( int i = 0; i < 6; ++i )
{
if ( !( quad[i] = FaceQuadStructPtr( quadAlgo.CheckNbEdges( aMesh, FF( i+1 ),
}
if (meshFaces.size() != 6) {
//return error(COMPERR_BAD_SHAPE, TComm(meshFaces.size())<<" instead of 6 faces in a block");
- static StdMeshers_CompositeHexa_3D compositeHexa(-10, 0, aMesh.GetGen());
+ static StdMeshers_CompositeHexa_3D compositeHexa(-10, aMesh.GetGen());
return compositeHexa.Evaluate(aMesh, aShape, aResMap);
}
static StdMeshers_HexaFromSkin_3D * algo = 0;
if ( !algo ) {
SMESH_Gen* gen = aMesh.GetGen();
- algo = new StdMeshers_HexaFromSkin_3D( gen->GetANewId(), 0, gen );
+ algo = new StdMeshers_HexaFromSkin_3D( gen->GetANewId(), gen );
}
algo->InitComputeError();
algo->Compute( aMesh, aHelper );
static StdMeshers_Prism_3D * aPrism3D = 0;
if ( !aPrism3D ) {
SMESH_Gen* gen = aMesh.GetGen();
- aPrism3D = new StdMeshers_Prism_3D( gen->GetANewId(), 0, gen );
+ aPrism3D = new StdMeshers_Prism_3D( gen->GetANewId(), gen );
}
SMESH_Hypothesis::Hypothesis_Status aStatus;
if ( aPrism3D->CheckHypothesis( aMesh, aShape, aStatus ) ) {
static StdMeshers_Prism_3D * aPrism3D = 0;
if ( !aPrism3D ) {
SMESH_Gen* gen = aMesh.GetGen();
- aPrism3D = new StdMeshers_Prism_3D( gen->GetANewId(), 0, gen );
+ aPrism3D = new StdMeshers_Prism_3D( gen->GetANewId(), gen );
}
SMESH_Hypothesis::Hypothesis_Status aStatus;
if ( aPrism3D->CheckHypothesis( aMesh, aShape, aStatus ) ) {
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Hexa_3D.hxx
// Moved here from SMESH_Hexa_3D.hxx
// Author : Paul RASCLE, EDF
class STDMESHERS_EXPORT StdMeshers_Hexa_3D : public SMESH_3D_Algo
{
public:
- StdMeshers_Hexa_3D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Hexa_3D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_Hexa_3D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers_ImportSource1D : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers_ImportSource1D : implementation of SMESH idl descriptions
// File : StdMeshers_ImportSource1D.cxx
// Module : SMESH
//
//=============================================================================
StdMeshers_ImportSource1D::StdMeshers_ImportSource1D(int hypId,
- int studyId,
SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen),
+ :SMESH_Hypothesis(hypId, gen),
_toCopyMesh(false),
_toCopyGroups(false)
{
//=============================================================================
StdMeshers_ImportSource2D::StdMeshers_ImportSource2D(int hypId,
- int studyId,
SMESH_Gen * gen)
- :StdMeshers_ImportSource1D(hypId, studyId, gen)
+ :StdMeshers_ImportSource1D(hypId, gen)
{
_name = "ImportSource2D";
_param_algo_dim = 2; // is used by StdMeshers_Import_2D;
{
// filter off deleted groups
vector<SMESH_Group*> okGroups = getValidGroups( _groups,
- _gen->GetStudyContext(_studyId),
+ _gen->GetStudyContext(),
loaded);
if ( okGroups.size() != _groups.size() )
((StdMeshers_ImportSource1D*)this)->_groups = okGroups;
vector<SMESH_Mesh*> meshes;
if ( !meshIDs.empty() )
{
- StudyContextStruct* studyContext = _gen->GetStudyContext(_studyId);
+ StudyContextStruct* studyContext = _gen->GetStudyContext();
for ( set<int>::iterator id = meshIDs.begin(); id != meshIDs.end(); ++id )
{
map<int, SMESH_Mesh*>::iterator itm = studyContext->mapMesh.begin();
int key1 = _resultGroupsStorage[i++];
int key2 = _resultGroupsStorage[i++];
pair<int, int> resMapKey( key1, key2 );
- SMESH_Mesh* mesh = getTgtMeshByKey( resMapKey, _gen->GetStudyContext(_studyId));
+ SMESH_Mesh* mesh = getTgtMeshByKey( resMapKey, _gen->GetStudyContext());
// restore mesh ids at least
_resultGroups.insert( make_pair (resMapKey,vector<SMESH_Group*>() ));
if ( key2groups == _resultGroups.end() )
return 0;
vector<SMESH_Group*> vec = getValidGroups((*key2groups).second,
- _gen->GetStudyContext(_studyId) );
+ _gen->GetStudyContext() );
if ( vec.size() != key2groups->second.size())
key2groups->second = vec;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers : implementation of SMESH idl descriptions
// File : StdMeshers_ImportSource1D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_ImportSource1D : public SMESH_Hypothesis
{
public:
- StdMeshers_ImportSource1D(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_ImportSource1D(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_ImportSource1D();
void SetGroups(const std::vector<SMESH_Group*>& groups);
class STDMESHERS_EXPORT StdMeshers_ImportSource2D : public StdMeshers_ImportSource1D
{
public:
- StdMeshers_ImportSource2D(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_ImportSource2D(int hypId, SMESH_Gen * gen);
};
#endif
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Import_1D.cxx
// Module : SMESH
//
*/
//=============================================================================
-StdMeshers_Import_1D::StdMeshers_Import_1D(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_1D_Algo(hypId, studyId, gen), _sourceHyp(0)
+StdMeshers_Import_1D::StdMeshers_Import_1D(int hypId, SMESH_Gen * gen)
+ :SMESH_1D_Algo(hypId, gen), _sourceHyp(0)
{
_name = "Import_1D";
_shapeType = (1 << TopAbs_EDGE);
"StdMeshers_Import_1D::_Listener") {}
public:
- // return poiter to a static listener
+ // return pointer to a static listener
static _Listener* get() { static _Listener theListener; return &theListener; }
static _ImportData* getImportData(const SMESH_Mesh* srcMesh, SMESH_Mesh* tgtMesh);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// Module : SMESH
//
#ifndef _SMESH_Import_1D_HXX_
class STDMESHERS_EXPORT StdMeshers_Import_1D: public SMESH_1D_Algo
{
public:
- StdMeshers_Import_1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Import_1D(int hypId, SMESH_Gen* gen);
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Import_1D2D.cxx
// Module : SMESH
//
*/
//=============================================================================
-StdMeshers_Import_1D2D::StdMeshers_Import_1D2D(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_2D_Algo(hypId, studyId, gen), _sourceHyp(0)
+StdMeshers_Import_1D2D::StdMeshers_Import_1D2D(int hypId, SMESH_Gen * gen)
+ :SMESH_2D_Algo(hypId, gen), _sourceHyp(0)
{
_name = "Import_1D2D";
_shapeType = (1 << TopAbs_FACE);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// Module : SMESH
//
#ifndef _SMESH_Import_2D_HXX_
class STDMESHERS_EXPORT StdMeshers_Import_1D2D: public SMESH_2D_Algo
{
public:
- StdMeshers_Import_1D2D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Import_1D2D(int hypId, SMESH_Gen* gen);
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_LengthFromEdges.cxx
// Moved here from SMESH_LengthFromEdges.cxx
// Author : Paul RASCLE, EDF
*/
//=============================================================================
-StdMeshers_LengthFromEdges::StdMeshers_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_LengthFromEdges::StdMeshers_LengthFromEdges(int hypId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, gen)
{
_mode =1;
_name = "LengthFromEdges";
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_LengthFromEdges.hxx
// Moved here from SMESH_LengthFromEdges.hxx
// Author : Paul RASCLE, EDF
public SMESH_Hypothesis
{
public:
- StdMeshers_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_LengthFromEdges(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_LengthFromEdges();
void SetMode(int mode)
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_LocalLength.cxx
// Moved here from SMESH_LocalLength.cxx
// Author : Paul RASCLE, EDF
*/
//=============================================================================
-StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_length = 1.;
_precision = Precision::Confusion();
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_LocalLength.hxx
// Moved here from SMESH_LocalLength.hxx
// Author : Paul RASCLE, EDF
class STDMESHERS_EXPORT StdMeshers_LocalLength: public SMESH_Hypothesis
{
public:
- StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_LocalLength(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_LocalLength();
void SetLength(double length) throw(SALOME_Exception);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_MEFISTO_2D.cxx
// Moved here from SMESH_MEFISTO_2D.cxx
// Author : Paul RASCLE, EDF
*/
//=============================================================================
-StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, int studyId, SMESH_Gen * gen):
- SMESH_2D_Algo(hypId, studyId, gen)
+StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, SMESH_Gen * gen):
+ SMESH_2D_Algo(hypId, gen)
{
_name = "MEFISTO_2D";
_shapeType = (1 << TopAbs_FACE);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_MEFISTO_2D.hxx
// Moved here from SMESH_MEFISTO_2D.hxx
// Author : Paul RASCLE, EDF
class STDMESHERS_EXPORT StdMeshers_MEFISTO_2D: public SMESH_2D_Algo
{
public:
- StdMeshers_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_MEFISTO_2D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_MEFISTO_2D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_MaxElementArea.cxx
// Moved here from SMESH_MaxElementArea.cxx
// Author : Paul RASCLE, EDF
*/
//=============================================================================
-StdMeshers_MaxElementArea::StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_MaxElementArea::StdMeshers_MaxElementArea(int hypId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, gen)
{
_maxArea =1.;
_name = "MaxElementArea";
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_MaxElementArea.hxx
// Moved here from SMESH_MaxElementArea.hxx
// Author : Paul RASCLE, EDF
class STDMESHERS_EXPORT StdMeshers_MaxElementArea:public SMESH_Hypothesis
{
public:
- StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_MaxElementArea(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_MaxElementArea();
void SetMaxArea(double maxArea) throw(SALOME_Exception);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_MaxElementVolume.cxx
// Moved here from SMESH_MaxElementVolume.cxx
// Author : Paul RASCLE, EDF
*/
//=============================================================================
-StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, gen)
{
_maxVolume = 1.;
_name = "MaxElementVolume";
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_MaxElementVolume.hxx
// Moved here from SMESH_MaxElementVolume.hxx
// Author : Paul RASCLE, EDF
public SMESH_Hypothesis
{
public:
- StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_MaxElementVolume(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_MaxElementVolume();
void SetMaxVolume(double maxVolume)
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_MaxLength.cxx
// Module : SMESH
//
*/
//=============================================================================
-StdMeshers_MaxLength::StdMeshers_MaxLength(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_MaxLength::StdMeshers_MaxLength(int hypId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_length = 1.;
_preestimated = 0.;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_MaxLength.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_MaxLength: public SMESH_Hypothesis
{
public:
- StdMeshers_MaxLength(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_MaxLength(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_MaxLength();
void SetLength(double length) throw(SALOME_Exception);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers : implementation of SMESH idl descriptions
// File : StdMeshers_NotConformAllowed.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
*/
//=============================================================================
-StdMeshers_NotConformAllowed::StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_NotConformAllowed::StdMeshers_NotConformAllowed(int hypId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, gen)
{
_name = "NotConformAllowed";
_param_algo_dim = -1;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers : implementation of SMESH idl descriptions
// File : StdMeshers_NotConformAllowed.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
public SMESH_Hypothesis
{
public:
- StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_NotConformAllowed(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_NotConformAllowed();
virtual std::ostream & SaveTo(std::ostream & save);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_NumberOfSegments.cxx
// Moved here from SMESH_NumberOfSegments.cxx
// Author : Paul RASCLE, EDF
//=============================================================================
StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId,
- int studyId,
SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, studyId, gen),
+ : SMESH_Hypothesis(hypId, gen),
_numberOfSegments(15),//issue 19923
_distrType(DT_Regular),
_scaleFactor(1.),
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_NumberOfSegments.hxx
// Moved here from SMESH_NumberOfSegments.hxx
// Author : Paul RASCLE, EDF
public SMESH_Hypothesis
{
public:
- StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_NumberOfSegments(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_NumberOfSegments();
// Builds point distribution according to passed function
*/
struct TQuadrangleAlgo : public StdMeshers_Quadrangle_2D
{
- TQuadrangleAlgo(int studyId, SMESH_Gen* gen)
- : StdMeshers_Quadrangle_2D( gen->GetANewId(), studyId, gen)
+ TQuadrangleAlgo(SMESH_Gen* gen)
+ : StdMeshers_Quadrangle_2D( gen->GetANewId(), gen)
{
}
static StdMeshers_Quadrangle_2D* instance( SMESH_Algo* fatherAlgo,
SMESH_MesherHelper* helper=0)
{
- static TQuadrangleAlgo* algo = new TQuadrangleAlgo( fatherAlgo->GetStudyId(),
- fatherAlgo->GetGen() );
+ static TQuadrangleAlgo* algo = new TQuadrangleAlgo( fatherAlgo->GetGen() );
if ( helper &&
algo->myProxyMesh &&
algo->myProxyMesh->GetMesh() != helper->GetMesh() )
{
StdMeshers_ProjectionSource1D myHyp;
- TProjction1dAlgo(int studyId, SMESH_Gen* gen)
- : StdMeshers_Projection_1D( gen->GetANewId(), studyId, gen),
- myHyp( gen->GetANewId(), studyId, gen)
+ TProjction1dAlgo(SMESH_Gen* gen)
+ : StdMeshers_Projection_1D( gen->GetANewId(), gen),
+ myHyp( gen->GetANewId(), gen)
{
StdMeshers_Projection_1D::_sourceHypo = & myHyp;
}
static TProjction1dAlgo* instance( SMESH_Algo* fatherAlgo )
{
- static TProjction1dAlgo* algo = new TProjction1dAlgo( fatherAlgo->GetStudyId(),
- fatherAlgo->GetGen() );
+ static TProjction1dAlgo* algo = new TProjction1dAlgo( fatherAlgo->GetGen() );
return algo;
}
};
{
StdMeshers_ProjectionSource2D myHyp;
- TProjction2dAlgo(int studyId, SMESH_Gen* gen)
- : StdMeshers_Projection_1D2D( gen->GetANewId(), studyId, gen),
- myHyp( gen->GetANewId(), studyId, gen)
+ TProjction2dAlgo(SMESH_Gen* gen)
+ : StdMeshers_Projection_1D2D( gen->GetANewId(), gen),
+ myHyp( gen->GetANewId(), gen)
{
StdMeshers_Projection_2D::_sourceHypo = & myHyp;
}
static TProjction2dAlgo* instance( SMESH_Algo* fatherAlgo )
{
- static TProjction2dAlgo* algo = new TProjction2dAlgo( fatherAlgo->GetStudyId(),
- fatherAlgo->GetGen() );
+ static TProjction2dAlgo* algo = new TProjction2dAlgo( fatherAlgo->GetGen() );
return algo;
}
const NSProjUtils::TNodeNodeMap& GetNodesMap()
//purpose :
//=======================================================================
-StdMeshers_Prism_3D::StdMeshers_Prism_3D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_Prism_3D::StdMeshers_Prism_3D(int hypId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "Prism_3D";
_shapeType = (1 << TopAbs_SOLID); // 1 bit per shape type
if ( side._topEdge.IsNull() )
{
- // find vertical EDGEs --- EGDEs shared with neighbor side FACEs
+ // find vertical EDGEs --- EDGEs shared with neighbor side FACEs
for ( int is2nd = 0; is2nd < 2 && isOK; ++is2nd ) // 2 adjacent neighbors
{
int di = is2nd ? 1 : -1;
if ( !botSM ) // find a proper bottom
{
bool savedSetErrorToSM = mySetErrorToSM;
- mySetErrorToSM = false; // ingore errors in initPrism()
+ mySetErrorToSM = false; // ignore errors in initPrism()
// search among meshed FACEs
list< SMESH_subMesh* >::iterator sm = meshedSubMesh.begin();
const size_t zSrc = 0, zTgt = zSize-1;
if ( zSize < 3 ) return true;
- vector< vector< gp_XYZ > > intPntsOfLayer( zSize ); // node coodinates to compute
+ vector< vector< gp_XYZ > > intPntsOfLayer( zSize ); // node coordinates to compute
// set coordinates of src and tgt nodes
for ( size_t z = 0; z < intPntsOfLayer.size(); ++z )
intPntsOfLayer[ z ].resize( myIntColumns.size() );
prepareTopBotDelaunay();
bool isErrorCorrectable = findDelaunayTriangles();
- // compute coordinates of internal nodes by projecting (transfroming) src and tgt
+ // compute coordinates of internal nodes by projecting (transforming) src and tgt
// nodes towards the central layer
vector< NSProjUtils::TrsfFinder3D > trsfOfLayer( zSize );
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Prism_3D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_Prism_3D: public SMESH_3D_Algo
{
public:
- StdMeshers_Prism_3D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Prism_3D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_Prism_3D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Projection_1D.cxx
// Module : SMESH
// Created : Fri Oct 20 11:37:07 2006
//purpose :
//=======================================================================
-StdMeshers_Projection_1D::StdMeshers_Projection_1D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_1D_Algo(hypId, studyId, gen)
+StdMeshers_Projection_1D::StdMeshers_Projection_1D(int hypId, SMESH_Gen* gen)
+ :SMESH_1D_Algo(hypId, gen)
{
_name = "Projection_1D";
_shapeType = (1 << TopAbs_EDGE); // 1 bit per shape type
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Projection_1D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_Projection_1D: public SMESH_1D_Algo
{
public:
- StdMeshers_Projection_1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Projection_1D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_Projection_1D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Projection_2D.cxx
// Module : SMESH
// Created : Fri Oct 20 11:37:07 2006
//purpose :
//=======================================================================
-StdMeshers_Projection_2D::StdMeshers_Projection_2D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_2D_Algo(hypId, studyId, gen)
+StdMeshers_Projection_2D::StdMeshers_Projection_2D(int hypId, SMESH_Gen* gen)
+ :SMESH_2D_Algo(hypId, gen)
{
_name = "Projection_2D";
_compatibleHypothesis.push_back("ProjectionSource2D");
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Projection_2D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_Projection_2D: public SMESH_2D_Algo
{
public:
- StdMeshers_Projection_2D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Projection_2D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_Projection_2D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Projection_3D.cxx
// Module : SMESH
// Created : Fri Oct 20 11:37:07 2006
//purpose :
//=======================================================================
-StdMeshers_Projection_3D::StdMeshers_Projection_3D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_Projection_3D::StdMeshers_Projection_3D(int hypId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "Projection_3D";
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit per shape type
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Projection_3D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_Projection_3D: public SMESH_3D_Algo
{
public:
- StdMeshers_Projection_3D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Projection_3D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_Projection_3D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Propagation.cxx
// Module : SMESH
//
*/
//=============================================================================
-StdMeshers_Propagation::StdMeshers_Propagation (int hypId, int studyId, SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_Propagation::StdMeshers_Propagation (int hypId, SMESH_Gen * gen)
+ : SMESH_Hypothesis(hypId, gen)
{
_name = GetName();
_param_algo_dim = -1; // 1D auxiliary
}
StdMeshers_PropagOfDistribution::StdMeshers_PropagOfDistribution (int hypId,
- int studyId,
SMESH_Gen * gen)
- : StdMeshers_Propagation(hypId, studyId, gen) { _name = GetName(); }
+ : StdMeshers_Propagation(hypId, gen) { _name = GetName(); }
StdMeshers_Propagation::~StdMeshers_Propagation() {}
string StdMeshers_Propagation::GetName () { return "Propagation"; }
string StdMeshers_PropagOfDistribution::GetName () { return "PropagOfDistribution"; }
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Propagation.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_Propagation : public SMESH_Hypothesis
{
public:
- StdMeshers_Propagation(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_Propagation(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_Propagation();
virtual std::ostream & SaveTo(std::ostream & save);
class STDMESHERS_EXPORT StdMeshers_PropagOfDistribution: public StdMeshers_Propagation
{
public:
- StdMeshers_PropagOfDistribution(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_PropagOfDistribution(int hypId, SMESH_Gen * gen);
static std::string GetName();
};
class StdMeshers_QuadFromMedialAxis_1D2D::Algo1D : public StdMeshers_Regular_1D
{
public:
- Algo1D(int studyId, SMESH_Gen* gen):
- StdMeshers_Regular_1D( gen->GetANewId(), studyId, gen )
+ Algo1D(SMESH_Gen* gen):
+ StdMeshers_Regular_1D( gen->GetANewId(), gen )
{
}
void SetSegmentLength( double len )
//================================================================================
StdMeshers_QuadFromMedialAxis_1D2D::StdMeshers_QuadFromMedialAxis_1D2D(int hypId,
- int studyId,
SMESH_Gen* gen)
- : StdMeshers_Quadrangle_2D(hypId, studyId, gen),
+ : StdMeshers_Quadrangle_2D(hypId, gen),
_regular1D( 0 )
{
_name = "QuadFromMedialAxis_1D2D";
}
// cout << "from salome.geom import geomBuilder" << endl;
- // cout << "geompy = geomBuilder.New(salome.myStudy)" << endl;
+ // cout << "geompy = geomBuilder.New()" << endl;
Handle(TColgp_HArray1OfPnt) points = new TColgp_HArray1OfPnt(1, pnt.size());
for ( size_t i = 0; i < pnt.size(); ++i )
{
* \param [in] theDivPoints - projections of VERTEXes to MA
* \param [in] theSinuEdges - the sinuous EDGEs
* \param [in] theSideEdgeIDs - indices of sinuous EDGEs per side
- * \param [in] theIsEdgeComputed - is sinuous EGDE is meshed
+ * \param [in] theIsEdgeComputed - is sinuous EDGE is meshed
* \param [in,out] thePointsOnE - the map to fill
* \param [out] theNodes2Merge - the map of nodes to merge
*/
//================================================================================
/*!
* \brief Divide the sinuous EDGEs by projecting the division point of Medial
- * Axis to the EGDEs
+ * Axis to the EDGEs
* \param [in] theHelper - the helper
* \param [in] theMinSegLen - minimal segment length
* \param [in] theMA - the Medial Axis
SMESH_MAT2d::MedialAxis ma( F, sinuFace._sinuEdges, minSegLen, /*ignoreCorners=*/true );
if ( !_regular1D )
- _regular1D = new Algo1D( _studyId, _gen );
+ _regular1D = new Algo1D( _gen );
_regular1D->SetSegmentLength( minSegLen );
vector<double> maParams;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers_QuadranglePreference : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers_QuadranglePreference : implementation of SMESH idl descriptions
// File : StdMeshers_QuadranglePreference.cxx
// Module : SMESH
//
//=============================================================================
StdMeshers_QuadranglePreference::StdMeshers_QuadranglePreference(int hypId,
- int studyId,
SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_name = "QuadranglePreference";
_param_algo_dim = -2; // auxiliary used by NETGEN 2D
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers : implementation of SMESH idl descriptions
// File : StdMeshers_QuadranglePreference.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_QuadranglePreference:public SMESH_Hypothesis
{
public:
- StdMeshers_QuadranglePreference(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_QuadranglePreference(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_QuadranglePreference();
virtual std::ostream & SaveTo(std::ostream & save);
*/
//=============================================================================
-StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId,
+StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId,
SMESH_Gen* gen)
- : SMESH_2D_Algo(hypId, studyId, gen),
+ : SMESH_2D_Algo(hypId, gen),
myQuadranglePreference(false),
myTrianglePreference(false),
myTriaVertexID(-1),
// | | | |
// | |C | |
// | L | | R |
- // left | |__| | rigth
+ // left | |__| | right
// | / \ |
// | / C \ |
// |/ \|
// | |__| |
// | / \ |
// | / C \ |
- // left |/________\| rigth
+ // left |/________\| right
// | |
// | C |
// | |
// | | | |
// | | | |
// | L | | R |
- // left | | | | rigth
+ // left | | | | right
// | / \ |
// | / C \ |
// |/ \|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers_QuadraticMesh : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers_QuadraticMesh : implementation of SMESH idl descriptions
// File : StdMeshers_QuadraticMesh.cxx
// Module : SMESH
//
//=============================================================================
StdMeshers_QuadraticMesh::StdMeshers_QuadraticMesh(int hypId,
- int studyId,
SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_name = "QuadraticMesh";
_param_algo_dim = -1; // it means auxiliary, dim = 1
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers : implementation of SMESH idl descriptions
// File : StdMeshers_QuadraticMesh.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_QuadraticMesh:public SMESH_Hypothesis
{
public:
- StdMeshers_QuadraticMesh(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_QuadraticMesh(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_QuadraticMesh();
virtual std::ostream & SaveTo(std::ostream & save);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_RadialPrism_3D.cxx
// Module : SMESH
// Created : Fri Oct 20 11:37:07 2006
//purpose :
//=======================================================================
-StdMeshers_RadialPrism_3D::StdMeshers_RadialPrism_3D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_RadialPrism_3D::StdMeshers_RadialPrism_3D(int hypId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "RadialPrism_3D";
_shapeType = (1 << TopAbs_SOLID); // 1 bit per shape type
const int myID = -1000;
TNodeDistributor* myHyp = dynamic_cast<TNodeDistributor*>( aMesh.GetHypothesis( myID ));
if ( !myHyp )
- myHyp = new TNodeDistributor( myID, 0, aMesh.GetGen() );
+ myHyp = new TNodeDistributor( myID, aMesh.GetGen() );
return myHyp;
}
// -----------------------------------------------------------------------------
}
protected:
// -----------------------------------------------------------------------------
- TNodeDistributor( int hypId, int studyId, SMESH_Gen* gen)
- : StdMeshers_Regular_1D( hypId, studyId, gen)
+ TNodeDistributor( int hypId, SMESH_Gen* gen)
+ : StdMeshers_Regular_1D( hypId, gen)
{
}
// -----------------------------------------------------------------------------
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_RadialPrism_3D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_RadialPrism_3D: public SMESH_3D_Algo
{
public:
- StdMeshers_RadialPrism_3D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_RadialPrism_3D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_RadialPrism_3D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_RadialQuadrangle_1D2D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_RadialQuadrangle_1D2D: public StdMeshers_Quadrangle_2D
{
public:
- StdMeshers_RadialQuadrangle_1D2D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_RadialQuadrangle_1D2D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_RadialQuadrangle_1D2D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Regular_1D.hxx
// Moved here from SMESH_Regular_1D.hxx
// Author : Paul RASCLE, EDF
class STDMESHERS_EXPORT StdMeshers_Regular_1D: public SMESH_1D_Algo
{
public:
- StdMeshers_Regular_1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Regular_1D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_Regular_1D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Reversible1D.cxx
// Module : SMESH
//
*/
//=============================================================================
-StdMeshers_Reversible1D::StdMeshers_Reversible1D(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_Reversible1D::StdMeshers_Reversible1D(int hypId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_param_algo_dim = 1;
}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_Reversible1D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_Reversible1D : public SMESH_Hypothesis
{
public:
- StdMeshers_Reversible1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_Reversible1D(int hypId, SMESH_Gen* gen);
void SetReversedEdges( const std::vector<int>& ids);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_SegmentAroundVertex_0D.cxx
// Module : SMESH
// Created : Fri Oct 20 11:37:07 2006
//=======================================================================
StdMeshers_SegmentAroundVertex_0D::StdMeshers_SegmentAroundVertex_0D
- (int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_0D_Algo(hypId, studyId, gen)
+ (int hypId, SMESH_Gen* gen)
+ :SMESH_0D_Algo(hypId, gen)
{
_name = "SegmentAroundVertex_0D";
// it is assigned to vertices but influence a state of EDGE submeshes
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_SegmentAroundVertex_0D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_SegmentAroundVertex_0D: public SMESH_0D_Algo
{
public:
- StdMeshers_SegmentAroundVertex_0D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_SegmentAroundVertex_0D(int hypId, SMESH_Gen* gen);
virtual ~StdMeshers_SegmentAroundVertex_0D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_SegmentLengthAroundVertex.cxx
// Module : SMESH
//
//=============================================================================
StdMeshers_SegmentLengthAroundVertex::StdMeshers_SegmentLengthAroundVertex
- (int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+ (int hypId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_length = 1.;
_name = "SegmentLengthAroundVertex";
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_SegmentLengthAroundVertex.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
class STDMESHERS_EXPORT StdMeshers_SegmentLengthAroundVertex:public SMESH_Hypothesis
{
public:
- StdMeshers_SegmentLengthAroundVertex(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_SegmentLengthAroundVertex(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_SegmentLengthAroundVertex();
void SetLength(double length) throw(SALOME_Exception);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers_StartEndLength : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers_StartEndLength : implementation of SMESH idl descriptions
// File : StdMeshers_StartEndLength.cxx
// Module : SMESH
//
//=============================================================================
StdMeshers_StartEndLength::StdMeshers_StartEndLength(int hypId,
- int studyId,
SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_begLength = 1.;
_endLength = 10.;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers : implementation of SMESH idl descriptions
// File : StdMeshers_StartEndLength.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
{
public:
- StdMeshers_StartEndLength(int hypId, int studyId, SMESH_Gen * gen);
+ StdMeshers_StartEndLength(int hypId, SMESH_Gen * gen);
virtual ~ StdMeshers_StartEndLength();
void SetLength(double length, bool isStartLength) throw(SALOME_Exception);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_UseExisting_1D2D.cxx
// Module : SMESH
// Created : Fri Oct 20 11:37:07 2006
//=======================================================================
StdMeshers_UseExisting_1D::StdMeshers_UseExisting_1D
- (int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_1D_Algo(hypId, studyId, gen)
+ (int hypId, SMESH_Gen* gen)
+ :SMESH_1D_Algo(hypId, gen)
{
_name = "UseExisting_1D";
_shapeType = (1 << TopAbs_EDGE); // 1 bit per shape type
//=======================================================================
StdMeshers_UseExisting_2D::StdMeshers_UseExisting_2D
- (int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_2D_Algo(hypId, studyId, gen)
+ (int hypId, SMESH_Gen* gen)
+ :SMESH_2D_Algo(hypId, gen)
{
_name = "UseExisting_2D";
_shapeType = (1 << TopAbs_FACE); // 1 bit per shape type
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_UseExisting_1D2D.hxx
// Module : SMESH
//
class STDMESHERS_EXPORT StdMeshers_UseExisting_2D: public SMESH_2D_Algo
{
public:
- StdMeshers_UseExisting_2D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_UseExisting_2D(int hypId, SMESH_Gen* gen);
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
class STDMESHERS_EXPORT StdMeshers_UseExisting_1D: public SMESH_1D_Algo
{
public:
- StdMeshers_UseExisting_1D(int hypId, int studyId, SMESH_Gen* gen);
+ StdMeshers_UseExisting_1D(int hypId, SMESH_Gen* gen);
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
// Convex FACEs whose radius of curvature is less than the thickness of layers
map< TGeomID, _ConvexFace > _convexFaces;
- // shapes (EDGEs and VERTEXes) srink from which is forbidden due to collisions with
+ // shapes (EDGEs and VERTEXes) shrink from which is forbidden due to collisions with
// the adjacent SOLID
set< TGeomID > _noShrinkShapes;
//================================================================================
// StdMeshers_ViscousLayers hypothesis
//
-StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_Hypothesis(hypId, studyId, gen),
+StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, SMESH_Gen* gen)
+ :SMESH_Hypothesis(hypId, gen),
_isToIgnoreShapes(1), _nbLayers(1), _thickness(1), _stretchFactor(1),
_method( SURF_OFFSET_SMOOTH )
{
py = _pyStream = new ofstream(fname);
*py << "import SMESH" << endl
<< "from salome.smesh import smeshBuilder" << endl
- << "smesh = smeshBuilder.New(salome.myStudy)" << endl
- << "meshSO = smesh.GetCurrentStudy().FindObjectID('0:1:2:" << tag <<"')" << endl
+ << "smesh = smeshBuilder.New()" << endl
+ << "meshSO = salome.myStudy.FindObjectID('0:1:2:" << tag <<"')" << endl
<< "mesh = smesh.Mesh( meshSO.GetObject() )"<<endl;
theNbPyFunc = 0;
}
}
- // Fill _eosC1 to make that C1 FACEs and EGDEs between them to be smoothed as a whole
+ // Fill _eosC1 to make that C1 FACEs and EDGEs between them to be smoothed as a whole
TopTools_MapOfShape c1VV;
//================================================================================
/*!
- * \brief DEBUG. Create groups contating temorary data of _LayerEdge's
+ * \brief DEBUG. Create groups containing temporary data of _LayerEdge's
*/
//================================================================================
src2->GetID() < edge->_nodes[0]->GetID() )
continue; // avoid using same segment twice
- // a _LayerEdge containg tgt2
+ // a _LayerEdge containing tgt2
_LayerEdge* neiborEdge = edge->_2neibors->_edges[j];
_TmpMeshFaceOnEdge* f = new _TmpMeshFaceOnEdge( edge, neiborEdge, --_tmpFaceID );
vector< _EdgesOnShape* > subEOS;
vector< _LayerEdge* > lEdges;
- // loop on FACEs to srink mesh on
+ // loop on FACEs to shrink mesh on
map< TGeomID, list< _SolidData* > >::iterator f2sd = f2sdMap.begin();
for ( ; f2sd != f2sdMap.end(); ++f2sd )
{
if ( eos.SWOLType() == TopAbs_EDGE )
{
SMESH_subMesh* edgeSM = _mesh->GetSubMesh( eos._sWOL );
- _Shrinker1D& srinker = e2shrMap[ edgeSM->GetId() ];
- eShri1D.insert( & srinker );
- srinker.AddEdge( eos._edges[0], eos, helper );
+ _Shrinker1D& shrinker = e2shrMap[ edgeSM->GetId() ];
+ eShri1D.insert( & shrinker );
+ shrinker.AddEdge( eos._edges[0], eos, helper );
VISCOUS_3D::ToClearSubWithMain( edgeSM, data._solid );
- // restore params of nodes on EGDE if the EDGE has been already
- // srinked while srinking other FACE
- srinker.RestoreParams();
+ // restore params of nodes on EDGE if the EDGE has been already
+ // shrinked while shrinking other FACE
+ shrinker.RestoreParams();
}
for ( size_t i = 0; i < eos._edges.size(); ++i )
{
if ( data2 )
VISCOUS_3D::ToClearSubWithMain( sm, data2->_solid );
- } // loop on FACES to srink mesh on
+ } // loop on FACES to shrink mesh on
// Replace source nodes by target nodes in shrinked mesh edges
//================================================================================
/*!
- * \brief Try to fix triangles with high aspect ratio by swaping diagonals
+ * \brief Try to fix triangles with high aspect ratio by swapping diagonals
*/
//================================================================================
*/
struct _Segment
{
- const gp_XY* _uv[2]; // poiter to _LayerEdge::_uvIn
+ const gp_XY* _uv[2]; // pointer to _LayerEdge::_uvIn
int _indexInLine; // position in _PolyLine
_Segment() {}
//================================================================================
// StdMeshers_ViscousLayers hypothesis
//
-StdMeshers_ViscousLayers2D::StdMeshers_ViscousLayers2D(int hypId, int studyId, SMESH_Gen* gen)
- :StdMeshers_ViscousLayers(hypId, studyId, gen)
+StdMeshers_ViscousLayers2D::StdMeshers_ViscousLayers2D(int hypId, SMESH_Gen* gen)
+ :StdMeshers_ViscousLayers(hypId, gen)
{
_name = StdMeshers_ViscousLayers2D::GetHypType();
_param_algo_dim = -2; // auxiliary hyp used by 2D algos
// --------------------------------------------------------------------------------
void StdMeshers_ViscousLayers2D::RestoreListeners() const
{
- StudyContextStruct* sc = _gen->GetStudyContext( _studyId );
+ StudyContextStruct* sc = _gen->GetStudyContext();
std::map < int, SMESH_Mesh * >::iterator i_smesh = sc->mapMesh.begin();
for ( ; i_smesh != sc->mapMesh.end(); ++i_smesh )
{
#include <SVTK_ViewWindow.h>
#include <SALOME_ListIO.hxx>
- // SALOME KERNEL incldues
+ // SALOME KERNEL includes
#include <SALOMEDSClient_SObject.hxx>
#include <SALOMEDSClient_Study.hxx>
for ( unsigned i = 0; i < objects->length(); ++i )
{
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
_PTR(SObject) aSObj = aStudy->FindObjectID(objects[i].in());
- CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
+ CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
if ( !CORBA::is_nil( anObj )) {
std::string name = aSObj->GetName();
QString text = myObjNameLineEdit->text();
//================================================================================
/*!
- * \brief Allow modifing myCustomWidgets in const methods
+ * \brief Allow modifying myCustomWidgets in const methods
* \retval ListOfWidgets* - non-const pointer to myCustomWidgets
*/
//================================================================================
GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
GEOM::GEOM_IShapesOperations_wrap shapeOp;
if ( !geomGen->_is_nil() && aStudy )
- shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
+ shapeOp = geomGen->GetIShapesOperations();
if ( !shapeOp->_is_nil() )
{
GEOM::ListOfLong_var vertices =
//================================================================================
/*!
* \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
- * from message resouce file
+ * from message resource file
* \param t - hypothesis type
* \retval QString - result string
*/
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_ObjRefUlils.cxx
// Created : Wed Oct 18 15:38:22 2006
// Author : Edward AGAPOV (eap)
// try by entry
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
- SALOMEDS::Study_var study = gen->GetCurrentStudy();
- if ( ! theEntry.empty() && ! study->_is_nil() ) {
- SALOMEDS::SObject_wrap sobj = study->FindObjectID( theEntry.c_str() );
+ if ( ! theEntry.empty() ) {
+ SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() );
CORBA::Object_var obj = gen->SObjectToObject( sobj );
geom = GEOM::GEOM_Object::_narrow( obj );
}
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
GEOM::GEOM_Object_var geom = gen->ShapeToGeomObject( theShape );
if ( ! geom->_is_nil() ) {
- SALOMEDS::SObject_wrap sobj = gen->ObjectToSObject( gen->GetCurrentStudy(), geom );
+ SALOMEDS::SObject_wrap sobj = gen->ObjectToSObject( geom );
if ( !sobj->_is_nil() ) {
CORBA::String_var entry = sobj->GetID();
stream << " " << entry.in();
if ( entry )
* entry = str;
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
- SALOMEDS::Study_var study = gen->GetCurrentStudy();
- if ( ! study->_is_nil() ) {
- SALOMEDS::SObject_wrap sobj = study->FindObjectID( str.c_str() );
- CORBA::Object_var obj = gen->SObjectToObject( sobj );
- GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj );
- return gen->GeomObjectToShape( geom.in() );
- }
+ SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( str.c_str() );
+ CORBA::Object_var obj = gen->SObjectToObject( sobj );
+ GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj );
+ return gen->GeomObjectToShape( geom.in() );
}
}
if ( entry )
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH SMESH : implementaion of SMESH idl descriptions
+ // SMESH SMESH : implementation of SMESH idl descriptions
// File : StdMeshers_ObjRefUlils.hxx
// Created : Wed Oct 18 15:15:27 2006
// Author : Edward AGAPOV (eap)
{
public:
/*!
- * \brief Return GEOM Object correspoding to TopoDS_Shape
+ * \brief Return GEOM Object corresponding to TopoDS_Shape
* \param theShape - input TopoDS_Shape
* \retval GEOM::GEOM_Object_ptr - result object
*/
}
/*!
- * \brief Return TopoDS_Shape correspoding to GEOM_Object
+ * \brief Return TopoDS_Shape corresponding to GEOM_Object
* \param theGeomObject - input object
* \retval TopoDS_Shape - result TopoDS_Shape
*/
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
std::string str;
if (stream >> str) {
- if ( StudyContext* myStudyContext = gen->GetCurrentStudyContext() ) {
+ if ( StudyContext* myStudyContext = gen->GetStudyContext() ) {
std::string ior = myStudyContext->getIORbyOldId( atoi( str.c_str() ));
if ( !ior.empty() )
return TInterface::_narrow(gen->GetORB()->string_to_object( ior.c_str() ));
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
- // SMESH StdMeshers : implementaion of SMESH idl descriptions
+ // SMESH StdMeshers : implementation of SMESH idl descriptions
// File : StdMeshers_i.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
{
public:
virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
- int theStudyId,
::SMESH_Gen* theGenImpl)
{
StdMeshers_QuadrangleParams_i* h =
- new StdMeshers_QuadrangleParams_i( thePOA, theStudyId, theGenImpl);
+ new StdMeshers_QuadrangleParams_i( thePOA, theGenImpl);
h->SetQuadType( TYPE );
return h;
}