mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 18:30:35 +05:00
21948: EDF SMESH : Memory is not freed when deleting a mesh
Elimenate memory leaks on CORBA objects, servants of SALOMEDS objects etc
This commit is contained in:
parent
873eca935e
commit
b3aa30bca3
@ -347,13 +347,11 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
|
||||
|
||||
SMESHGUI::Modified();
|
||||
|
||||
#ifdef WITHGENERICOBJ
|
||||
// obj has been published in study. Its refcount has been incremented.
|
||||
// It is safe to decrement its refcount
|
||||
// so that it will be destroyed when the entry in study will be removed
|
||||
if (!CORBA::is_nil(aCompoundMesh))
|
||||
aCompoundMesh->UnRegister();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
// SALOME GEOM includes
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOM_GenericObjPtr.h>
|
||||
|
||||
// SALOME KERNEL includes
|
||||
#include <SALOMEDS_SObject.hxx>
|
||||
@ -114,10 +115,11 @@ namespace SMESH
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
if (!aStudy || geomGen->_is_nil())
|
||||
return GEOM::GEOM_Object::_nil();
|
||||
GEOM::GEOM_IShapesOperations_var aShapesOp = geomGen->GetIShapesOperations(aStudy->StudyId());
|
||||
GEOM::GEOM_IShapesOperations_wrap aShapesOp =
|
||||
geomGen->GetIShapesOperations(aStudy->StudyId());
|
||||
if (aShapesOp->_is_nil())
|
||||
return GEOM::GEOM_Object::_nil();
|
||||
GEOM::GEOM_Object_var subShape = aShapesOp->GetSubShape (theMainShape,theID);
|
||||
GEOM::GEOM_Object_wrap subShape = aShapesOp->GetSubShape (theMainShape,theID);
|
||||
return subShape._retn();
|
||||
}
|
||||
} // end of namespace SMESH
|
||||
|
@ -44,6 +44,7 @@
|
||||
// SALOME GEOM includes
|
||||
#include <GEOMBase.h>
|
||||
#include <GEOM_SelectionFilter.h>
|
||||
#include <GEOM_GenericObjPtr.h>
|
||||
|
||||
// SALOME GUI includes
|
||||
#include <QtxColorButton.h>
|
||||
@ -1033,8 +1034,6 @@ bool SMESHGUI_GroupDlg::onApply()
|
||||
return false;
|
||||
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
GEOM::GEOM_IGroupOperations_var aGroupOp =
|
||||
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
|
||||
|
||||
if (myGeomObjects->length() == 1) {
|
||||
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
|
||||
@ -1053,8 +1052,7 @@ bool SMESHGUI_GroupDlg::onApply()
|
||||
if (geomGen->_is_nil() || !aStudy)
|
||||
return false;
|
||||
|
||||
GEOM::GEOM_IGroupOperations_var op =
|
||||
geomGen->GetIGroupOperations(aStudy->StudyId());
|
||||
GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId());
|
||||
if (op->_is_nil())
|
||||
return false;
|
||||
|
||||
@ -1071,8 +1069,8 @@ bool SMESHGUI_GroupDlg::onApply()
|
||||
}
|
||||
}
|
||||
|
||||
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
|
||||
GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
|
||||
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
|
||||
GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
|
||||
op->UnionList(aGroupVar, myGeomObjects);
|
||||
|
||||
if (op->IsDone()) {
|
||||
@ -1373,15 +1371,19 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
||||
|
||||
// Check if group constructed on the same shape as a mesh or on its child
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
GEOM::GEOM_IGroupOperations_var anOp =
|
||||
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
|
||||
|
||||
// The main shape of the group
|
||||
GEOM::GEOM_Object_var aGroupMainShape;
|
||||
if (aGeomGroup->GetType() == 37)
|
||||
GEOM::GEOM_Object_wrap aGroupMainShape;
|
||||
if (aGeomGroup->GetType() == 37) {
|
||||
GEOM::GEOM_IGroupOperations_wrap anOp =
|
||||
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
|
||||
aGroupMainShape = anOp->GetMainShape(aGeomGroup);
|
||||
else
|
||||
aGroupMainShape = GEOM::GEOM_Object::_duplicate(aGeomGroup);
|
||||
// aGroupMainShape is a new geom servant to be deleted by GEOM_Object_wrap
|
||||
}
|
||||
else {
|
||||
aGroupMainShape = aGeomGroup;
|
||||
aGroupMainShape->Register();
|
||||
}
|
||||
_PTR(SObject) aGroupMainShapeSO =
|
||||
aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
|
||||
|
||||
@ -1951,7 +1953,7 @@ void SMESHGUI_GroupDlg::onAdd()
|
||||
|
||||
} else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) {
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
GEOM::GEOM_IGroupOperations_var aGroupOp =
|
||||
GEOM::GEOM_IGroupOperations_wrap aGroupOp =
|
||||
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
|
||||
|
||||
SMESH::ElementType aGroupType = SMESH::ALL;
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOM_SelectionFilter.h>
|
||||
#include <GEOM_GenericObjPtr.h>
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_OverrideCursor.h>
|
||||
@ -204,7 +205,7 @@ LightApp_Dialog* SMESHGUI_GroupOnShapeOp::dlg() const
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
static SMESH::ElementType elementType(GEOM::GEOM_Object_var& geom)
|
||||
static SMESH::ElementType elementType(GEOM::GEOM_Object_var geom)
|
||||
{
|
||||
if ( !geom->_is_nil() ) {
|
||||
switch ( geom->GetShapeType() ) {
|
||||
@ -219,17 +220,17 @@ static SMESH::ElementType elementType(GEOM::GEOM_Object_var& geom)
|
||||
default: return SMESH::ALL;
|
||||
}
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
GEOM::GEOM_IShapesOperations_var aShapeOp =
|
||||
GEOM::GEOM_IShapesOperations_wrap aShapeOp =
|
||||
SMESH::GetGEOMGen()->GetIShapesOperations(aStudy->StudyId());
|
||||
|
||||
if ( geom->GetType() == 37 ) { // geom group
|
||||
GEOM::GEOM_IGroupOperations_var aGroupOp =
|
||||
GEOM::GEOM_IGroupOperations_wrap aGroupOp =
|
||||
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
|
||||
if ( !aGroupOp->_is_nil() ) {
|
||||
GEOM::GEOM_Object_var mainShape = aGroupOp->GetMainShape( geom );
|
||||
GEOM::ListOfLong_var ids = aGroupOp->GetObjects( geom );
|
||||
GEOM::GEOM_Object_wrap mainShape = aGroupOp->GetMainShape( geom );
|
||||
GEOM::ListOfLong_var ids = aGroupOp->GetObjects( geom );
|
||||
if ( ids->length() && !mainShape->_is_nil() && !aShapeOp->_is_nil() ) {
|
||||
GEOM::GEOM_Object_var member = aShapeOp->GetSubShape( mainShape, ids[0] );
|
||||
GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( mainShape, ids[0] );
|
||||
return elementType( member );
|
||||
}
|
||||
}
|
||||
@ -237,7 +238,7 @@ static SMESH::ElementType elementType(GEOM::GEOM_Object_var& geom)
|
||||
else if ( !aShapeOp->_is_nil() ) { // just a compoud shape
|
||||
GEOM::ListOfLong_var ids = aShapeOp->SubShapeAllIDs( geom, GEOM::SHAPE, false );
|
||||
if ( ids->length() ) {
|
||||
GEOM::GEOM_Object_var member = aShapeOp->GetSubShape( geom, ids[0] );
|
||||
GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( geom, ids[0] );
|
||||
return elementType( member );
|
||||
}
|
||||
}
|
||||
|
@ -51,23 +51,32 @@
|
||||
#define SPACING 6
|
||||
#define MARGIN 11
|
||||
|
||||
//To disable automatic genericobj management, the following line should be commented.
|
||||
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
|
||||
#define WITHGENERICOBJ
|
||||
|
||||
SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
|
||||
: myHypType( theHypType ), myIsCreate( false ), myDlg( 0 )
|
||||
: myToDeleteInitParamsHypo( false ),
|
||||
myHypType( theHypType ),
|
||||
myIsCreate( false ),
|
||||
myDlg( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
|
||||
{
|
||||
if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
|
||||
myInitParamsHypo->UnRegister();
|
||||
}
|
||||
|
||||
void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
|
||||
{
|
||||
if ( !CORBA::is_nil( hyp ) && hypType() == hyp->GetName() )
|
||||
myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
|
||||
if ( !CORBA::is_nil( hyp ) ) {
|
||||
if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
|
||||
myInitParamsHypo->UnRegister();
|
||||
CORBA::String_var hypName = hyp->GetName();
|
||||
if ( hypType() == hypName.in() )
|
||||
{
|
||||
myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
|
||||
myToDeleteInitParamsHypo = !SMESH::FindSObject( myInitParamsHypo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
|
||||
@ -91,19 +100,15 @@ void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
|
||||
if (isAlgo) {
|
||||
SMESH::SMESH_Hypothesis_var anAlgo =
|
||||
SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
|
||||
#ifdef WITHGENERICOBJ
|
||||
if (!CORBA::is_nil(anAlgo))
|
||||
anAlgo->UnRegister();
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
SMESH::SMESH_Hypothesis_var aHypothesis =
|
||||
SMESH::CreateHypothesis( hypType(), theHypName, false );
|
||||
editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
|
||||
#ifdef WITHGENERICOBJ
|
||||
if (!CORBA::is_nil(aHypothesis))
|
||||
aHypothesis->UnRegister();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,9 +133,7 @@ void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
|
||||
{
|
||||
myHypName = theHypName;
|
||||
myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
|
||||
#ifdef WITHGENERICOBJ
|
||||
myHypo->Register();
|
||||
#endif
|
||||
|
||||
SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
|
||||
connect( Dlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
|
||||
@ -302,9 +305,7 @@ void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
|
||||
}
|
||||
}
|
||||
SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
|
||||
#ifdef WITHGENERICOBJ
|
||||
myHypo->UnRegister();
|
||||
#endif
|
||||
myHypo = SMESH::SMESH_Hypothesis::_nil();
|
||||
myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
|
||||
|
||||
|
@ -612,23 +612,21 @@ namespace SMESH
|
||||
return res < SMESH::HYP_UNKNOWN_FATAL;
|
||||
}
|
||||
|
||||
bool RemoveHypothesisOrAlgorithmOnMesh (_PTR(SObject) MorSM,
|
||||
bool RemoveHypothesisOrAlgorithmOnMesh (_PTR(SObject) MorSM,
|
||||
SMESH::SMESH_Hypothesis_ptr anHyp)
|
||||
{
|
||||
SALOMEDS::GenericAttribute_var anAttr;
|
||||
SALOMEDS::AttributeIOR_var anIOR;
|
||||
int res = SMESH::HYP_UNKNOWN_FATAL;
|
||||
SUIT_OverrideCursor wc;
|
||||
|
||||
if (MorSM) {
|
||||
try {
|
||||
GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM);
|
||||
SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
|
||||
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
|
||||
|
||||
SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
|
||||
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
|
||||
|
||||
if (!aSubMesh->_is_nil())
|
||||
aMesh = aSubMesh->GetFather();
|
||||
|
||||
|
||||
if (!aMesh->_is_nil()) {
|
||||
if (aMesh->HasShapeToMesh() && !aShapeObject->_is_nil()) {
|
||||
res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <GEOM_SelectionFilter.h>
|
||||
#include <GEOMBase.h>
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOM_GenericObjPtr.h>
|
||||
|
||||
// SALOME GUI includes
|
||||
#include <SalomeApp_Tools.h>
|
||||
@ -56,6 +57,8 @@
|
||||
// SALOME KERNEL includes
|
||||
#include <SALOMEDS_SComponent.hxx>
|
||||
#include <SALOMEDS_SObject.hxx>
|
||||
#include <SALOMEDS_Study.hxx>
|
||||
#include <SALOMEDS_wrap.hxx>
|
||||
|
||||
// Qt includes
|
||||
#include <QStringList>
|
||||
@ -336,8 +339,7 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
if (geomGen->_is_nil() || !aStudy) return false;
|
||||
|
||||
GEOM::GEOM_IGroupOperations_var op =
|
||||
geomGen->GetIGroupOperations(aStudy->StudyId());
|
||||
GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId());
|
||||
if (op->_is_nil()) return false;
|
||||
|
||||
// check all selected shapes
|
||||
@ -352,18 +354,17 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const
|
||||
if (aSubGeomVar->_is_nil()) return false;
|
||||
|
||||
// skl for NPAL14695 - implementation of searching of mainObj
|
||||
GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar);
|
||||
//if (mainObj->_is_nil() ||
|
||||
// string(mainObj->GetEntry()) != string(mainGeom->GetEntry())) return false;
|
||||
GEOM::GEOM_Object_wrap mainObj = op->GetMainShape(aSubGeomVar);
|
||||
while(1) {
|
||||
if (mainObj->_is_nil())
|
||||
return false;
|
||||
if (std::string(mainObj->GetEntry()) == std::string(mainGeom->GetEntry()))
|
||||
CORBA::String_var entry1 = mainObj->GetEntry();
|
||||
CORBA::String_var entry2 = mainGeom->GetEntry();
|
||||
if (std::string( entry1.in() ) == entry2.in() )
|
||||
return true;
|
||||
mainObj = op->GetMainShape(mainObj);
|
||||
}
|
||||
}
|
||||
//return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -896,7 +897,8 @@ void SMESHGUI_MeshOp::existingHyps( const int theDim,
|
||||
SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar );
|
||||
if ( !aHypVar->_is_nil() )
|
||||
{
|
||||
HypothesisData* aData = SMESH::GetHypothesisData( aHypVar->GetName() );
|
||||
CORBA::String_var hypType = aHypVar->GetName();
|
||||
HypothesisData* aData = SMESH::GetHypothesisData( hypType.in() );
|
||||
if ( !aData) continue;
|
||||
if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) &&
|
||||
( isCompatible ( theAlgoData, aData, theHypType )) &&
|
||||
@ -1710,7 +1712,7 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
|
||||
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
if (!geomGen->_is_nil() && aStudy) {
|
||||
GEOM::GEOM_IGroupOperations_var op =
|
||||
GEOM::GEOM_IGroupOperations_wrap op =
|
||||
geomGen->GetIGroupOperations(aStudy->StudyId());
|
||||
if (!op->_is_nil()) {
|
||||
// check and add all selected GEOM objects: they must be
|
||||
@ -1735,18 +1737,19 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
|
||||
aSeq[iSubSh] = aSubGeomVar;
|
||||
}
|
||||
// create a group
|
||||
GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(mainGeom, aGroupType);
|
||||
GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(mainGeom, aGroupType);
|
||||
op->UnionList(aGroupVar, aSeq);
|
||||
|
||||
if (op->IsDone()) {
|
||||
aGeomVar = aGroupVar;
|
||||
aGeomVar = aGroupVar.in();
|
||||
|
||||
// publish the GEOM group in study
|
||||
QString aNewGeomGroupName ("Auto_group_for_");
|
||||
aNewGeomGroupName += aName;
|
||||
SALOMEDS::SObject_var aNewGroupSO =
|
||||
geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar,
|
||||
aNewGeomGroupName.toLatin1().data(), mainGeom);
|
||||
SALOMEDS::Study_var aStudyVar = _CAST(Study, aStudy)->GetStudy();
|
||||
SALOMEDS::SObject_wrap aNewGroupSO =
|
||||
geomGen->AddInStudy( aStudyVar, aGeomVar,
|
||||
aNewGeomGroupName.toLatin1().data(), mainGeom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ bool SMESHGUI_Selection::isImported( const int ind ) const
|
||||
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( SO ) );
|
||||
if( !aMesh->_is_nil() )
|
||||
{
|
||||
SALOME_MED::MedFileInfo* inf = aMesh->GetMEDFileInfo();
|
||||
SALOME_MED::MedFileInfo_var inf = aMesh->GetMEDFileInfo();
|
||||
res = strlen( (char*)inf->fileName ) > 0;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
// SALOME GEOM includes
|
||||
#include <GEOMBase.h>
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOM_GenericObjPtr.h>
|
||||
|
||||
// SALOME GUI includes
|
||||
#include <LightApp_DataOwner.h>
|
||||
@ -53,6 +54,8 @@
|
||||
|
||||
// SALOME KERNEL includes
|
||||
#include <SALOMEDSClient_SObject.hxx>
|
||||
#include <SALOMEDS_Study.hxx>
|
||||
#include <SALOMEDS_wrap.hxx>
|
||||
|
||||
// OCCT includes
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
@ -223,7 +226,7 @@ SMESH::SMESH_Mesh_ptr SMESHGUI_ShapeByMeshOp::GetMesh()
|
||||
|
||||
//=======================================================================
|
||||
// function : GetShape()
|
||||
// purpose : Get published sub-shape
|
||||
// purpose : Return published sub-shape, it must be UnRegister()ed!
|
||||
//=======================================================================
|
||||
GEOM::GEOM_Object_ptr SMESHGUI_ShapeByMeshOp::GetShape()
|
||||
{
|
||||
@ -306,85 +309,92 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
|
||||
try {
|
||||
QStringList aListId = myDlg->myElementId->text().split( " ", QString::SkipEmptyParts);
|
||||
if (aListId.count() == 1)
|
||||
{
|
||||
int elemID = (aListId.first()).toInt();
|
||||
myGeomObj = GEOM::GEOM_Object::_duplicate(
|
||||
SMESHGUI::GetSMESHGen()->GetGeometryByMeshElement
|
||||
( myMesh.in(), elemID, myDlg->myGeomName->text().toLatin1().constData()) );
|
||||
}
|
||||
{
|
||||
int elemID = (aListId.first()).toInt();
|
||||
// GEOM_Object is published -> no need to UnRegister()
|
||||
myGeomObj = GEOM::GEOM_Object::_duplicate
|
||||
(SMESHGUI::GetSMESHGen()->GetGeometryByMeshElement
|
||||
( myMesh.in(), elemID, myDlg->myGeomName->text().toLatin1().constData()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
|
||||
if (geomGen->_is_nil() || !aStudy)
|
||||
return;
|
||||
|
||||
GEOM::GEOM_IShapesOperations_wrap aShapesOp =
|
||||
geomGen->GetIShapesOperations(aStudy->StudyId());
|
||||
if (aShapesOp->_is_nil() )
|
||||
return;
|
||||
|
||||
TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
|
||||
|
||||
std::map<double, GEOM::GEOM_Object_wrap> aGeomObjectsMap;
|
||||
GEOM::GEOM_Object_wrap aGeomObject;
|
||||
|
||||
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
|
||||
|
||||
for ( int i = 0; i < aListId.count(); i++ )
|
||||
{
|
||||
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
|
||||
if (geomGen->_is_nil() || !aStudy)
|
||||
return;
|
||||
|
||||
GEOM::GEOM_IShapesOperations_var aShapesOp =
|
||||
geomGen->GetIShapesOperations(aStudy->StudyId());
|
||||
if (aShapesOp->_is_nil() )
|
||||
return;
|
||||
|
||||
TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
|
||||
|
||||
std::map<double, GEOM::GEOM_Object_var> aGeomObjectsMap;
|
||||
GEOM::GEOM_Object_var aGeomObject;
|
||||
aGeomObject = // received object need UnRegister()!
|
||||
SMESHGUI::GetSMESHGen()->FindGeometryByMeshElement(myMesh.in(), aListId[i].toInt());
|
||||
|
||||
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
|
||||
|
||||
for ( int i = 0; i < aListId.count(); i++ )
|
||||
{
|
||||
aGeomObject =
|
||||
SMESHGUI::GetSMESHGen()->FindGeometryByMeshElement(myMesh.in(), aListId[i].toInt());
|
||||
if (aGeomObject->_is_nil()) continue;
|
||||
|
||||
if (aGeomObject->_is_nil()) continue;
|
||||
|
||||
double anId = aShapesOp->GetSubShapeIndex(aMeshShape, aGeomObject);
|
||||
if (aShapesOp->IsDone() && aGeomObjectsMap.find(anId) == aGeomObjectsMap.end())
|
||||
{
|
||||
aGeomObjectsMap[anId] = aGeomObject;
|
||||
double anId = aShapesOp->GetSubShapeIndex(aMeshShape, aGeomObject);
|
||||
if (aShapesOp->IsDone() && !aGeomObjectsMap.count(anId) )
|
||||
{
|
||||
aGeomObjectsMap[anId] = aGeomObject;
|
||||
|
||||
TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aGeomObject->GetShapeType();
|
||||
if (i == 0)
|
||||
aGroupType = aSubShapeType;
|
||||
else if (aSubShapeType != aGroupType)
|
||||
aGroupType = TopAbs_SHAPE;
|
||||
}
|
||||
}
|
||||
|
||||
int aNumberOfGO = aGeomObjectsMap.size();
|
||||
if (aNumberOfGO == 1)
|
||||
myGeomObj = (*aGeomObjectsMap.begin()).second;
|
||||
else if (aNumberOfGO > 1)
|
||||
{
|
||||
GEOM::GEOM_IGroupOperations_var aGroupOp =
|
||||
geomGen->GetIGroupOperations(aStudy->StudyId());
|
||||
if(aGroupOp->_is_nil())
|
||||
return;
|
||||
|
||||
GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO();
|
||||
aGeomObjects->length( aNumberOfGO );
|
||||
|
||||
int i = 0;
|
||||
std::map<double, GEOM::GEOM_Object_var>::iterator anIter;
|
||||
for (anIter = aGeomObjectsMap.begin(); anIter!=aGeomObjectsMap.end(); anIter++)
|
||||
aGeomObjects[i++] = (*anIter).second;
|
||||
|
||||
//create geometry group
|
||||
myGeomObj = aGroupOp->CreateGroup(aMeshShape, aGroupType);
|
||||
aGroupOp->UnionList(myGeomObj, aGeomObjects);
|
||||
|
||||
if (!aGroupOp->IsDone())
|
||||
return;
|
||||
}
|
||||
|
||||
// publish the GEOM object in study
|
||||
QString aNewGeomGroupName ( myDlg->myGeomName->text() );
|
||||
|
||||
SALOMEDS::SObject_var aNewGroupSO =
|
||||
geomGen->AddInStudy(SMESHGUI::GetSMESHGen()->GetCurrentStudy(), myGeomObj,
|
||||
aNewGeomGroupName.toLatin1().data(), aMeshShape);
|
||||
TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aGeomObject->GetShapeType();
|
||||
if (i == 0)
|
||||
aGroupType = aSubShapeType;
|
||||
else if (aSubShapeType != aGroupType)
|
||||
aGroupType = TopAbs_SHAPE;
|
||||
}
|
||||
}
|
||||
|
||||
int aNumberOfGO = aGeomObjectsMap.size();
|
||||
if (aNumberOfGO == 1)
|
||||
{
|
||||
aGeomObject = (*aGeomObjectsMap.begin()).second;
|
||||
}
|
||||
else if (aNumberOfGO > 1)
|
||||
{
|
||||
GEOM::GEOM_IGroupOperations_wrap aGroupOp =
|
||||
geomGen->GetIGroupOperations(aStudy->StudyId());
|
||||
if(aGroupOp->_is_nil())
|
||||
return;
|
||||
|
||||
GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO();
|
||||
aGeomObjects->length( aNumberOfGO );
|
||||
|
||||
int i = 0;
|
||||
std::map<double, GEOM::GEOM_Object_wrap>::iterator anIter;
|
||||
for (anIter = aGeomObjectsMap.begin(); anIter!=aGeomObjectsMap.end(); anIter++)
|
||||
aGeomObjects[i++] = (*anIter).second.in();
|
||||
|
||||
//create geometry group
|
||||
aGeomObject = aGroupOp->CreateGroup(aMeshShape, aGroupType);
|
||||
aGroupOp->UnionList(myGeomObj, aGeomObjects);
|
||||
|
||||
if (!aGroupOp->IsDone())
|
||||
return;
|
||||
}
|
||||
|
||||
// publish the GEOM object in study
|
||||
QString aNewGeomGroupName ( myDlg->myGeomName->text() );
|
||||
SALOMEDS::Study_var aStudyVar = _CAST(Study,aStudy)->GetStudy();
|
||||
SALOMEDS::SObject_wrap aNewGroupSO =
|
||||
geomGen->AddInStudy( aStudyVar, aGeomObject,
|
||||
aNewGeomGroupName.toLatin1().data(), aMeshShape);
|
||||
|
||||
// get a GEOM_Object already published, which doesn't need UnRegister()
|
||||
CORBA::Object_var obj = aNewGroupSO->GetObject();
|
||||
myGeomObj = GEOM::GEOM_Object::_narrow( obj );
|
||||
}
|
||||
}
|
||||
catch (const SALOME::SALOME_Exception& S_ex) {
|
||||
SalomeApp_Tools::QtCatchCorbaException(S_ex);
|
||||
|
@ -83,12 +83,15 @@ namespace
|
||||
SALOMEDS::GenericAttribute_var anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributeName");
|
||||
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
||||
aName->SetValue(theName.toLatin1().data());
|
||||
aName->UnRegister();
|
||||
anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributePixMap");
|
||||
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
||||
aPixmap->SetPixMap(thePixmap.toLatin1().data());
|
||||
aPixmap->UnRegister();
|
||||
anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributeSelectable");
|
||||
SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
|
||||
aSelAttr->SetSelectable(false);
|
||||
aSelAttr->UnRegister();
|
||||
}
|
||||
|
||||
return aDomainRoot;
|
||||
@ -126,12 +129,12 @@ namespace
|
||||
//---------------------------------------------------------------
|
||||
inline
|
||||
SALOMEDS::SObject_var
|
||||
AddToDomain(const std::string& theIOR,
|
||||
const SALOMEDS::SComponent_var& theSComponentMesh,
|
||||
AddToDomain(const std::string& theIOR,
|
||||
const SALOMEDS::SComponent_var& theSComponentMesh,
|
||||
const SALOMEDS::StudyBuilder_var& theStudyBuilder,
|
||||
CORBA::Long theDomainRootTag,
|
||||
const QString& theDomainName,
|
||||
const QString& theDomainPixmap)
|
||||
CORBA::Long theDomainRootTag,
|
||||
const QString& theDomainName,
|
||||
const QString& theDomainPixmap)
|
||||
{
|
||||
SALOMEDS::SObject_var aDomain = GetDomainRoot(theSComponentMesh,
|
||||
theStudyBuilder,
|
||||
@ -140,6 +143,7 @@ namespace
|
||||
theDomainPixmap);
|
||||
// Add New Hypothesis
|
||||
SALOMEDS::SObject_var aSObject = theStudyBuilder->NewObject(aDomain);
|
||||
aDomain->UnRegister();
|
||||
SALOMEDS::GenericAttribute_var anAttr = theStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
|
||||
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
||||
CORBA::Object_var anObject = StringToObject(theIOR);
|
||||
@ -147,9 +151,11 @@ namespace
|
||||
CORBA::String_var aType = aDomainItem->GetName();
|
||||
QString aPixmapName = theDomainPixmap + "_" + aType.in();
|
||||
aPixmap->SetPixMap(aPixmapName.toLatin1().data());
|
||||
aPixmap->UnRegister();
|
||||
anAttr = theStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
|
||||
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
||||
anIOR->SetValue(theIOR.c_str());
|
||||
anIOR->UnRegister();
|
||||
|
||||
return aSObject;
|
||||
}
|
||||
@ -187,44 +193,52 @@ namespace
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void
|
||||
SetDomain(const char* theMeshOrSubMeshEntry,
|
||||
const char* theDomainEntry,
|
||||
const SALOMEDS::Study_var& theStudy,
|
||||
SetDomain(const char* theMeshOrSubMeshEntry,
|
||||
const char* theDomainEntry,
|
||||
const SALOMEDS::Study_var& theStudy,
|
||||
const SALOMEDS::StudyBuilder_var& theStudyBuilder,
|
||||
long theRefOnAppliedDomainTag,
|
||||
const QString& theAppliedDomainMEN,
|
||||
const QString& theAppliedDomainICON)
|
||||
long theRefOnAppliedDomainTag,
|
||||
const QString& theAppliedDomainMEN,
|
||||
const QString& theAppliedDomainICON)
|
||||
{
|
||||
SALOMEDS::SObject_var aMeshOrSubMeshSO = theStudy->FindObjectID(theMeshOrSubMeshEntry);
|
||||
SALOMEDS::SObject_var aHypothesisSO = theStudy->FindObjectID(theDomainEntry);
|
||||
SALOMEDS::SObject_var aHypothesisSO = theStudy->FindObjectID(theDomainEntry);
|
||||
|
||||
if(!aMeshOrSubMeshSO->_is_nil() && !aHypothesisSO->_is_nil()){
|
||||
//Find or Create Applied Hypothesis root
|
||||
SALOMEDS::SObject_var anAppliedDomainSO;
|
||||
if(!aMeshOrSubMeshSO->FindSubObject(theRefOnAppliedDomainTag,anAppliedDomainSO)){
|
||||
if( !aMeshOrSubMeshSO->FindSubObject( theRefOnAppliedDomainTag, anAppliedDomainSO ))
|
||||
{
|
||||
anAppliedDomainSO = theStudyBuilder->NewObjectToTag(aMeshOrSubMeshSO,theRefOnAppliedDomainTag);
|
||||
SALOMEDS::GenericAttribute_var anAttr =
|
||||
theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributeName");
|
||||
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
||||
aName->SetValue(theAppliedDomainMEN.toLatin1().data());
|
||||
aName->UnRegister();
|
||||
anAttr = theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributeSelectable");
|
||||
SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
|
||||
aSelAttr->SetSelectable(false);
|
||||
aSelAttr->UnRegister();
|
||||
anAttr = theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributePixMap");
|
||||
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
||||
aPixmap->SetPixMap(theAppliedDomainICON.toLatin1().data());
|
||||
aPixmap->UnRegister();
|
||||
}
|
||||
SALOMEDS::SObject_var aSObject = theStudyBuilder->NewObject(anAppliedDomainSO);
|
||||
theStudyBuilder->Addreference(aSObject,aHypothesisSO);
|
||||
aSObject->UnRegister();
|
||||
anAppliedDomainSO->UnRegister();
|
||||
}
|
||||
if ( !aMeshOrSubMeshSO->_is_nil() ) aMeshOrSubMeshSO->UnRegister();
|
||||
if ( !aHypothesisSO->_is_nil()) aHypothesisSO->UnRegister();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void
|
||||
SetHypothesis(const char* theMeshOrSubMeshEntry,
|
||||
const char* theDomainEntry,
|
||||
const SALOMEDS::Study_var& theStudy,
|
||||
SetHypothesis(const char* theMeshOrSubMeshEntry,
|
||||
const char* theDomainEntry,
|
||||
const SALOMEDS::Study_var& theStudy,
|
||||
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
|
||||
{
|
||||
SetDomain(theMeshOrSubMeshEntry,
|
||||
@ -239,9 +253,9 @@ namespace
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void
|
||||
SetAlgorithms(const char* theMeshOrSubMeshEntry,
|
||||
const char* theDomainEntry,
|
||||
const SALOMEDS::Study_var& theStudy,
|
||||
SetAlgorithms(const char* theMeshOrSubMeshEntry,
|
||||
const char* theDomainEntry,
|
||||
const SALOMEDS::Study_var& theStudy,
|
||||
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
|
||||
{
|
||||
SetDomain(theMeshOrSubMeshEntry,
|
||||
@ -296,31 +310,36 @@ SMESH_Swig::Init(int theStudyID)
|
||||
{
|
||||
class TEvent: public SALOME_Event
|
||||
{
|
||||
int myStudyID;
|
||||
SALOMEDS::Study_var& myStudy;
|
||||
int myStudyID;
|
||||
SALOMEDS::Study_var& myStudy;
|
||||
SALOMEDS::StudyBuilder_var& myStudyBuilder;
|
||||
SALOMEDS::SComponent_var& mySComponentMesh;
|
||||
SALOMEDS::SComponent_var& mySComponentMesh;
|
||||
public:
|
||||
TEvent(int theStudyID,
|
||||
SALOMEDS::Study_var& theStudy,
|
||||
TEvent(int theStudyID,
|
||||
SALOMEDS::Study_var& theStudy,
|
||||
SALOMEDS::StudyBuilder_var& theStudyBuilder,
|
||||
SALOMEDS::SComponent_var& theSComponentMesh):
|
||||
myStudyID(theStudyID),
|
||||
myStudy(theStudy),
|
||||
myStudyBuilder(theStudyBuilder),
|
||||
SALOMEDS::SComponent_var& theSComponentMesh):
|
||||
myStudyID (theStudyID),
|
||||
myStudy (theStudy),
|
||||
myStudyBuilder (theStudyBuilder),
|
||||
mySComponentMesh(theSComponentMesh)
|
||||
{}
|
||||
|
||||
~TEvent()
|
||||
{
|
||||
if ( !mySComponentMesh->_is_nil() ) mySComponentMesh->UnRegister();
|
||||
}
|
||||
|
||||
virtual
|
||||
void
|
||||
Execute()
|
||||
{
|
||||
SUIT_Session* aSession = SUIT_Session::session();
|
||||
SUIT_Session* aSession = SUIT_Session::session();
|
||||
SUIT_Application* anApplication = aSession->activeApplication();
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
||||
|
||||
SALOME_NamingService* aNamingService = anApp->namingService();
|
||||
CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
|
||||
CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
|
||||
SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
|
||||
myStudy = aStudyMgr->GetStudyByID(myStudyID);
|
||||
|
||||
@ -334,26 +353,33 @@ SMESH_Swig::Init(int theStudyID)
|
||||
SALOMEDS::AttributePixMap_var aPixmap;
|
||||
|
||||
SALOMEDS::SComponent_var aSComponent = myStudy->FindComponent("SMESH");
|
||||
if(aSComponent->_is_nil()){
|
||||
if ( aSComponent->_is_nil() )
|
||||
{
|
||||
bool aLocked = myStudy->GetProperties()->IsLocked();
|
||||
if (aLocked)
|
||||
myStudy->GetProperties()->SetLocked(false);
|
||||
|
||||
aSComponent = myStudyBuilder->NewComponent("SMESH");
|
||||
anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributeName");
|
||||
aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
||||
|
||||
SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); //SRN: BugID IPAL9186, load a SMESH gui if it hasn't been loaded
|
||||
if (!aSMESHGUI){
|
||||
SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI();
|
||||
//SRN: BugID IPAL9186, load a SMESH gui if it hasn't been loaded
|
||||
if (!aSMESHGUI) {
|
||||
CAM_Module* aModule = anApp->module("Mesh");
|
||||
if(!aModule)
|
||||
aModule = anApp->loadModule("Mesh");
|
||||
aModule = anApp->loadModule("Mesh");
|
||||
aSMESHGUI = dynamic_cast<SMESHGUI*>(aModule);
|
||||
} //SRN: BugID IPAL9186: end of a fix
|
||||
|
||||
aSComponent = myStudyBuilder->NewComponent("SMESH");
|
||||
|
||||
anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributeName");
|
||||
aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
||||
aName->SetValue(aSMESHGUI->moduleName().toLatin1().data());
|
||||
aName->UnRegister();
|
||||
|
||||
anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributePixMap");
|
||||
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
||||
aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
|
||||
aPixmap->UnRegister();
|
||||
|
||||
myStudyBuilder->DefineComponentInstance(aSComponent,aSMESHGen);
|
||||
if (aLocked)
|
||||
myStudy->GetProperties()->SetLocked(true);
|
||||
@ -388,22 +414,29 @@ const char* SMESH_Swig::AddNewMesh(const char* theIOR)
|
||||
|
||||
// VSR: added temporarily - to be removed - objects are published automatically by engine
|
||||
SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(theIOR);
|
||||
if (aSObject->_is_nil()){
|
||||
if (aSObject->_is_nil())
|
||||
{
|
||||
//Find or Create Hypothesis root
|
||||
GetHypothesisRoot(mySComponentMesh,myStudyBuilder);
|
||||
GetAlgorithmsRoot(mySComponentMesh,myStudyBuilder);
|
||||
SALOMEDS::SObject_var hroot = GetHypothesisRoot(mySComponentMesh,myStudyBuilder);
|
||||
SALOMEDS::SObject_var aroot = GetAlgorithmsRoot(mySComponentMesh,myStudyBuilder);
|
||||
hroot->UnRegister();
|
||||
aroot->UnRegister();
|
||||
|
||||
// Add New Mesh
|
||||
aSObject = myStudyBuilder->NewObject(mySComponentMesh);
|
||||
SALOMEDS::GenericAttribute_var anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
|
||||
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
||||
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
|
||||
aPixmap->UnRegister();
|
||||
|
||||
anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
|
||||
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
||||
anIOR->SetValue(theIOR);
|
||||
anIOR->UnRegister();
|
||||
}
|
||||
|
||||
CORBA::String_var anEntry = aSObject->GetID();
|
||||
aSObject->UnRegister();
|
||||
|
||||
return anEntry._retn();
|
||||
}
|
||||
@ -418,6 +451,8 @@ const char* SMESH_Swig::AddNewHypothesis(const char* theIOR)
|
||||
mySComponentMesh,
|
||||
myStudyBuilder);
|
||||
CORBA::String_var anEntry = aSObject->GetID();
|
||||
aSObject->UnRegister();
|
||||
|
||||
return anEntry._retn();
|
||||
}
|
||||
|
||||
@ -431,6 +466,8 @@ const char* SMESH_Swig::AddNewAlgorithms(const char* theIOR)
|
||||
mySComponentMesh,
|
||||
myStudyBuilder);
|
||||
CORBA::String_var anEntry = aSObject->GetID();
|
||||
aSObject->UnRegister();
|
||||
|
||||
return anEntry._retn();
|
||||
}
|
||||
|
||||
@ -439,13 +476,16 @@ const char* SMESH_Swig::AddNewAlgorithms(const char* theIOR)
|
||||
void SMESH_Swig::SetShape(const char* theShapeEntry,
|
||||
const char* theMeshEntry)
|
||||
{
|
||||
SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID( theMeshEntry );
|
||||
SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID( theShapeEntry );
|
||||
SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID( theMeshEntry );
|
||||
|
||||
if(!aMeshSO->_is_nil() && !aGeomShapeSO->_is_nil()){
|
||||
SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObjectToTag(aMeshSO, SMESH::Tag_RefOnShape);
|
||||
myStudyBuilder->Addreference(aSObject,aGeomShapeSO);
|
||||
aSObject->UnRegister();
|
||||
}
|
||||
if ( !aMeshSO->_is_nil() ) aMeshSO->UnRegister();
|
||||
if ( !aGeomShapeSO->_is_nil() ) aGeomShapeSO->UnRegister();
|
||||
}
|
||||
|
||||
|
||||
@ -485,49 +525,57 @@ const char* SMESH_Swig::AddSubMesh(const char* theMeshEntry,
|
||||
int theShapeType)
|
||||
{
|
||||
SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(theMeshEntry);
|
||||
if(!aMeshSO->_is_nil()){
|
||||
if(!aMeshSO->_is_nil()) {
|
||||
long aShapeTag;
|
||||
QString aSubMeshName;
|
||||
switch(theShapeType){
|
||||
switch(theShapeType) {
|
||||
case TopAbs_SOLID:
|
||||
aShapeTag = SMESH::Tag_SubMeshOnSolid;
|
||||
aShapeTag = SMESH::Tag_SubMeshOnSolid;
|
||||
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnSolid");
|
||||
break;
|
||||
case TopAbs_FACE:
|
||||
aShapeTag = SMESH::Tag_SubMeshOnFace;
|
||||
aShapeTag = SMESH::Tag_SubMeshOnFace;
|
||||
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnFace");
|
||||
break;
|
||||
case TopAbs_EDGE:
|
||||
aShapeTag = SMESH::Tag_SubMeshOnEdge;
|
||||
aShapeTag = SMESH::Tag_SubMeshOnEdge;
|
||||
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnEdge");
|
||||
break;
|
||||
case TopAbs_VERTEX:
|
||||
aShapeTag = SMESH::Tag_SubMeshOnVertex;
|
||||
aShapeTag = SMESH::Tag_SubMeshOnVertex;
|
||||
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnVertex");
|
||||
break;
|
||||
default:
|
||||
aShapeTag = SMESH::Tag_SubMeshOnCompound;
|
||||
aShapeTag = SMESH::Tag_SubMeshOnCompound;
|
||||
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnCompound");
|
||||
}
|
||||
|
||||
SALOMEDS::SObject_var aSubMeshesRoot;
|
||||
SALOMEDS::GenericAttribute_var anAttr;
|
||||
if(!aMeshSO->FindSubObject(aShapeTag,aSubMeshesRoot)){
|
||||
SALOMEDS::SObject_var aSubMeshesRoot;
|
||||
if ( !aMeshSO->FindSubObject( aShapeTag, aSubMeshesRoot ) )
|
||||
{
|
||||
aSubMeshesRoot = myStudyBuilder->NewObjectToTag(aMeshSO,aShapeTag);
|
||||
anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeName");
|
||||
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
||||
aName->SetValue(aSubMeshName.toLatin1().data());
|
||||
aName->UnRegister();
|
||||
anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeSelectable");
|
||||
SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
|
||||
aSelAttr->SetSelectable(false);
|
||||
aSelAttr->UnRegister();
|
||||
}
|
||||
aSubMeshesRoot->UnRegister();
|
||||
aMeshSO->UnRegister();
|
||||
|
||||
SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObject(aSubMeshesRoot);
|
||||
anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
|
||||
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
||||
anIOR->SetValue(theSubMeshIOR);
|
||||
anIOR->UnRegister();
|
||||
|
||||
CORBA::String_var aString = aSObject->GetID();
|
||||
aSObject->UnRegister();
|
||||
|
||||
return aString._retn();
|
||||
}
|
||||
|
||||
@ -537,17 +585,20 @@ const char* SMESH_Swig::AddSubMesh(const char* theMeshEntry,
|
||||
const char* SMESH_Swig::AddSubMeshOnShape(const char* theMeshEntry,
|
||||
const char* theGeomShapeEntry,
|
||||
const char* theSubMeshIOR,
|
||||
int ShapeType)
|
||||
int ShapeType)
|
||||
{
|
||||
SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID(theGeomShapeEntry);
|
||||
if(!aGeomShapeSO->_is_nil()){
|
||||
const char * aSubMeshEntry = AddSubMesh(theMeshEntry,theSubMeshIOR,ShapeType);
|
||||
if(!aGeomShapeSO->_is_nil())
|
||||
{
|
||||
const char * aSubMeshEntry = AddSubMesh(theMeshEntry,theSubMeshIOR,ShapeType);
|
||||
SALOMEDS::SObject_var aSubMeshSO = myStudy->FindObjectID(aSubMeshEntry);
|
||||
if(!aSubMeshSO->_is_nil()){
|
||||
SetShape(theGeomShapeEntry,aSubMeshEntry);
|
||||
if ( !aSubMeshSO->_is_nil()) {
|
||||
SetShape( theGeomShapeEntry, aSubMeshEntry );
|
||||
CORBA::String_var aString = aSubMeshSO->GetID();
|
||||
aSubMeshSO->UnRegister();
|
||||
return aString._retn();
|
||||
}
|
||||
aGeomShapeSO->UnRegister();
|
||||
}
|
||||
|
||||
return "";
|
||||
@ -566,11 +617,11 @@ void SMESH_Swig::CreateAndDisplayActor( const char* Mesh_Entry )
|
||||
}
|
||||
virtual void Execute() {
|
||||
//SMESH::UpdateView(SMESH::eDisplay, _entry);
|
||||
SUIT_Session* aSession = SUIT_Session::session();
|
||||
SUIT_Session* aSession = SUIT_Session::session();
|
||||
SUIT_Application* anApplication = aSession->activeApplication();
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
||||
/*SUIT_ViewManager* vman = */anApp->getViewManager(VTKViewer_Viewer::Type(),true);
|
||||
SMESHGUI_Displayer* aDisp = new SMESHGUI_Displayer(anApp);
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
||||
/*SUIT_ViewManager* vman = */anApp->getViewManager(VTKViewer_Viewer::Type(),true);
|
||||
SMESHGUI_Displayer* aDisp = new SMESHGUI_Displayer(anApp);
|
||||
aDisp->Display(_entry,1);
|
||||
}
|
||||
};
|
||||
@ -584,31 +635,31 @@ void SMESH_Swig::EraseActor( const char* Mesh_Entry, const bool allViewers )
|
||||
{
|
||||
private:
|
||||
const char* _entry;
|
||||
bool _allViewers;
|
||||
bool _allViewers;
|
||||
public:
|
||||
TEvent(const char* Mesh_Entry, const bool allViewers ) {
|
||||
_entry = Mesh_Entry;
|
||||
_allViewers = allViewers;
|
||||
}
|
||||
virtual void Execute() {
|
||||
SUIT_Session* aSession = SUIT_Session::session();
|
||||
SUIT_Session* aSession = SUIT_Session::session();
|
||||
SUIT_Application* anApplication = aSession->activeApplication();
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
||||
SMESHGUI_Displayer* aDisp = new SMESHGUI_Displayer(anApp);
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
||||
SMESHGUI_Displayer* aDisp = new SMESHGUI_Displayer(anApp);
|
||||
ViewManagerList aManagers;
|
||||
if ( !_allViewers ) {
|
||||
aManagers << anApp->activeViewManager();
|
||||
aManagers << anApp->activeViewManager();
|
||||
}
|
||||
else {
|
||||
aManagers = anApp->viewManagers();
|
||||
aManagers = anApp->viewManagers();
|
||||
}
|
||||
foreach( SUIT_ViewManager* aMgr, aManagers ) {
|
||||
if ( aMgr && aMgr->getType() == VTKViewer_Viewer::Type() ) {
|
||||
SALOME_View* aSalomeView = dynamic_cast<SALOME_View*>(aMgr->getViewModel());
|
||||
if (aSalomeView) {
|
||||
aDisp->Erase(_entry,true, true, aSalomeView);
|
||||
}
|
||||
}
|
||||
if ( aMgr && aMgr->getType() == VTKViewer_Viewer::Type() ) {
|
||||
SALOME_View* aSalomeView = dynamic_cast<SALOME_View*>(aMgr->getViewModel());
|
||||
if (aSalomeView) {
|
||||
aDisp->Erase(_entry,true, true, aSalomeView);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -626,6 +677,8 @@ void SMESH_Swig::SetName(const char* theEntry,
|
||||
anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName");
|
||||
aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
||||
aName->SetValue(theName);
|
||||
aName->UnRegister();
|
||||
aSObject->UnRegister();
|
||||
}
|
||||
}
|
||||
|
||||
@ -638,33 +691,33 @@ void SMESH_Swig::SetName(const char* theEntry,
|
||||
//================================================================================
|
||||
|
||||
void SMESH_Swig::SetMeshIcon(const char* theMeshEntry,
|
||||
const bool theIsComputed,
|
||||
const bool isEmpty)
|
||||
const bool theIsComputed,
|
||||
const bool isEmpty)
|
||||
{
|
||||
class TEvent: public SALOME_Event
|
||||
{
|
||||
SALOMEDS::Study_var myStudy;
|
||||
std::string myMeshEntry;
|
||||
bool myIsComputed, myIsEmpty;
|
||||
std::string myMeshEntry;
|
||||
bool myIsComputed, myIsEmpty;
|
||||
public:
|
||||
TEvent(const SALOMEDS::Study_var& theStudy,
|
||||
const std::string& theMeshEntry,
|
||||
const bool theIsComputed,
|
||||
const bool isEmpty):
|
||||
myStudy(theStudy),
|
||||
myMeshEntry(theMeshEntry),
|
||||
const std::string& theMeshEntry,
|
||||
const bool theIsComputed,
|
||||
const bool isEmpty):
|
||||
myStudy (theStudy),
|
||||
myMeshEntry (theMeshEntry),
|
||||
myIsComputed(theIsComputed),
|
||||
myIsEmpty(isEmpty)
|
||||
myIsEmpty (isEmpty)
|
||||
{}
|
||||
|
||||
virtual
|
||||
void
|
||||
Execute()
|
||||
{
|
||||
SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(myMeshEntry.c_str());
|
||||
if(!aMeshSO->_is_nil())
|
||||
if(_PTR(SObject) aMesh = ClientFactory::SObject(aMeshSO))
|
||||
SMESH::ModifiedMesh(aMesh,myIsComputed,myIsEmpty);
|
||||
SALOMEDS::SObject_ptr aMeshSO = myStudy->FindObjectID(myMeshEntry.c_str());
|
||||
if(_PTR(SObject) aMesh = ClientFactory::SObject(aMeshSO))
|
||||
SMESH::ModifiedMesh(aMesh,myIsComputed,myIsEmpty);
|
||||
// aMeshSO->UnRegister(); ~aMesh() already called UnRegister()!
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,6 +42,8 @@
|
||||
|
||||
#include <SALOMEDSClient_Study.hxx>
|
||||
|
||||
#include <GEOM_GenericObjPtr.h>
|
||||
|
||||
// SALOME GUI includes
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
|
||||
@ -418,7 +420,7 @@ bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
|
||||
|
||||
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
|
||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||
GEOM::GEOM_IShapesOperations_var shapeOp;
|
||||
GEOM::GEOM_IShapesOperations_wrap shapeOp;
|
||||
if ( !geomGen->_is_nil() && aStudy )
|
||||
shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
|
||||
if ( !shapeOp->_is_nil() )
|
||||
|
@ -68,9 +68,6 @@
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <StdSelect_TypeOfEdge.hxx>
|
||||
|
||||
// SALOME KERNEL includes
|
||||
#include <SALOMEDS_SObject.hxx>
|
||||
|
||||
|
||||
#define SPACING 6
|
||||
#define MARGIN 0
|
||||
@ -470,18 +467,17 @@ GEOM::GEOM_Object_var StdMeshersGUI_SubShapeSelectorWdg::GetGeomObjectByEntry( c
|
||||
{
|
||||
GEOM::GEOM_Object_var aGeomObj;
|
||||
SALOMEDS::Study_var aStudy = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
|
||||
if (aStudy != 0) {
|
||||
if ( !aStudy->_is_nil() )
|
||||
{
|
||||
SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( theEntry.toLatin1().data() );
|
||||
SALOMEDS::GenericAttribute_var anAttr;
|
||||
|
||||
if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
|
||||
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
||||
CORBA::String_var aVal = anIOR->Value();
|
||||
CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal);
|
||||
if (!aSObj->_is_nil() )
|
||||
{
|
||||
CORBA::Object_var obj = aSObj->GetObject();
|
||||
aGeomObj = GEOM::GEOM_Object::_narrow(obj);
|
||||
aSObj->UnRegister();
|
||||
}
|
||||
}
|
||||
return aGeomObj;
|
||||
return aGeomObj._retn();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
|
@ -32,8 +32,9 @@
|
||||
#include "SMESH_PythonDump.hxx"
|
||||
#include "StdMeshers_ObjRefUlils.hxx"
|
||||
|
||||
#include "Utils_CorbaException.hxx"
|
||||
#include "utilities.h"
|
||||
#include <Utils_CorbaException.hxx>
|
||||
#include <utilities.h>
|
||||
#include <SALOMEDS_wrap.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
@ -97,7 +98,7 @@ void StdMeshers_ImportSource1D_i::SetSourceEdges(const SMESH::ListOfGroups& grou
|
||||
THROW_SALOME_CORBA_EXCEPTION("Wrong group type", SALOME::BAD_PARAM);
|
||||
smesh_groups.push_back( gp_i->GetSmeshGroup() );
|
||||
|
||||
SALOMEDS::SObject_var so = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject(study, groups[i]);
|
||||
SALOMEDS::SObject_wrap so = SMESH_Gen_i::ObjectToSObject(study, groups[i]);
|
||||
if ( !so->_is_nil())
|
||||
{
|
||||
CORBA::String_var entry = so->GetID();
|
||||
@ -178,8 +179,8 @@ char* StdMeshers_ImportSource1D_i::SaveTo()
|
||||
os << " " << _groupEntries[i];
|
||||
|
||||
// id
|
||||
SALOMEDS::SObject_var groupSO = study->FindObjectID( _groupEntries[i] );
|
||||
CORBA::Object_var groupObj;
|
||||
SALOMEDS::SObject_wrap groupSO = study->FindObjectID( _groupEntries[i] );
|
||||
CORBA::Object_var groupObj;
|
||||
if ( !groupSO->_is_nil() )
|
||||
groupObj = groupSO->GetObject();
|
||||
StdMeshers_ObjRefUlils::SaveToStream( groupObj, os );
|
||||
|
@ -97,11 +97,12 @@ void StdMeshers_ImportSource2D_i::SetSourceFaces(const SMESH::ListOfGroups& grou
|
||||
THROW_SALOME_CORBA_EXCEPTION("Wrong group type", SALOME::BAD_PARAM);
|
||||
smesh_groups.push_back( gp_i->GetSmeshGroup() );
|
||||
|
||||
SALOMEDS::SObject_var so = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject(study, groups[i]);
|
||||
SALOMEDS::SObject_var so = SMESH_Gen_i::ObjectToSObject(study, groups[i]);
|
||||
if ( !so->_is_nil())
|
||||
{
|
||||
CORBA::String_var entry = so->GetID();
|
||||
entries.push_back( entry.in() );
|
||||
so->UnRegister();
|
||||
}
|
||||
}
|
||||
this->GetImpl()->SetGroups( smesh_groups );
|
||||
@ -179,9 +180,11 @@ char* StdMeshers_ImportSource2D_i::SaveTo()
|
||||
|
||||
// id
|
||||
SALOMEDS::SObject_var groupSO = study->FindObjectID( _groupEntries[i] );
|
||||
CORBA::Object_var groupObj;
|
||||
if ( !groupSO->_is_nil() )
|
||||
CORBA::Object_var groupObj;
|
||||
if ( !groupSO->_is_nil() ) {
|
||||
groupObj = groupSO->GetObject();
|
||||
groupSO->UnRegister();
|
||||
}
|
||||
StdMeshers_ObjRefUlils::SaveToStream( groupObj, os );
|
||||
}
|
||||
|
||||
|
@ -88,11 +88,16 @@ void StdMeshers_LayerDistribution_i::SetLayerDistribution(SMESH::SMESH_Hypothesi
|
||||
this->GetImpl()->SetLayerDistribution( hyp_i->GetImpl() );
|
||||
myHyp = SMESH::SMESH_Hypothesis::_duplicate( hyp1D );
|
||||
// Remove SO of 1D hypothesis if it was published
|
||||
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
|
||||
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen())
|
||||
{
|
||||
SALOMEDS::Study_var study = gen->GetCurrentStudy();
|
||||
SALOMEDS::SObject_var SO = gen->ObjectToSObject( study, hyp1D );
|
||||
SALOMEDS::SObject_var SO = gen->ObjectToSObject( study, hyp1D );
|
||||
if ( ! SO->_is_nil() )
|
||||
study->NewBuilder()->RemoveObjectWithChildren( SO );
|
||||
{
|
||||
SALOMEDS::StudyBuilder_var builder = study->NewBuilder();
|
||||
builder->RemoveObjectWithChildren( SO );
|
||||
SO->UnRegister();
|
||||
}
|
||||
}
|
||||
// Update Python script: write creation of 1D hyp as it is not published and
|
||||
// for this, SMESH_Gen does not write it's creation
|
||||
|
@ -27,6 +27,7 @@
|
||||
//
|
||||
#include "StdMeshers_ObjRefUlils.hxx"
|
||||
|
||||
#include <SALOMEDS_wrap.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
using namespace std;
|
||||
@ -60,8 +61,8 @@ StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject (const std::string& theEntry,
|
||||
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
|
||||
SALOMEDS::Study_var study = gen->GetCurrentStudy();
|
||||
if ( ! theEntry.empty() && ! study->_is_nil() ) {
|
||||
SALOMEDS::SObject_var sobj= study->FindObjectID( theEntry.c_str() );
|
||||
CORBA::Object_var obj = gen->SObjectToObject( sobj );
|
||||
SALOMEDS::SObject_wrap sobj = study->FindObjectID( theEntry.c_str() );
|
||||
CORBA::Object_var obj = gen->SObjectToObject( sobj );
|
||||
geom = GEOM::GEOM_Object::_narrow( obj );
|
||||
}
|
||||
}
|
||||
@ -87,9 +88,10 @@ void StdMeshers_ObjRefUlils::SaveToStream( const TopoDS_Shape& theShape, ostream
|
||||
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
|
||||
GEOM::GEOM_Object_var geom = gen->ShapeToGeomObject( theShape );
|
||||
if ( ! geom->_is_nil() ) {
|
||||
SALOMEDS::SObject_var sobj = gen->ObjectToSObject( gen->GetCurrentStudy(), geom );
|
||||
SALOMEDS::SObject_wrap sobj = gen->ObjectToSObject( gen->GetCurrentStudy(), geom );
|
||||
if ( !sobj->_is_nil() ) {
|
||||
stream << " " << sobj->GetID();
|
||||
CORBA::String_var entry = sobj->GetID();
|
||||
stream << " " << entry.in();
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
@ -114,9 +116,9 @@ TopoDS_Shape StdMeshers_ObjRefUlils::LoadFromStream( istream & stream)
|
||||
if ( ! study->_is_nil() ) {
|
||||
string str;
|
||||
if (stream >> str) {
|
||||
SALOMEDS::SObject_var sobj= study->FindObjectID( str.c_str() );
|
||||
CORBA::Object_var obj = gen->SObjectToObject( sobj );
|
||||
GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj );
|
||||
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() );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user