23586: [EDF] HYDRO: Copy mesh to new geometry

This commit is contained in:
eap 2018-09-17 22:24:36 +03:00
parent 37d2abfafb
commit 6df8817c1a
90 changed files with 2473 additions and 725 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -4,7 +4,10 @@
Copy Mesh Copy Mesh
********* *********
A mesh can be created by copying a part of or the whole other mesh. A mesh can be created by copying a part of or the whole other mesh. There are two modes of the operation:
* copy mesh elements only;
* copy mesh definition to another geometry. This mode can be used only if the source mesh is based on geometry. It is supposed that the new geometry is a modified geometry of the source mesh.
*To make a copy of a mesh:* *To make a copy of a mesh:*
@ -20,6 +23,7 @@ The following dialog box will appear:
In the dialog: In the dialog:
* select the mode of the operation.
* specify the part of mesh to copy: * specify the part of mesh to copy:
* **Select whole mesh, sub-mesh or group** by mouse activating this checkbox; or * **Select whole mesh, sub-mesh or group** by mouse activating this checkbox; or
@ -28,12 +32,16 @@ In the dialog:
* apply Filters. **Set filter** button allows to apply a filter to the selection of elements. See more about filters in the :ref:`selection_filter_library_page` page. * apply Filters. **Set filter** button allows to apply a filter to the selection of elements. See more about filters in the :ref:`selection_filter_library_page` page.
* specify the **New Mesh Name**; * specify the **New Mesh Name**;
* select the **New Geometry**;
* specify the conditions of copying: * specify the conditions of copying:
* activate **Generate groups** checkbox to copy the groups of the source mesh to the newly created mesh. * activate **Generate groups** check-box to copy the groups of the source mesh to the newly created mesh. In the mode of copying to new geometry, standalone groups are copied only if **Copy Mesh Elements** is activated.
* activate **Reuse hypotheses** check-box to use hypotheses applied to the source mesh in the new mesh. Hypotheses having parameters defined as sub-shapes will be copied independently of this check-box state.
* activate **Copy Mesh Element** to copy mesh elements of sub-shapes that are not modified.
* Click **Apply** or **Apply and Close** button to confirm the operation. * Click **Apply** or **Apply and Close** button to confirm the operation.
When copying the mesh to the new geometry, it can happen that a sub-shape used to define a sub-mesh, group or hypotheses is not found in the new geometry. In this case a new object depending on the not found sub-shape is marked with red color in the Object Browser in order to allow identifying such objects and to fix them, either by modifying their definition or by removing. If a depending object is a group on geometry, a standalone group is created instead. You can't transform it to a group on geometry, it can only be removed and re-created anew.
**See Also** a sample script of :ref:`tui_copy_mesh`. **See Also** a sample script of :ref:`tui_copy_mesh`.

View File

@ -280,6 +280,37 @@ module SMESH
in boolean toKeepIDs) in boolean toKeepIDs)
raises ( SALOME::SALOME_Exception ); raises ( SALOME::SALOME_Exception );
/*!
* Create a mesh by copying definitions of another mesh to a given geometry
* \param sourceMesh - a mesh to copy
* \param newGeometry - a new geometry
* \param meshName - a name of the new mesh
* \param toCopyGroups - to create groups in the new mesh
* \param toReuseHypotheses - if True, existing hypothesis will be used by the new mesh,
* otherwise new hypotheses with the same parameters will be created for the new mesh.
* \param toCopyElements - to copy mesh elements of same sub-shapes of the two geometries
* \param newMesh - return a new mesh
* \param newGroups - return new groups
* \param newSubmeshes - return new sub-meshes
* \param newHypotheses - return new algorithms and hypotheses
* \param invalidEntries - return study entries of objects whose
* counterparts are not found in the newGeometry, followed by entries
* of mesh sub-objects that are invalid because they depend on a not found
* preceeding sub-shape
*/
boolean CopyMeshWithGeom( in SMESH_Mesh sourceMesh,
in GEOM::GEOM_Object newGeometry,
in string meshName,
in boolean toCopyGroups,
in boolean toReuseHypotheses,
in boolean toCopyElements,
out SMESH_Mesh newMesh,
out ListOfGroups newGroups,
out submesh_array newSubmeshes,
out ListOfHypothesis newHypotheses,
out string_array invalidEntries)
raises ( SALOME::SALOME_Exception );
/*! /*!
* Concatenate the given meshes or groups into one mesh. * Concatenate the given meshes or groups into one mesh.
* Union groups with the same name and type if * Union groups with the same name and type if

View File

@ -196,6 +196,7 @@ SET(SMESH_RESOURCES_FILES
mesh_tree_hypo_quadratic.png mesh_tree_hypo_quadratic.png
mesh_build_compound.png mesh_build_compound.png
copy_mesh.png copy_mesh.png
copy_mesh_with_geom.png
mesh_node_to_point.png mesh_node_to_point.png
mesh_tree_mesh_partial.png mesh_tree_mesh_partial.png
mesh_extractGroup.png mesh_extractGroup.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

View File

@ -1193,8 +1193,8 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
if ( !GetMeshDS()->IsUsedHypothesis( hyp )) if ( !GetMeshDS()->IsUsedHypothesis( hyp ))
return; return;
if (_callUp) if (_callUp && hyp)
_callUp->HypothesisModified(); _callUp->HypothesisModified( hyp->GetID() );
SMESH_Algo *algo; SMESH_Algo *algo;
const SMESH_HypoFilter* compatibleHypoKind; const SMESH_HypoFilter* compatibleHypoKind;

View File

@ -334,7 +334,7 @@ class SMESH_EXPORT SMESH_Mesh
struct TCallUp // callback from SMESH to SMESH_I level struct TCallUp // callback from SMESH to SMESH_I level
{ {
virtual void RemoveGroup (const int theGroupID)=0; virtual void RemoveGroup (const int theGroupID)=0;
virtual void HypothesisModified ()=0; virtual void HypothesisModified (int theHypID)=0;
virtual void Load ()=0; virtual void Load ()=0;
virtual ~TCallUp() {} virtual ~TCallUp() {}
}; };

View File

@ -365,7 +365,7 @@ int SMESH_subMesh::computeCost() const
*/ */
//============================================================================= //=============================================================================
const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn() const std::map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn()
{ {
if ( _dependenceAnalysed || !_father->HasShapeToMesh() ) if ( _dependenceAnalysed || !_father->HasShapeToMesh() )
return _mapDepend; return _mapDepend;

View File

@ -24,32 +24,34 @@
#include "SMESHGUI_CopyMeshDlg.h" #include "SMESHGUI_CopyMeshDlg.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_IdValidator.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_Selection.h"
#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h"
#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h> #include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx> #include <SMESH_TypeFilter.hxx>
#include <SMDS_Mesh.hxx> #include <SMDS_Mesh.hxx>
// SALOME GUI includes // SALOME GUI includes
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
#include <LightApp_Application.h> #include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <SALOME_ListIO.hxx>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SVTK_ViewModel.h> #include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
#include <SALOME_ListIO.hxx> #include <SalomeApp_Tools.h>
// SALOME KERNEL includes // SALOME KERNEL includes
#include <SALOMEDSClient_Study.hxx>
#include <SALOMEDSClient_SObject.hxx> #include <SALOMEDSClient_SObject.hxx>
// OCCT includes // OCCT includes
@ -113,7 +115,8 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
myFilterDlg(0), myFilterDlg(0),
myIsApplyAndClose( false ) myIsApplyAndClose( false )
{ {
QPixmap image (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH")));
QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH_WG")));
setModal(false); setModal(false);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
@ -126,18 +129,21 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
/***************************************************************/ /***************************************************************/
ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this); ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this);
QButtonGroup* GroupConstructors = new QButtonGroup(this); GroupConstructors = new QButtonGroup(this);
QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox); QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
ConstructorsBoxLayout->setSpacing(SPACING); ConstructorsBoxLayout->setSpacing(SPACING);
ConstructorsBoxLayout->setMargin(MARGIN); ConstructorsBoxLayout->setMargin(MARGIN);
QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox); QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox);
RadioButton1->setIcon(image); RadioButton1->setIcon(image1);
GroupConstructors->addButton(RadioButton1, 0); GroupConstructors->addButton(RadioButton1, 0);
QRadioButton* RadioButton2= new QRadioButton(ConstructorsBox);
RadioButton2->setIcon(image2);
GroupConstructors->addButton(RadioButton2, 1);
ConstructorsBoxLayout->addWidget(RadioButton1); ConstructorsBoxLayout->addWidget(RadioButton1);
ConstructorsBoxLayout->addWidget(RadioButton2);
RadioButton1->setChecked(true); RadioButton1->setChecked(true);
GroupConstructors->addButton(RadioButton1, 0);
/***************************************************************/ /***************************************************************/
GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this); GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
@ -164,13 +170,26 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
// CheckBox for copying groups // CheckBox for copying groups
myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
myCopyGroupsCheck->setChecked(false); myCopyGroupsCheck->setChecked(true);
// CheckBox for keeping ids ( OBSOLETE ) // CheckBox for keeping ids ( OBSOLETE )
myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments); myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments);
myKeepIdsCheck->setChecked(true); myKeepIdsCheck->setChecked(true);
myKeepIdsCheck->hide(); myKeepIdsCheck->hide();
// New geometry
myGeomLabel = new QLabel( tr("NEW_GEOM"), GroupArguments );
myGeomNameEdit = new QLineEdit( GroupArguments );
myGeomNameEdit->setReadOnly(true);
// CheckBox to reuse hypotheses
myReuseHypCheck = new QCheckBox(tr("REUSE_HYPOTHESES"), GroupArguments);
myReuseHypCheck->setChecked(true);
// CheckBox to copy mesh elements
myCopyElementsCheck = new QCheckBox(tr("COPY_ELEMENTS"), GroupArguments);
myCopyElementsCheck->setChecked(true);
// layout // layout
GroupArgumentsLayout->addWidget(myTextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(myTextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(myLineEditElements, 0, 1, 1, 5); GroupArgumentsLayout->addWidget(myLineEditElements, 0, 1, 1, 5);
@ -178,8 +197,13 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
GroupArgumentsLayout->addWidget(myIdSourceCheck, 1, 0, 1, 6); GroupArgumentsLayout->addWidget(myIdSourceCheck, 1, 0, 1, 6);
GroupArgumentsLayout->addWidget(meshNameLabel, 2, 0); GroupArgumentsLayout->addWidget(meshNameLabel, 2, 0);
GroupArgumentsLayout->addWidget(myMeshNameEdit, 2, 1, 1, 5); GroupArgumentsLayout->addWidget(myMeshNameEdit, 2, 1, 1, 5);
GroupArgumentsLayout->addWidget(myCopyGroupsCheck, 3, 0, 1, 6); GroupArgumentsLayout->addWidget(myGeomLabel, 3, 0);
// GroupArgumentsLayout->addWidget(myKeepIdsCheck, 4, 0, 1, 6); GroupArgumentsLayout->addWidget(myGeomNameEdit, 3, 1, 1, 5);
GroupArgumentsLayout->addWidget(myCopyGroupsCheck, 4, 0, 1, 6);
GroupArgumentsLayout->addWidget(myReuseHypCheck, 5, 0, 1, 6);
GroupArgumentsLayout->addWidget(myCopyElementsCheck, 6, 0, 1, 6);
// GroupArgumentsLayout->addWidget(myKeepIdsCheck, 7, 0, 1, 6);
GroupArgumentsLayout->setRowStretch( 6, 1 );
/***************************************************************/ /***************************************************************/
GroupButtons = new QGroupBox(this); GroupButtons = new QGroupBox(this);
@ -243,6 +267,9 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
this, SLOT (onTextChange(const QString&))); this, SLOT (onTextChange(const QString&)));
connect(myIdSourceCheck, SIGNAL(toggled(bool)), connect(myIdSourceCheck, SIGNAL(toggled(bool)),
this, SLOT (onSelectIdSource(bool))); this, SLOT (onSelectIdSource(bool)));
connect(GroupConstructors, SIGNAL(buttonClicked(int)),
this, SLOT (onConstructor(int)));
SelectionIntoArgument(); SelectionIntoArgument();
} }
@ -275,11 +302,12 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
{ {
myBusy = false; myBusy = false;
myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh")); if ( !isWithGeomMode() )
myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
if ( ResetControls ) if ( ResetControls )
{ {
myLineEditElements->clear(); myLineEditElements->clear();
//myElementsId = "";
myNbOkElements = 0; myNbOkElements = 0;
buttonOk->setEnabled(false); buttonOk->setEnabled(false);
@ -289,13 +317,100 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_Mesh::_nil();
myIdSourceCheck->setChecked(true); myIdSourceCheck->setChecked(true);
myCopyGroupsCheck->setChecked(false);
myKeepIdsCheck->setChecked(false);
onSelectIdSource( myIdSourceCheck->isChecked() ); onConstructor( 0 );
} }
} }
//=======================================================================
//function : onConstructor
//purpose : switch operation mode
//=======================================================================
void SMESHGUI_CopyMeshDlg::onConstructor( int withGeom )
{
myGeomLabel ->setVisible( withGeom );
myGeomNameEdit ->setVisible( withGeom );
myReuseHypCheck ->setVisible( withGeom );
myCopyElementsCheck->setVisible( withGeom );
myFilterBtn ->setVisible( !withGeom );
myIdSourceCheck ->setVisible( !withGeom );
if ( !withGeom )
myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
onSelectIdSource( /*toSelectMesh=*/ myIdSourceCheck->isChecked() || withGeom );
}
//=======================================================================
//function : getErrorMsg
//purpose : Return an error message and entries of invalid smesh object
//=======================================================================
QString SMESHGUI_CopyMeshDlg::getErrorMsg( SMESH::string_array_var theInvalidEntries,
QStringList & theEntriesToBrowse )
{
if ( theInvalidEntries->length() == 0 )
return tr("SMESH_OPERATION_FAILED");
// theInvalidEntries - SObject's that hold geometry objects whose
// counterparts are not found in the newGeometry, followed by SObject's
// holding mesh sub-objects that are invalid because they depend on a not found
// preceeding sub-shape
QString msg = tr("SUBSHAPES_NOT_FOUND_MSG") + "\n";
QString objString;
for ( CORBA::ULong i = 0; i < theInvalidEntries->length(); ++i )
{
_PTR(SObject) so = SMESH::getStudy()->FindObjectID( theInvalidEntries[i].in() );
int objType = SMESHGUI_Selection::type( theInvalidEntries[i].in() );
if ( objType < 0 ) // geom object
{
objString += "\n";
if ( so )
objString += so->GetName().c_str();
else
objString += theInvalidEntries[i].in(); // it's something like "FACE #2"
}
else // smesh object
{
theEntriesToBrowse.push_back( theInvalidEntries[i].in() );
objString += "\n ";
switch ( objType ) {
case SMESH::MESH:
objString += tr("SMESH_MESH"); break;
case SMESH::HYPOTHESIS:
objString += tr("SMESH_HYPOTHESIS"); break;
case SMESH::ALGORITHM:
objString += tr("SMESH_ALGORITHM"); break;
case SMESH::SUBMESH_VERTEX:
case SMESH::SUBMESH_EDGE:
case SMESH::SUBMESH_FACE:
case SMESH::SUBMESH_SOLID:
case SMESH::SUBMESH_COMPOUND:
case SMESH::SUBMESH:
objString += tr("SMESH_SUBMESH"); break;
case SMESH::GROUP:
objString += tr("SMESH_GROUP"); break;
default:;
}
objString += " \"";
if ( so )
objString += so->GetName().c_str();
objString += "\" (";
objString += theInvalidEntries[i].in();
objString += ")";
}
}
if ( !objString.isEmpty() )
msg += objString;
return msg;
}
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -303,13 +418,14 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
bool SMESHGUI_CopyMeshDlg::ClickOnApply() bool SMESHGUI_CopyMeshDlg::ClickOnApply()
{ {
if (SMESHGUI::isStudyLocked()) if ( SMESHGUI::isStudyLocked() )
return false; return false;
if( !isValid() ) if( !isValid() )
return false; return false;
QStringList anEntryList; QStringList anEntryList;
bool toShowObjects = isApplyAndClose();
try try
{ {
SUIT_OverrideCursor aWaitCursor; SUIT_OverrideCursor aWaitCursor;
@ -333,16 +449,55 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
} }
QByteArray meshName = myMeshNameEdit->text().toUtf8(); QByteArray meshName = myMeshNameEdit->text().toUtf8();
bool toCopyGroups = ( myCopyGroupsCheck->isChecked() ); bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
bool toReuseHyps = ( myReuseHypCheck->isChecked() );
bool toCopyElems = ( myCopyElementsCheck->isChecked() );
bool toKeepIDs = ( myKeepIdsCheck->isChecked() ); bool toKeepIDs = ( myKeepIdsCheck->isChecked() );
SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen(); SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
SMESH::SMESH_Mesh_var newMesh = SMESH::SMESH_Mesh_var newMesh;
gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs); if ( isWithGeomMode() )
if( !newMesh->_is_nil() ) {
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) ) SMESH::SMESH_Mesh_var srcMesh = mySelectedObject->GetMesh();
SMESH::ListOfGroups_var newGroups;
SMESH::submesh_array_var newSubmeshes;
SMESH::ListOfHypothesis_var newHypotheses;
SMESH::string_array_var invalidEntries;
CORBA::Boolean ok = gen->CopyMeshWithGeom( srcMesh, myNewGeometry,
meshName.constData(),
toCopyGroups, toReuseHyps, toCopyElems,
newMesh.out(),
newGroups.out(),
newSubmeshes.out(),
newHypotheses.out(),
invalidEntries.out() );
if ( !ok )
{
if ( invalidEntries->length() > 0 )
toShowObjects = true;
SUIT_MessageBox::warning( this,
tr("SMESH_WRN_WARNING"),
getErrorMsg( invalidEntries, anEntryList ));
}
}
else
{
newMesh = gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
}
if ( !newMesh->_is_nil() )
if ( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
{
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
if ( isWithGeomMode() )
SMESH::SetName( aSObject, meshName );
}
} }
catch (...) { catch(const SALOME::SALOME_Exception & S_ex)
{
SalomeApp_Tools::QtCatchCorbaException(S_ex);
}
catch (...)
{
} }
mySMESHGUI->updateObjBrowser(true); mySMESHGUI->updateObjBrowser(true);
@ -350,7 +505,7 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
if( LightApp_Application* anApp = if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) ) dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() ); anApp->browseObjects( anEntryList, toShowObjects );
Init(false); Init(false);
mySelectedObject = SMESH::SMESH_IDSource::_nil(); mySelectedObject = SMESH::SMESH_IDSource::_nil();
@ -503,13 +658,12 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
myActor = 0; myActor = 0;
QString aString = ""; QString aString = "";
myLineEditElements->setText(aString);
myNbOkElements = 0; myNbOkElements = 0;
buttonOk->setEnabled(false); buttonOk->setEnabled(false);
buttonApply->setEnabled(false); buttonApply->setEnabled(false);
myFilterBtn->setEnabled(false); myFilterBtn->setEnabled(false);
// get selected mesh // get selected mesh or geometry
SALOME_ListIO aList; SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList); mySelectionMgr->selectedObjects(aList);
int nbSel = aList.Extent(); int nbSel = aList.Extent();
@ -517,19 +671,29 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
return; return;
Handle(SALOME_InteractiveObject) IO = aList.First(); Handle(SALOME_InteractiveObject) IO = aList.First();
mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
if ( mySelectedObject->_is_nil() ) SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(IO);
GEOM::GEOM_Object_var geom = SMESH::GetGeom(IO);
if ( !mesh->_is_nil() )
{
myMesh = mesh;
myActor = SMESH::FindActorByEntry(IO->getEntry());
if (!myActor)
myActor = SMESH::FindActorByObject(myMesh);
mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
if ( mySelectedObject->_is_nil() )
return;
}
else if ( !geom->_is_nil() )
{
myNewGeometry = geom;
}
else
return; return;
myMesh = SMESH::GetMeshByIO(IO); if (myIdSourceCheck->isChecked() || isWithGeomMode() )
if (myMesh->_is_nil())
return;
myActor = SMESH::FindActorByEntry(IO->getEntry());
if (!myActor)
myActor = SMESH::FindActorByObject(myMesh);
if (myIdSourceCheck->isChecked())
{ {
SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
if ( aString.isEmpty() ) aString = " "; if ( aString.isEmpty() ) aString = " ";
@ -541,8 +705,23 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
myNbOkElements = aString.size(); myNbOkElements = aString.size();
myFilterBtn->setEnabled(true); myFilterBtn->setEnabled(true);
} }
myLineEditElements->setText( aString );
bool ok = !aString.isEmpty(); bool ok = !aString.isEmpty();
if ( !mesh->_is_nil() )
{
myLineEditElements->setText( aString );
if ( isWithGeomMode() )
myMeshNameEdit->setText( aString );
}
else if ( !geom->_is_nil() )
{
myGeomNameEdit->setText( aString );
ok = ok && !myLineEditElements->text().isEmpty();
}
if ( ok && isWithGeomMode() && !myMesh->_is_nil() )
ok = myMesh->HasShapeToMesh();
buttonOk->setEnabled(ok); buttonOk->setEnabled(ok);
buttonApply->setEnabled(ok); buttonApply->setEnabled(ok);
@ -554,7 +733,9 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
//======================================================================= //=======================================================================
void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh) void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
{ {
if (toSelectMesh) if ( isWithGeomMode() )
myTextLabelElements->setText(tr("SMESH_MESH"));
else if ( toSelectMesh )
myTextLabelElements->setText(tr("OBJECT_NAME")); myTextLabelElements->setText(tr("OBJECT_NAME"));
else else
myTextLabelElements->setText(tr("ELEM_IDS")); myTextLabelElements->setText(tr("ELEM_IDS"));
@ -564,7 +745,8 @@ void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
} }
mySelectionMgr->clearFilters(); mySelectionMgr->clearFilters();
mySelectionMgr->installFilter(myIdSourceFilter); if ( !isWithGeomMode() )
mySelectionMgr->installFilter(myIdSourceFilter);
SMESH::SetPointRepresentation(false); SMESH::SetPointRepresentation(false);
if (toSelectMesh) { if (toSelectMesh) {
@ -592,10 +774,29 @@ void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
bool SMESHGUI_CopyMeshDlg::isValid() bool SMESHGUI_CopyMeshDlg::isValid()
{ {
if ( myIdSourceCheck->isChecked() ) bool ok = false;
return !mySelectedObject->_is_nil(); if ( myIdSourceCheck->isChecked() || isWithGeomMode() )
{
ok = ( !mySelectedObject->_is_nil() );
if ( isWithGeomMode() )
ok = ok && ( !myNewGeometry->_is_nil() );
}
else
{
ok = ( myNbOkElements > 0 );
}
return myNbOkElements > 0; return ok;
}
//=======================================================================
//function : isWithGeomMode
//purpose : Return true if the mode is "with geometry"
//=======================================================================
bool SMESHGUI_CopyMeshDlg::isWithGeomMode()
{
return ( GroupConstructors->checkedId() == 1 );
} }
//================================================================================= //=================================================================================

View File

@ -35,12 +35,14 @@
// IDL includes // IDL includes
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Gen)
class QCheckBox; class QCheckBox;
class QGroupBox; class QGroupBox;
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
class QPushButton; class QPushButton;
class QButtonGroup;
class SMESHGUI; class SMESHGUI;
class SMESHGUI_IdValidator; class SMESHGUI_IdValidator;
@ -56,10 +58,10 @@ class SUIT_SelectionFilter;
//================================================================================= //=================================================================================
class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public QDialog class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_CopyMeshDlg( SMESHGUI* ); SMESHGUI_CopyMeshDlg( SMESHGUI* );
~SMESHGUI_CopyMeshDlg(); ~SMESHGUI_CopyMeshDlg();
@ -67,10 +69,12 @@ private:
void Init( bool = true ); void Init( bool = true );
void enterEvent( QEvent* ); /* mouse enter the QWidget */ void enterEvent( QEvent* ); /* mouse enter the QWidget */
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
int GetConstructorId();
void setNewMeshName(); void setNewMeshName();
QString getErrorMsg( SMESH::string_array_var invalidEntries,
QStringList & entriesToBrowse );
bool isValid(); bool isValid();
bool isWithGeomMode();
void setIsApplyAndClose( const bool theFlag ); void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const; bool isApplyAndClose() const;
@ -84,11 +88,14 @@ private:
bool myBusy; bool myBusy;
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Mesh_var myMesh;
GEOM::GEOM_Object_var myNewGeometry;
SMESH_Actor* myActor; SMESH_Actor* myActor;
SUIT_SelectionFilter* myIdSourceFilter; SUIT_SelectionFilter* myIdSourceFilter;
SMESH::SMESH_IDSource_var mySelectedObject; SMESH::SMESH_IDSource_var mySelectedObject;
QButtonGroup* GroupConstructors;
QGroupBox* ConstructorsBox; QGroupBox* ConstructorsBox;
QGroupBox* GroupArguments; QGroupBox* GroupArguments;
QGroupBox* GroupButtons; QGroupBox* GroupButtons;
@ -99,10 +106,14 @@ private:
QPushButton* buttonHelp; QPushButton* buttonHelp;
QLabel* myTextLabelElements; QLabel* myTextLabelElements;
QLabel* myGeomLabel;
QLineEdit* myLineEditElements; QLineEdit* myLineEditElements;
QLineEdit* myMeshNameEdit; QLineEdit* myMeshNameEdit;
QLineEdit* myGeomNameEdit;
QCheckBox* myIdSourceCheck; QCheckBox* myIdSourceCheck;
QCheckBox* myCopyGroupsCheck; QCheckBox* myCopyGroupsCheck;
QCheckBox* myReuseHypCheck;
QCheckBox* myCopyElementsCheck;
QCheckBox* myKeepIdsCheck; QCheckBox* myKeepIdsCheck;
QPushButton* myFilterBtn; QPushButton* myFilterBtn;
@ -122,6 +133,7 @@ private slots:
void SelectionIntoArgument(); void SelectionIntoArgument();
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void ActivateThisDialog(); void ActivateThisDialog();
void onConstructor( int );
void onTextChange( const QString& ); void onTextChange( const QString& );
void onSelectIdSource( bool ); void onSelectIdSource( bool );
void setFilters(); void setFilters();

View File

@ -111,6 +111,17 @@ namespace SMESH
return aMeshShape; return aMeshShape;
} }
GEOM::GEOM_Object_var GetGeom( Handle(SALOME_InteractiveObject) io )
{
GEOM::GEOM_Object_var go;
if ( !io.IsNull() && io->hasEntry() )
{
_PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
go = GetGeom( so );
}
return go._retn();
}
SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO ) SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO )
{ {
if (!smeshSO) if (!smeshSO)

View File

@ -51,6 +51,8 @@ namespace SMESH
SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( _PTR(SObject) ); SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( _PTR(SObject) );
SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( Handle(SALOME_InteractiveObject) io );
SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO ); SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO );
SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long ); SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long );

View File

@ -523,13 +523,15 @@ namespace SMESH
if(MYDEBUG) MESSAGE("Loading client meshers plugin library ..."); if(MYDEBUG) MESSAGE("Loading client meshers plugin library ...");
#ifdef WIN32 #ifdef WIN32
#ifdef UNICODE #ifdef UNICODE
LPTSTR path = new TCHAR[aClientLibName.length() + 1]; LPTSTR path = new TCHAR[aClientLibName.length() + 1];
path[aClientLibName.toWCharArray(path)] = '\0'; path[aClientLibName.toWCharArray(path)] = '\0';
#else #else
const char* path = aClientLibName.toUtf8().data(); QByteArray baPath = aClientLibName.toUtf8();
const char* path = baPath.data();
#endif #endif
#else #else
char* path = aClientLibName.toUtf8().data(); QByteArray baPath = aClientLibName.toUtf8();
char* path = baPath.data();
#endif #endif
LibHandle libHandle = LoadLib( path ); LibHandle libHandle = LoadLib( path );
if (!libHandle) { if (!libHandle) {

View File

@ -92,6 +92,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
myShapeByMeshOp( 0 ), myShapeByMeshOp( 0 ),
myToCreate( theToCreate ), myToCreate( theToCreate ),
myIsMesh( theIsMesh ), myIsMesh( theIsMesh ),
myIsInvalidSubMesh( false ),
myHypoSet( 0 ) myHypoSet( 0 )
{ {
if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
@ -152,7 +153,7 @@ bool SMESHGUI_MeshOp::onApply()
QStringList anEntryList; QStringList anEntryList;
if ( myToCreate && myIsMesh ) if ( myToCreate && myIsMesh )
aResult = createMesh( aMess, anEntryList ); aResult = createMesh( aMess, anEntryList );
if ( myToCreate && !myIsMesh ) if (( myToCreate && !myIsMesh ) || myIsInvalidSubMesh )
aResult = createSubMesh( aMess, anEntryList ); aResult = createSubMesh( aMess, anEntryList );
else if ( !myToCreate ) else if ( !myToCreate )
aResult = editMeshOrSubMesh( aMess ); aResult = editMeshOrSubMesh( aMess );
@ -519,6 +520,7 @@ void SMESHGUI_MeshOp::selectionDone()
try try
{ {
myIsOnGeometry = true; myIsOnGeometry = true;
myIsInvalidSubMesh = false;
//Check geometry for mesh //Check geometry for mesh
QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj); QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
@ -638,11 +640,21 @@ void SMESHGUI_MeshOp::selectionDone()
SMESH::SMESH_subMesh_var submeshVar = SMESH::SMESH_subMesh_var submeshVar =
SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() ); SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
myIsMesh = submeshVar->_is_nil(); myIsMesh = submeshVar->_is_nil();
myIsInvalidSubMesh = ( !myIsMesh && submeshVar->GetId() < 1 );
myDlg->setTitile( myToCreate, myIsMesh ); myDlg->setTitile( myToCreate, myIsMesh );
myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !submeshVar->_is_nil() ); myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !submeshVar->_is_nil() );
myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true ); myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide(); myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide(); if ( myIsInvalidSubMesh )
{
// it is necessary to select a new geometry
myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->show();
myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
}
else
{
myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
}
myDlg->updateGeometry(); myDlg->updateGeometry();
myDlg->adjustSize(); myDlg->adjustSize();
readMesh(); readMesh();
@ -1877,9 +1889,9 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
//================================================================================ //================================================================================
/*! /*!
* \brief Creates sub-mesh * \brief Creates sub-mesh
* \param theMess - Output parameter intended for returning error message * \param theMess - Output parameter intended for returning error message
* \param theEntryList - List of entries of published objects * \param theEntryList - List of entries of published objects
* \retval bool - TRUE if sub-mesh is created, FALSE otherwise * \retval bool - TRUE if sub-mesh is created, FALSE otherwise
* *
* Creates sub-mesh * Creates sub-mesh
*/ */
@ -1893,11 +1905,16 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
return false; return false;
// get mesh object // get mesh object
QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
_PTR(SObject) pMesh = SMESH::getStudy()->FindObjectID( aMeshEntry.toUtf8().data() );
SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh_var aMeshVar =
SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() ); SMESH::EntryToInterface<SMESH::SMESH_Mesh>( myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ));
if (aMeshVar->_is_nil()) if ( aMeshVar->_is_nil() && myIsInvalidSubMesh )
{
SMESH::SMESH_subMesh_var aSMVar =
SMESH::EntryToInterface<SMESH::SMESH_subMesh>( myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ));
if ( !aSMVar->_is_nil() )
aMeshVar = aSMVar->GetMesh();
}
if ( aMeshVar->_is_nil() )
return false; return false;
// GEOM shape of the main mesh // GEOM shape of the main mesh
@ -1971,8 +1988,14 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
SUIT_OverrideCursor aWaitCursor; SUIT_OverrideCursor aWaitCursor;
QString aNameOrID = aName;
if ( myIsInvalidSubMesh )
// pass a sub-mesh entry to mesh->GetSubMesh() to replace the invalid sub-mesh
// by a valid one in an existing SO
aNameOrID = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
// create sub-mesh // create sub-mesh
SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toUtf8().data() ); SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aNameOrID.toUtf8().data() );
_PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() ); _PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() );
if ( aSubMeshSO ) { if ( aSubMeshSO ) {
SMESH::SetName( aSubMeshSO, aName.toUtf8().data() ); SMESH::SetName( aSubMeshSO, aName.toUtf8().data() );
@ -2249,10 +2272,13 @@ void SMESHGUI_MeshOp::readMesh()
myHasConcurrentSubBefore = checkSubMeshConcurrency( aMeshVar, aSubMeshVar ); myHasConcurrentSubBefore = checkSubMeshConcurrency( aMeshVar, aSubMeshVar );
} }
// Get name of geometry object if ( !myIsInvalidSubMesh )
CORBA::String_var name = SMESH::GetGeomName( pObj ); {
if ( name.in() ) // Get name of geometry object
myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, name.in() ); CORBA::String_var name = SMESH::GetGeomName( pObj );
if ( name.in() )
myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, name.in() );
}
} }
// Get hypotheses and algorithms assigned to the mesh/sub-mesh // Get hypotheses and algorithms assigned to the mesh/sub-mesh

View File

@ -153,8 +153,11 @@ private:
SMESHGUI_ShapeByMeshOp* myShapeByMeshOp; SMESHGUI_ShapeByMeshOp* myShapeByMeshOp;
bool myToCreate; bool myToCreate;
bool myIsMesh; bool myIsMesh;
bool myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object bool myIsOnGeometry; //!< TRUE if edited mesh is based on geometry
bool myHasConcurrentSubBefore; bool myHasConcurrentSubBefore;
bool myIsInvalidSubMesh; //!< "invalid sub-mesh" is edited
// The geometry of "invalid sub-mesh" is not a sub-shape of the main shape;
// it is created for the case where a valid sub-shape not found by CopyMeshWithGeom()
TDim2Type2HypList myExistingHyps; //!< all hypothesis of SMESH module TDim2Type2HypList myExistingHyps; //!< all hypothesis of SMESH module
TDim2Type2HypList myObjHyps; //!< hypothesis assigned to the current TDim2Type2HypList myObjHyps; //!< hypothesis assigned to the current

View File

@ -226,6 +226,12 @@ namespace SMESH
return app->orb()->string_to_object(theIOR.toLatin1().data()); return app->orb()->string_to_object(theIOR.toLatin1().data());
} }
CORBA::Object_var EntryToObject( const QString& theEntry )
{
_PTR(SObject) anObj = getStudy()->FindObjectID( theEntry.toLatin1().data() );
return SObjectToObject(anObj);
}
int GetNameOfSelectedIObjects(LightApp_SelectionMgr* theMgr, QString& theName) int GetNameOfSelectedIObjects(LightApp_SelectionMgr* theMgr, QString& theName)
{ {
if (!theMgr) if (!theMgr)

View File

@ -152,6 +152,18 @@ SMESHGUI_EXPORT
return TInterface::_nil(); return TInterface::_nil();
} }
SMESHGUI_EXPORT
CORBA::Object_var EntryToObject( const QString& );
template<class TInterface> typename TInterface::_var_type
EntryToInterface( const QString& theEntry )
{
CORBA::Object_var anObj = EntryToObject( theEntry );
if ( !CORBA::is_nil( anObj ) )
return TInterface::_narrow( anObj );
return TInterface::_nil();
}
SMESHGUI_EXPORT SMESHGUI_EXPORT
int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& ); int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& );

View File

@ -35,6 +35,10 @@
<source>ICON_COPY_MESH</source> <source>ICON_COPY_MESH</source>
<translation>copy_mesh.png</translation> <translation>copy_mesh.png</translation>
</message> </message>
<message>
<source>ICON_COPY_MESH_WG</source>
<translation>copy_mesh_with_geom.png</translation>
</message>
<message> <message>
<source>ICON_COMPUTE</source> <source>ICON_COMPUTE</source>
<translation>mesh_compute.png</translation> <translation>mesh_compute.png</translation>

View File

@ -1938,6 +1938,14 @@ add the exported data to its contents?</translation>
<source>SMESH_HYPOTHESES</source> <source>SMESH_HYPOTHESES</source>
<translation>Hypotheses</translation> <translation>Hypotheses</translation>
</message> </message>
<message>
<source>SMESH_HYPOTHESIS</source>
<translation>Hypothesis</translation>
</message>
<message>
<source>SMESH_ALGORITHM</source>
<translation>Algorithm</translation>
</message>
<message> <message>
<source>SMESH_HYP_1</source> <source>SMESH_HYP_1</source>
<translation>Algorithm misses a hypothesis</translation> <translation>Algorithm misses a hypothesis</translation>
@ -8070,6 +8078,25 @@ as they are of improper type:
<source>NEW_NAME</source> <source>NEW_NAME</source>
<translation>New Mesh Name</translation> <translation>New Mesh Name</translation>
</message> </message>
<message>
<source>NEW_GEOM</source>
<translation>New Geometry</translation>
</message>
<message>
<source>REUSE_HYPOTHESES</source>
<translation>Reuse Hypotheses</translation>
</message>
<message>
<source>COPY_ELEMENTS</source>
<translation>Copy Mesh Elements</translation>
</message>
<message>
<source>SUBSHAPES_NOT_FOUND_MSG</source>
<translation>
Some sub-shapes not found in the new geometry. They are listed
below along with dependent mesh objects that are marked with
with red in the Object Browser.</translation>
</message>
</context> </context>
<context> <context>
<name>SMESHGUI_MeasureDlg</name> <name>SMESHGUI_MeasureDlg</name>

View File

@ -1006,10 +1006,10 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
AddObject( mesh ); AddObject( mesh );
return; return;
} }
if( method == "CreateMeshesFromMED" || if ( method == "CreateMeshesFromMED" ||
method == "CreateMeshesFromSAUV"|| method == "CreateMeshesFromSAUV"||
method == "CreateMeshesFromCGNS" || method == "CreateMeshesFromCGNS" ||
method == "CreateMeshesFromGMF" ) // command result is ( [mesh1,mesh2], status ) method == "CreateMeshesFromGMF" ) // command result is ( [mesh1,mesh2], status )
{ {
std::list< _pyID > meshIDs = theCommand->GetStudyEntries( theCommand->GetResultValue() ); std::list< _pyID > meshIDs = theCommand->GetStudyEntries( theCommand->GetResultValue() );
std::list< _pyID >::iterator meshID = meshIDs.begin(); std::list< _pyID >::iterator meshID = meshIDs.begin();
@ -1027,6 +1027,12 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
theCommand->SetArg( 1, file ); theCommand->SetArg( 1, file );
} }
} }
if ( method == "CopyMeshWithGeom" )
{
std::list< _pyID > entries = theCommand->GetStudyEntries( theCommand->GetResultValue() );
Handle(_pyMesh) mesh = new _pyMesh( theCommand, entries.front() );
AddObject( mesh );
}
// CreateHypothesis() // CreateHypothesis()
if ( method == "CreateHypothesis" ) if ( method == "CreateHypothesis" )

View File

@ -81,3 +81,27 @@ SMESH::ListOfHypothesisName* SMESH_Algo_i::GetCompatibleHypothesis()
} }
return listOfHypothesis._retn(); return listOfHypothesis._retn();
} }
//================================================================================
/*!
* Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool SMESH_Algo_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
return false;
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool SMESH_Algo_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
return true;
}

View File

@ -53,6 +53,15 @@ public:
// Gets list of compatible hypotheses // Gets list of compatible hypotheses
SMESH::ListOfHypothesisName* GetCompatibleHypothesis(); SMESH::ListOfHypothesisName* GetCompatibleHypothesis();
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
}; };
#endif #endif

View File

@ -103,6 +103,9 @@
#include "SMESH_PreMeshInfo.hxx" #include "SMESH_PreMeshInfo.hxx"
#include "SMESH_PythonDump.hxx" #include "SMESH_PythonDump.hxx"
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
// to pass CORBA exception through SMESH_TRY
#define SMY_OWN_CATCH catch( SALOME::SALOME_Exception& se ) { throw se; }
#include "SMESH_TryCatch.hxx" // to include after OCC headers! #include "SMESH_TryCatch.hxx" // to include after OCC headers!
#include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Group)
@ -110,6 +113,7 @@
#include CORBA_SERVER_HEADER(SMESH_MeshEditor) #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
#include <GEOMImpl_Types.hxx>
#include <GEOM_Client.hxx> #include <GEOM_Client.hxx>
#include <Basics_Utils.hxx> #include <Basics_Utils.hxx>
@ -138,6 +142,7 @@
#include <sstream> #include <sstream>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <memory>
using namespace std; using namespace std;
using SMESH::TPythonDump; using SMESH::TPythonDump;
@ -440,17 +445,17 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp
// load plugin library // load plugin library
if(MYDEBUG) MESSAGE("Loading server meshers plugin library ..."); if(MYDEBUG) MESSAGE("Loading server meshers plugin library ...");
#ifdef WIN32 #ifdef WIN32
#ifdef UNICODE #ifdef UNICODE
const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName); const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName);
#else
const char* path = aPlatformLibName.c_str();
#endif
#else #else
const char* path = aPlatformLibName.c_str(); const char* path = aPlatformLibName.c_str();
#endif
#else
const char* path = aPlatformLibName.c_str();
#endif #endif
LibHandle libHandle = LoadLib( path ); LibHandle libHandle = LoadLib( path );
#if defined(WIN32) && defined(UNICODE) #if defined(WIN32) && defined(UNICODE)
delete path; delete path;
#endif #endif
if (!libHandle) if (!libHandle)
{ {
@ -1938,7 +1943,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
try { try {
// get mesh servant // get mesh servant
SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( theMesh ).in() ); SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
ASSERT( meshServant ); ASSERT( meshServant );
if ( meshServant ) { if ( meshServant ) {
meshServant->Load(); meshServant->Load();
@ -1960,6 +1965,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
meshServant->CreateGroupServants(); // algos can create groups (issue 0020918) meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
myLocMesh.GetMeshDS()->Modified(); myLocMesh.GetMeshDS()->Modified();
UpdateIcons( theMesh ); UpdateIcons( theMesh );
HighLightInvalid( theMesh, /*isInvalid=*/!ok );
return ok; return ok;
} }
} }
@ -2724,10 +2730,12 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
const char* meshName, const char* meshName,
CORBA::Boolean toCopyGroups, CORBA::Boolean toCopyGroups,
CORBA::Boolean toKeepIDs) CORBA::Boolean toKeepIDs)
throw ( SALOME::SALOME_Exception )
{ {
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh() TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh()
std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
// 1. Get source mesh // 1. Get source mesh
@ -2930,7 +2938,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
<< toCopyGroups << ", " << toCopyGroups << ", "
<< toKeepIDs << ")"; << toKeepIDs << ")";
delete pyDump; pyDump = 0; // allow dump in GetGroups() pyDumpDeleter.reset(); // allow dump in GetGroups()
if ( nbNewGroups > 0 ) // dump created groups if ( nbNewGroups > 0 ) // dump created groups
SMESH::ListOfGroups_var groups = newMesh->GetGroups(); SMESH::ListOfGroups_var groups = newMesh->GetGroups();
@ -2938,6 +2946,868 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
return newMesh._retn(); return newMesh._retn();
} }
namespace // utils for CopyMeshWithGeom()
{
typedef std::map< std::string, std::string > TStr2StrMap;
typedef std::map< std::string, std::set< std::string > > TStr2StrSetMap;
//================================================================================
/*!
* \brief Return a new sub-shape corresponding to an old one
*/
//================================================================================
struct ShapeMapper
{
SMESH_Mesh_i* mySrcMesh_i;
SMESH_Mesh_i* myNewMesh_i;
SMESH_Gen_i* myGen_i;
bool myToPublish;
bool myIsSameGeom;
TStr2StrMap myOld2NewEntryMap; // map of study entries
bool myGIPMapDone;
GEOM::ListOfListOfLong_var myGIPMap; // filled by GetInPlaceMap()
// not directly relating to shape search
TStr2StrSetMap myInvalidMap; // blame shape -> invalid objects
//================================================================================
/*!
* \brief Constructor
*/
ShapeMapper( SMESH_Mesh_i* srcMesh_i,
SMESH_Mesh_i* newMesh_i,
SMESH_Gen_i* smeshGen_i )
: mySrcMesh_i( srcMesh_i ),
myNewMesh_i( newMesh_i ),
myGen_i ( smeshGen_i ),
myToPublish( smeshGen_i->IsEnablePublish() ),
myGIPMapDone( false )
{
// retrieve from the study shape mapping made thanks to
// "Set presentation parameters and sub-shapes from arguments" option
GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
GEOM::GEOM_Object_var mainShapeOld = mySrcMesh_i->GetShapeToMesh();
SALOMEDS::SObject_wrap oldSO = myGen_i->ObjectToSObject( mainShapeOld );
SALOMEDS::SObject_wrap newSO = myGen_i->ObjectToSObject( mainShapeNew );
if ( newSO->_is_nil() )
{
myToPublish = false;
return;
}
if (( myIsSameGeom = mainShapeNew->_is_equivalent( mainShapeOld )))
return;
CORBA::String_var oldEntry = oldSO->GetID();
CORBA::String_var newEntry = newSO->GetID();
myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ),
std::string( newEntry.in() )));
SALOMEDS::Study_var study = myGen_i->getStudyServant();
GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine();
GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
GEOM::ListOfGO_var subShapes = op->GetExistingSubObjects( mainShapeNew,
/*groupsOnly=*/false );
for ( CORBA::ULong i = 0; i < subShapes->length(); ++i )
{
newSO = myGen_i->ObjectToSObject( subShapes[ i ]);
SALOMEDS::ChildIterator_wrap anIter = study->NewChildIterator( newSO );
for ( ; anIter->More(); anIter->Next() )
{
SALOMEDS::SObject_wrap so = anIter->Value();
if ( so->ReferencedObject( oldSO.inout() ))
{
oldEntry = oldSO->GetID();
newEntry = newSO->GetID();
myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ),
std::string( newEntry.in() )));
}
}
}
}
//================================================================================
/*!
* \brief Find a new sub-shape corresponding to an old one
*/
GEOM::GEOM_Object_ptr FindNew( GEOM::GEOM_Object_ptr oldShape )
{
if ( myIsSameGeom )
return GEOM::GEOM_Object::_duplicate( oldShape );
GEOM::GEOM_Object_var newShape;
if ( CORBA::is_nil( oldShape ))
return newShape._retn();
if ( !isChildOfOld( oldShape ))
return GEOM::GEOM_Object::_duplicate( oldShape ); // shape independent of the old shape
GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine();
// try to find by entry
if ( myToPublish )
{
CORBA::String_var oldEntry = oldShape->GetStudyEntry();
TStr2StrMap::iterator o2nID = myOld2NewEntryMap.find( oldEntry.in() );
if ( o2nID != myOld2NewEntryMap.end() )
{
newShape = getShapeByEntry( o2nID->second );
}
}
if ( newShape->_is_nil() )
{
// try to construct a new sub-shape using myGIPMap
buildGIPMap();
std::vector< int > newIndices;
GEOM::ListOfLong_var oldIndices = oldShape->GetSubShapeIndices();
for ( CORBA::ULong i = 0; i < oldIndices->length(); ++i )
{
findNewIDs( oldIndices[i], newIndices );
}
if ( !newIndices.empty() )
{
try
{
if ( newIndices.size() > 1 || oldShape->GetType() == GEOM_GROUP )
{
int groupType = getShapeType( myNewMesh_i, newIndices[0] );
GEOM::GEOM_IGroupOperations_wrap grOp = geomGen->GetIGroupOperations();
newShape = grOp->CreateGroup( mainShapeNew, groupType );
GEOM::ListOfLong_var newIndicesList = new GEOM::ListOfLong();
newIndicesList->length( newIndices.size() );
for ( size_t i = 0; i < newIndices.size(); ++i )
newIndicesList[ i ] = newIndices[ i ];
grOp->UnionIDs( newShape, newIndicesList );
}
else
{
GEOM::GEOM_IShapesOperations_wrap shOp = geomGen->GetIShapesOperations();
newShape = shOp->GetSubShape( mainShapeNew, newIndices[0] );
}
}
catch (...)
{
}
}
}
if ( !newShape->_is_nil() && myToPublish )
{
CORBA::String_var oldEntry, newEntry = newShape->GetStudyEntry();
if ( !newEntry.in() || !newEntry.in()[0] )
{
CORBA::String_var name = oldShape->GetName();
SALOMEDS::SObject_wrap so = geomGen->AddInStudy( newShape, name, mainShapeNew );
newEntry = newShape->GetStudyEntry();
oldEntry = oldShape->GetStudyEntry();
myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ),
std::string( newEntry.in() )));
}
}
return newShape._retn();
}
//================================================================================
/*!
* \brief Return a study entry of a new shape by study entry of the old one
*/
std::string FindNew( const std::string & oldEntry )
{
if ( myIsSameGeom )
return oldEntry;
TStr2StrMap::iterator o2nID = myOld2NewEntryMap.find( oldEntry );
if ( o2nID != myOld2NewEntryMap.end() )
return o2nID->second;
GEOM::GEOM_Object_var oldShape = getShapeByEntry( oldEntry );
if ( oldShape->_is_nil() || !isChildOfOld( oldShape ))
return oldEntry;
GEOM::GEOM_Object_ptr newShape = FindNew( oldShape );
if ( newShape->_is_nil() )
return std::string();
CORBA::String_var newEntry = newShape->GetStudyEntry();
return newEntry.in();
}
//================================================================================
/*!
* \brief Return a sub-shape ID of a new shape by a sub-shape ID of the old one.
* Return zero if not found or there are more than one new ID
*/
int FindNew( int oldID )
{
if ( myIsSameGeom )
return oldID;
buildGIPMap();
int newID = 0;
if ( 0 < oldID && oldID < (int)myGIPMap->length() )
{
if ( myGIPMap[ oldID ].length() == 1 )
newID = myGIPMap[ oldID ][ 0 ];
}
return newID;
}
//================================================================================
/*!
* \brief Return a sub-shape ID of a new shape by an old sub-mesh.
* Return zero if the old shape is not kept as is in the new shape.
*/
int FindNewNotChanged( SMESH_subMesh* oldSM )
{
if ( myIsSameGeom )
return oldSM->GetId();
int newID = FindNew( oldSM->GetId() );
if ( !newID )
return 0;
SMESH_subMesh* newSM = myNewMesh_i->GetImpl().GetSubMeshContaining( newID );
if ( !newSM )
return 0;
// consider a sub-shape as not changed if all its sub-shapes are mapped into
// one new sub-shape of the same type.
if ( oldSM->DependsOn().size() !=
newSM->DependsOn().size() )
return 0;
SMESH_subMeshIteratorPtr srcSMIt = oldSM->getDependsOnIterator( /*includeSelf=*/true );
while ( srcSMIt->more() )
{
oldSM = srcSMIt->next();
int newSubID = FindNew( oldSM->GetId() );
if ( getShapeType( myNewMesh_i, newSubID ) !=
getShapeType( mySrcMesh_i, oldSM->GetId() ))
return 0;
}
return newID;
}
//================================================================================
/*!
* \brief Return shape by study entry
*/
GEOM::GEOM_Object_ptr getShapeByEntry( const std::string & entry )
{
GEOM::GEOM_Object_var shape;
SALOMEDS::SObject_wrap so = myGen_i->getStudyServant()->FindObjectID( entry.c_str() );
if ( !so->_is_nil() )
{
CORBA::Object_var obj = so->GetObject();
shape = GEOM::GEOM_Object::_narrow( obj );
}
return shape._retn();
}
//================================================================================
/*!
* \brief Fill myGIPMap by calling GetInPlaceMap()
*/
void buildGIPMap()
{
if ( !myGIPMapDone )
{
myGIPMapDone = true;
GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
GEOM::GEOM_Object_var mainShapeOld = mySrcMesh_i->GetShapeToMesh();
GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine();
GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
try
{
myGIPMap = op->GetInPlaceMap( mainShapeNew, mainShapeOld );
}
catch( ... )
{
myGIPMap = new GEOM::ListOfListOfLong();
}
}
}
//================================================================================
/*!
* \brief Find a new sub-shape indices by an old one in myGIPMap. Return
* number of found IDs
*/
int findNewIDs( int oldID, std::vector< int >& newIDs )
{
size_t prevNbIDs = newIDs.size();
if ( 0 < oldID && oldID < (int) myGIPMap->length() )
{
for ( CORBA::ULong i = 0; i < myGIPMap[ oldID ].length(); ++i )
newIDs.push_back( myGIPMap[ oldID ][ i ]);
}
return newIDs.size() - prevNbIDs;
}
//================================================================================
/*!
* \brief Check if an object relates to the old shape
*/
bool isChildOfOld( GEOM::GEOM_Object_ptr oldShape )
{
if ( CORBA::is_nil( oldShape ))
return false;
GEOM::GEOM_Object_var mainShapeOld1 = mySrcMesh_i->GetShapeToMesh();
GEOM::GEOM_Object_var mainShapeOld2 = oldShape->GetMainShape();
return ( mainShapeOld1->_is_equivalent( mainShapeOld2 ) ||
mainShapeOld1->_is_equivalent( oldShape ));
}
//================================================================================
/*!
* \brief Return shape type by shape ID
*/
TopAbs_ShapeEnum getShapeType( SMESH_Mesh_i* mesh_i, int shapeID )
{
SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS();
const TopoDS_Shape& shape = meshDS->IndexToShape( shapeID );
return shape.IsNull() ? TopAbs_SHAPE : shape.ShapeType();
}
//================================================================================
/*!
* \brief Store a source sub-shape for which a counterpart not found and
* a smesh object invalid due to that
*/
void AddInvalid( GEOM::GEOM_Object_var srcShape,
SALOMEDS::SObject_wrap smeshSO )
{
CORBA::String_var geomEntry = srcShape->GetStudyEntry();
if ( geomEntry.in()[0] && !smeshSO->_is_nil() )
{
CORBA::String_var smeshEntry = smeshSO->GetID();
myInvalidMap[ geomEntry.in() ].insert( smeshEntry.in() );
}
}
//================================================================================
/*!
* \brief Store a source sub-shape for which a counterpart not found and
* a smesh object invalid due to that
*/
void AddInvalid( std::string geomEntry,
SALOMEDS::SObject_wrap smeshSO )
{
if ( !geomEntry.empty() )
{
CORBA::String_var smeshEntry = smeshSO->GetID();
myInvalidMap[ geomEntry ].insert( smeshEntry.in() );
}
}
//================================================================================
/*!
* \brief Store a source sub-shape for which a counterpart not found and
* a smesh object invalid due to that
*/
void AddInvalid( int oldGeomID,
SALOMEDS::SObject_wrap smeshSO )
{
int shapeType = getShapeType( mySrcMesh_i, oldGeomID );
if ( shapeType < 0 || shapeType > TopAbs_SHAPE )
return;
const char* typeName[] = { "COMPOUND","COMPSOLID","SOLID","SHELL",
"FACE","WIRE","EDGE","VERTEX","SHAPE" };
SMESH_Comment geomName( typeName[ shapeType ]);
geomName << " #" << oldGeomID;
CORBA::String_var smeshEntry = smeshSO->GetID();
myInvalidMap[ geomName ].insert( smeshEntry.in() );
}
//================================================================================
/*!
* \brief Return entries of a source sub-shape for which a counterpart not found and
* of smesh objects invalid due to that
*/
void GetInvalid( SMESH::string_array_out & theInvalidEntries,
std::vector< SALOMEDS::SObject_wrap > & theInvalidMeshSObjects)
{
int nbSO = 0;
TStr2StrSetMap::iterator entry2entrySet = myInvalidMap.begin();
for ( ; entry2entrySet != myInvalidMap.end(); ++entry2entrySet )
{
nbSO += 1 + entry2entrySet->second.size();
}
int iSO = theInvalidMeshSObjects.size(), iEntry = 0;
theInvalidEntries->length ( nbSO );
theInvalidMeshSObjects.resize( theInvalidMeshSObjects.size() + nbSO - myInvalidMap.size() );
entry2entrySet = myInvalidMap.begin();
for ( ; entry2entrySet != myInvalidMap.end(); ++entry2entrySet )
{
theInvalidEntries[ iEntry++ ] = entry2entrySet->first.c_str();
std::set< std::string > & entrySet = entry2entrySet->second;
std::set< std::string >::iterator entry = entrySet.begin();
for ( ; entry != entrySet.end(); ++entry )
{
theInvalidEntries[ iEntry++ ] = entry->c_str();
SALOMEDS::SObject_wrap so = myGen_i->getStudyServant()->FindObjectID( entry->c_str() );
if ( !so->_is_nil() )
theInvalidMeshSObjects[ iSO++ ] = so;
}
}
}
}; // struct ShapeMapper
//================================================================================
/*!
* \brief Append an item to a CORBA sequence
*/
template < class CORBA_seq, class ITEM >
void append( CORBA_seq& seq, ITEM item )
{
if ( !CORBA::is_nil( item ))
{
seq->length( 1 + seq->length() );
seq[ seq->length() - 1 ] = item;
}
}
}
//================================================================================
/*!
* \brief Create a mesh by copying definitions of another mesh to a given geometry
* \param [in] sourceMesh - a mesh to copy
* \param [in] newGeometry - a new geometry
* \param [in] toCopyGroups - to create groups in the new mesh
* \param [in] toReuseHypotheses - if True, existing hypothesis will be used by the new mesh,
* otherwise new hypotheses with the same parameters will be created for the new mesh.
* \param [in] toCopyElements - to copy mesh elements of same sub-shapes of the two geometries
* \param [out] newMesh - return a new mesh
* \param [out] newGroups - return new groups
* \param [out] newSubmeshes - return new sub-meshes
* \param [out] newHypotheses - return new algorithms and hypotheses
* \param [out] invalidEntries - return study entries of objects whose
* counterparts are not found in the newGeometry, followed by entries
* of mesh sub-objects that are invalid because they depend on a not found
* preceeding sub-shape
* \return CORBA::Boolean - is a success
*/
//================================================================================
CORBA::Boolean SMESH_Gen_i::CopyMeshWithGeom( SMESH::SMESH_Mesh_ptr theSourceMesh,
GEOM::GEOM_Object_ptr theNewGeometry,
const char* theMeshName,
CORBA::Boolean theToCopyGroups,
CORBA::Boolean theToReuseHypotheses,
CORBA::Boolean theToCopyElements,
SMESH::SMESH_Mesh_out theNewMesh,
SMESH::ListOfGroups_out theNewGroups,
SMESH::submesh_array_out theNewSubmeshes,
SMESH::ListOfHypothesis_out theNewHypotheses,
SMESH::string_array_out theInvalidEntries)
throw ( SALOME::SALOME_Exception )
{
if ( CORBA::is_nil( theSourceMesh ) ||
CORBA::is_nil( theNewGeometry ))
THROW_SALOME_CORBA_EXCEPTION( "NULL arguments", SALOME::BAD_PARAM );
if ( !theSourceMesh->HasShapeToMesh() )
THROW_SALOME_CORBA_EXCEPTION( "Source mesh not on geometry", SALOME::BAD_PARAM );
bool ok = true;
SMESH_TRY;
TPythonDump pyDump; // prevent dump from CreateMesh()
theNewMesh = CreateMesh( theNewGeometry );
theNewGroups = new SMESH::ListOfGroups();
theNewSubmeshes = new SMESH::submesh_array();
theNewHypotheses = new SMESH::ListOfHypothesis();
theInvalidEntries = new SMESH::string_array();
std::vector< SALOMEDS::SObject_wrap > invalidSObjects;
GEOM::GEOM_Object_var srcGeom = theSourceMesh->GetShapeToMesh();
GEOM::GEOM_Object_var geom, newGeom;
SALOMEDS::SObject_wrap so;
SMESH_Mesh_i* srcMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSourceMesh );
SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theNewMesh );
ShapeMapper shapeMapper( srcMesh_i, newMesh_i, this );
// treat hypotheses of mesh and sub-meshes
SMESH::submesh_array_var smList = theSourceMesh->GetSubMeshes();
for ( CORBA::ULong iSM = 0; iSM <= smList->length(); ++iSM )
{
bool isSubMesh = ( iSM < smList->length() );
if ( isSubMesh )
{
// create a new sub-mesh
SMESH::SMESH_subMesh_var newSM;
geom = smList[iSM]->GetSubShape();
so = ObjectToSObject( smList[iSM] );
CORBA::String_var name;
if ( !so->_is_nil() )
name = so->GetName();
newGeom = shapeMapper.FindNew( geom );
if ( newGeom->_is_nil() )
{
newSM = createInvalidSubMesh( theNewMesh, geom, name.in() );
shapeMapper.AddInvalid( geom, ObjectToSObject( newSM ));
ok = false;
}
else
{
newSM = theNewMesh->GetSubMesh( newGeom, name.in() );
}
append( theNewSubmeshes, newSM );
if ( newGeom->_is_nil() )
continue; // don't assign hypotheses
}
else
{
newGeom = GEOM::GEOM_Object::_duplicate( theNewGeometry );
geom = srcGeom;
so = ObjectToSObject( theNewMesh );
SetName( so, theMeshName, "Mesh" );
}
// assign hypotheses
SMESH::ListOfHypothesis_var hypList = theSourceMesh->GetHypothesisList( geom );
for ( CORBA::ULong iHyp = 0; iHyp < hypList->length(); ++iHyp )
{
SMESH::SMESH_Hypothesis_var hyp = hypList[ iHyp ];
SMESH_Hypothesis_i* hyp_i = SMESH::DownCast< SMESH_Hypothesis_i* >( hyp );
// get geometry hyp depends on
std::vector< std::string > entryArray;
std::vector< int > subIDArray;
bool dependsOnGeom = hyp_i->getObjectsDependOn( entryArray, subIDArray );
if ( !theToReuseHypotheses || dependsOnGeom )
{
// create a new hypothesis
CORBA::String_var type = hyp->GetName();
CORBA::String_var lib = hyp->GetLibName();
CORBA::String_var data = hyp_i->SaveTo();
if ( data.in()[0] )
{
hyp = CreateHypothesis( type, lib );
hyp_i = SMESH::DownCast< SMESH_Hypothesis_i* >( hyp );
hyp_i->LoadFrom( data.in() );
append( theNewHypotheses, hyp );
}
}
// update geometry hyp depends on
if ( dependsOnGeom )
{
for ( size_t iGeo = 0; iGeo < entryArray.size(); ++iGeo )
{
if ( !entryArray[ iGeo ].empty() )
{
std::string newEntry = shapeMapper.FindNew( entryArray[ iGeo ]);
if ( newEntry.empty() )
{
ok = false;
shapeMapper.AddInvalid( entryArray[ iGeo ], ObjectToSObject( hyp ));
shapeMapper.AddInvalid( entryArray[ iGeo ], so ); // sub-mesh
}
entryArray[ iGeo ] = newEntry;
}
}
for ( size_t iGeo = 0; iGeo < subIDArray.size(); ++iGeo )
{
if ( subIDArray[ iGeo ] > 0 )
{
int newID = shapeMapper.FindNew( subIDArray[ iGeo ]);
if ( newID < 1 )
{
ok = false;
shapeMapper.AddInvalid( subIDArray[ iGeo ], ObjectToSObject( hyp ));
shapeMapper.AddInvalid( subIDArray[ iGeo ], so ); // sub-mesh
}
subIDArray[ iGeo ] = newID;
}
}
if ( !hyp_i->setObjectsDependOn( entryArray, subIDArray ))
ok = false;
}
CORBA::String_var errorText;
theNewMesh->AddHypothesis( newGeom, hyp, errorText.out() );
if ( errorText.in()[0] )
ok = false;
} // loop on hypotheses
} // loop on sub-meshes and mesh
// copy mesh elements, keeping IDs
if ( theToCopyElements && theSourceMesh->NbNodes() > 0 )
{
SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS();
::SMESH_MeshEditor editor( &newMesh_i->GetImpl() );
::SMESH_MeshEditor::ElemFeatures elemData;
SMESH_subMesh* srcMainSM = srcMesh_i->GetImpl().GetSubMeshContaining( 1 );
SMESH_subMeshIteratorPtr srcSMIt = srcMainSM->getDependsOnIterator( /*includeSelf=*/true,
/*vertexLast=*/false);
while ( srcSMIt->more() )
{
SMESH_subMesh* srcSM = srcSMIt->next();
if ( srcSM->IsEmpty() )
continue; // not yet computed
int newID = shapeMapper.FindNewNotChanged( srcSM );
if ( newID < 1 )
continue;
SMESHDS_SubMesh* srcSMDS = srcSM->GetSubMeshDS();
SMDS_NodeIteratorPtr nIt = srcSMDS->GetNodes();
while ( nIt->more() )
{
SMESH_NodeXYZ node( nIt->next() );
const SMDS_MeshNode* newNode = newMeshDS->AddNodeWithID( node.X(), node.Y(), node.Z(),
node->GetID() );
const SMDS_PositionPtr pos = node->GetPosition();
const double* uv = pos->GetParameters();
switch ( pos->GetTypeOfPosition() )
{
case SMDS_TOP_3DSPACE: newMeshDS->SetNodeInVolume( newNode, newID ); break;
case SMDS_TOP_FACE: newMeshDS->SetNodeOnFace ( newNode, newID, uv[0], uv[1] ); break;
case SMDS_TOP_EDGE: newMeshDS->SetNodeOnEdge ( newNode, newID, uv[0] ); break;
case SMDS_TOP_VERTEX: newMeshDS->SetNodeOnVertex( newNode, newID ); break;
default: ;
}
}
SMDS_ElemIteratorPtr eIt = srcSMDS->GetElements();
while( eIt->more() )
{
const SMDS_MeshElement* e = eIt->next();
elemData.Init( e, /*basicOnly=*/false );
elemData.SetID( e->GetID() );
elemData.myNodes.resize( e->NbNodes() );
SMDS_NodeIteratorPtr nnIt = e->nodeIterator();
size_t iN;
for ( iN = 0; nnIt->more(); ++iN )
{
const SMDS_MeshNode* srcNode = nnIt->next();
elemData.myNodes[ iN ] = newMeshDS->FindNode( srcNode->GetID() );
if ( !elemData.myNodes[ iN ])
break;
}
if ( iN == elemData.myNodes.size() )
if ( const SMDS_MeshElement * newElem = editor.AddElement( elemData.myNodes, elemData ))
newMeshDS->SetMeshElementOnShape( newElem, newID );
}
if ( SMESH_subMesh* newSM = newMesh_i->GetImpl().GetSubMeshContaining( newID ))
newSM->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
}
}
// treat groups
TStr2StrMap old2newGroupMap;
SALOME::GenericObj_wrap< SMESH::FilterManager > filterMgr = CreateFilterManager();
SMESH::ListOfGroups_var groups = theSourceMesh->GetGroups();
CORBA::ULong nbGroups = groups->length(), nbAddedGroups = 0;
for ( CORBA::ULong i = 0; i < nbGroups + nbAddedGroups; ++i )
{
SMESH::SMESH_Group_var stdlGroup = SMESH::SMESH_Group::_narrow ( groups[ i ]);
SMESH::SMESH_GroupOnGeom_var geomGroup = SMESH::SMESH_GroupOnGeom::_narrow ( groups[ i ]);
SMESH::SMESH_GroupOnFilter_var fltrGroup = SMESH::SMESH_GroupOnFilter::_narrow( groups[ i ]);
CORBA::String_var name = groups[ i ]->GetName();
SMESH::ElementType elemType = groups[ i ]->GetType();
SMESH::SMESH_GroupBase_var newGroup;
if ( !stdlGroup->_is_nil() )
{
if ( theToCopyElements )
{
SMESH::long_array_var elemIDs = stdlGroup->GetIDs();
stdlGroup = theNewMesh->CreateGroup( elemType, name );
stdlGroup->Add( elemIDs );
newGroup = SMESH::SMESH_GroupBase::_narrow( stdlGroup );
}
}
else if ( !geomGroup->_is_nil() )
{
GEOM::GEOM_Object_var geom = geomGroup->GetShape();
GEOM::GEOM_Object_var newGeom = shapeMapper.FindNew( geom );
if ( newGeom->_is_nil() )
{
newGroup = theNewMesh->CreateGroup( elemType, name ); // just to notify the user
shapeMapper.AddInvalid( geom, ObjectToSObject( newGroup ));
ok = false;
}
else
{
newGroup = theNewMesh->CreateGroupFromGEOM( elemType, name, newGeom );
}
}
else if ( !fltrGroup->_is_nil() )
{
// replace geometry in a filter
SMESH::Filter_var filter = fltrGroup->GetFilter();
SMESH::Filter::Criteria_var criteria;
filter->GetCriteria( criteria.out() );
bool isMissingGroup = false;
std::vector< std::string > badEntries;
for ( CORBA::ULong iCr = 0; iCr < criteria->length(); ++iCr )
{
const char* thresholdID = criteria[ iCr ].ThresholdID.in();
switch ( criteria[ iCr ].Type )
{
case SMESH::FT_BelongToMeshGroup:
{
SALOME::GenericObj_wrap< SMESH::BelongToMeshGroup > btgg = filterMgr->CreateBelongToMeshGroup();
btgg->SetGroupID( thresholdID );
SMESH::SMESH_GroupBase_ptr refGroup = btgg->GetGroup();
SALOMEDS::SObject_wrap refGroupSO = ObjectToSObject( refGroup );
if ( refGroupSO->_is_nil() )
break;
CORBA::String_var refID = refGroupSO->GetID();
TStr2StrMap::iterator o2nID = old2newGroupMap.find( refID.in() );
if ( o2nID == old2newGroupMap.end() )
{
isMissingGroup = true; // corresponding new group not yet created
break;
}
criteria[ iCr ].ThresholdID = o2nID->second.c_str();
if ( o2nID->second.empty() ) // new referred group is invalid
badEntries.push_back( refID.in() );
break;
}
case SMESH::FT_BelongToGeom:
case SMESH::FT_BelongToPlane:
case SMESH::FT_BelongToCylinder:
case SMESH::FT_BelongToGenSurface:
case SMESH::FT_LyingOnGeom:
{
std::string newID = shapeMapper.FindNew( thresholdID );
criteria[ iCr ].ThresholdID = newID.c_str();
if ( newID.empty() )
badEntries.push_back( thresholdID );
break;
}
case SMESH::FT_ConnectedElements:
{
if ( thresholdID && thresholdID[0] )
{
std::string newID = shapeMapper.FindNew( thresholdID );
criteria[ iCr ].ThresholdID = newID.c_str();
if ( newID.empty() )
badEntries.push_back( thresholdID );
}
break;
}
default:;
}
} // loop on criteria
if ( isMissingGroup && i < nbGroups )
{
// to treat the group again
append( groups, SMESH::SMESH_GroupBase::_duplicate( groups[ i ]));
++nbAddedGroups;
continue;
}
SMESH::Filter_var newFilter = filterMgr->CreateFilter();
newFilter->SetCriteria( criteria );
newGroup = theNewMesh->CreateGroupFromFilter( elemType, name, newFilter );
newFilter->UnRegister();
SALOMEDS::SObject_wrap newSO = ObjectToSObject( newGroup );
for ( size_t iEnt = 0; iEnt < badEntries.size(); ++iEnt )
shapeMapper.AddInvalid( badEntries[ iEnt ], newSO );
if ( isMissingGroup ) // all groups treated but a referred groups still not found
{
invalidSObjects.push_back( ObjectToSObject( newGroup ));
ok = false;
}
if ( !badEntries.empty() )
ok = false;
} // treat a group on filter
append( theNewGroups, newGroup );
// fill old2newGroupMap
SALOMEDS::SObject_wrap srcSO = ObjectToSObject( groups[i] );
SALOMEDS::SObject_wrap newSO = ObjectToSObject( newGroup );
if ( !srcSO->_is_nil() )
{
CORBA::String_var srcID, newID;
srcID = srcSO->GetID();
if ( !newSO->_is_nil() )
newID = newSO->GetID();
old2newGroupMap.insert( std::make_pair( std::string( srcID.in() ),
std::string( newID.in() )));
}
if ( newGroup->_is_nil() )
ok = false;
} // loop on groups
// set mesh name
SALOMEDS::SObject_wrap soNew = ObjectToSObject( theNewMesh );
SALOMEDS::SObject_wrap soOld = ObjectToSObject( theSourceMesh );
CORBA::String_var oldName = soOld->GetName();
SetName( soNew, oldName.in(), "Mesh" );
// mark invalid objects
shapeMapper.GetInvalid( theInvalidEntries, invalidSObjects );
for ( size_t i = 0; i < invalidSObjects.size(); ++i )
highLightInvalid( invalidSObjects[i].in(), true );
pyDump << "ok, "
<< theNewMesh << ", "
<< theNewGroups << ", "
<< *theNewSubmeshes.ptr() << ", "
<< *theNewHypotheses.ptr() << ", "
<< "invalidEntries = " << this << ".CopyMeshWithGeom( "
<< theSourceMesh << ", "
<< theNewGeometry << ", "
<< "'" << theMeshName << "', "
<< theToCopyGroups << ", "
<< theToReuseHypotheses << ", "
<< theToCopyElements << " )";
SMESH_CATCH( SMESH::throwCorbaException );
return ok;
}
//================================================================================ //================================================================================
/*! /*!
* \brief Get version of MED format being used. * \brief Get version of MED format being used.

View File

@ -246,9 +246,24 @@ public:
SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart, SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
const char* meshName, const char* meshName,
CORBA::Boolean toCopyGroups, CORBA::Boolean toCopyGroups,
CORBA::Boolean toKeepIDs); CORBA::Boolean toKeepIDs)
throw ( SALOME::SALOME_Exception );
// Compute mesh on a shape // Create a mesh by copying definitions of another mesh to a given geometry
CORBA::Boolean CopyMeshWithGeom( SMESH::SMESH_Mesh_ptr sourceMesh,
GEOM::GEOM_Object_ptr newGeometry,
const char* meshName,
CORBA::Boolean toCopyGroups,
CORBA::Boolean toReuseHypotheses,
CORBA::Boolean toCopyElements,
SMESH::SMESH_Mesh_out newMesh,
SMESH::ListOfGroups_out newGroups,
SMESH::submesh_array_out newSubmeshes,
SMESH::ListOfHypothesis_out newHypotheses,
SMESH::string_array_out invalidEntries)
throw ( SALOME::SALOME_Exception );
// Compute mesh on a shape
CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh, CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject ) GEOM::GEOM_Object_ptr theShapeObject )
throw ( SALOME::SALOME_Exception ); throw ( SALOME::SALOME_Exception );
@ -504,6 +519,7 @@ public:
GEOM::GEOM_Object_ptr theShapeObject, GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0); const char* theName = 0);
void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh); void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid);
bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh, bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject, GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp); SMESH::SMESH_Hypothesis_ptr theHyp);
@ -608,6 +624,14 @@ private:
SMESH::SMESH_Mesh_ptr createMesh() SMESH::SMESH_Mesh_ptr createMesh()
throw ( SALOME::SALOME_Exception ); throw ( SALOME::SALOME_Exception );
// Create a sub-mesh on a geometry that is not a sub-shape of the main shape
// for the case where a valid sub-shape not found by CopyMeshWithGeom()
SMESH::SMESH_subMesh_ptr createInvalidSubMesh( SMESH::SMESH_Mesh_ptr mesh,
GEOM::GEOM_Object_ptr strangerGeom,
const char* name );
void highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInvalid );
static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot ); static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName, SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,

View File

@ -452,6 +452,9 @@ static void addReference (SALOMEDS::SObject_ptr theSObject,
aStudyBuilder->Addreference( aReferenceSO, aToObjSO ); aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
// make the reference visible (invisible ref is created by createInvalidSubMesh())
aStudyBuilder->RemoveAttribute( aReferenceSO, "AttributeDrawable" );
// add reference to the use case tree // add reference to the use case tree
// (to support tree representation customization and drag-n-drop) // (to support tree representation customization and drag-n-drop)
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder(); SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
@ -689,6 +692,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr theM
if ( theMesh->_is_nil() || theSubMesh->_is_nil() || theShapeObject->_is_nil() ) if ( theMesh->_is_nil() || theSubMesh->_is_nil() || theShapeObject->_is_nil() )
return SALOMEDS::SObject::_nil(); return SALOMEDS::SObject::_nil();
std::string newName( theName ? theName : "" );
SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theSubMesh ); SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theSubMesh );
if ( aSubMeshSO->_is_nil() ) if ( aSubMeshSO->_is_nil() )
{ {
@ -740,15 +745,37 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr theM
SetName( aRootSO, aRootName ); SetName( aRootSO, aRootName );
// Add new submesh to corresponding sub-tree // Add new sub-mesh to corresponding sub-tree
int tag = 0; // to use a new SObject
if ( theName && theName[0] == '0' )
{
// theName can be an entry of an invalid sub-mesh which theSubMesh should replace
SALOMEDS::SObject_wrap aSObj = getStudyServant()->FindObjectID( theName );
if ( aSObj )
{
CORBA::String_var oldName = aSObj->GetName();
newName = oldName.in();
SALOMEDS::SObject_wrap aRootSO2 = aSObj->GetFather();
if ( aRootSO->Tag() == aRootSO2->Tag() ) // same parent
tag = aSObj->Tag(); // to use the same SObject
else
{
CORBA::Object_var anObj = SObjectToObject( aSObj );
SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( anObj );
theMesh->RemoveSubMesh( sm );
}
}
}
SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes(); SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes();
const int isEmpty = ( elemTypes->length() == 0 ); const int isEmpty = ( elemTypes->length() == 0 );
const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" }; const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" };
aSubMeshSO = publish ( theSubMesh, aRootSO, 0, pm[isEmpty] ); aSubMeshSO = publish ( theSubMesh, aRootSO, tag, pm[isEmpty] );
if ( aSubMeshSO->_is_nil() ) if ( aSubMeshSO->_is_nil() )
return aSubMeshSO._retn(); return aSubMeshSO._retn();
highLightInvalid( aSubMeshSO, false ); // now it is valid
} }
SetName( aSubMeshSO, theName, "SubMesh" ); SetName( aSubMeshSO, newName.c_str(), "SubMesh" );
// Add reference to theShapeObject // Add reference to theShapeObject
@ -757,7 +784,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr theM
// Publish hypothesis // Publish hypothesis
SMESH::ListOfHypothesis_var hypList = theMesh->GetHypothesisList( theShapeObject ); SMESH::ListOfHypothesis_var hypList = theMesh->GetHypothesisList( theShapeObject );
for ( CORBA::ULong i = 0; i < hypList->length(); i++ ) { for ( CORBA::ULong i = 0; i < hypList->length(); i++ )
{
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]); SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]);
SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp ); SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp );
AddHypothesisToShape( theMesh, theShapeObject, aHyp ); AddHypothesisToShape( theMesh, theShapeObject, aHyp );
@ -965,6 +993,42 @@ void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh )
} }
} }
//=======================================================================
//function : HighLightInvalid
//purpose : change font color of a object in the Object Browser
//=======================================================================
void SMESH_Gen_i::HighLightInvalid( CORBA::Object_ptr theObject, bool isInvalid )
{
SALOMEDS::SObject_wrap so = ObjectToSObject(theObject);
highLightInvalid( so.in(), isInvalid );
}
//=======================================================================
//function : highLightInvalid
//purpose : change font color of a object in the Object Browser
//=======================================================================
void SMESH_Gen_i::highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInvalid )
{
if ( !theSObject->_is_nil() )
{
SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
if ( isInvalid )
{
SALOMEDS::Color red = { 178,34,34 }; // to differ from reference color
SALOMEDS::GenericAttribute_wrap attr =
studyBuilder->FindOrCreateAttribute( theSObject, "AttributeTextColor" );
SALOMEDS::AttributeTextColor_wrap colorAttr = attr;
colorAttr->SetTextColor( red );
}
else
{
studyBuilder->RemoveAttribute( theSObject, "AttributeTextColor" );
}
}
}
//======================================================================= //=======================================================================
//function : GetMeshOrSubmeshByShape //function : GetMeshOrSubmeshByShape
//purpose : //purpose :
@ -1339,6 +1403,50 @@ char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject)
return aResult._retn(); return aResult._retn();
} }
//================================================================================
/*!
* \brief Create a sub-mesh on a geometry that is not a sub-shape of the main shape
* for the case where a valid sub-shape not found by CopyMeshWithGeom().
* The invalid sub-mesh has GetId() < 0.
*/
//================================================================================
SMESH::SMESH_subMesh_ptr
SMESH_Gen_i::createInvalidSubMesh(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theStrangerGeom,
const char* theName)
{
SMESH::SMESH_subMesh_var subMesh;
try
{
SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
subMesh = mesh_i->createSubMesh( theStrangerGeom );
if ( !subMesh->_is_nil() && CanPublishInStudy( subMesh ))
{
SALOMEDS::SObject_wrap so = PublishSubMesh( theMesh, subMesh, theStrangerGeom, theName );
// hide a reference to geometry
if ( !so->_is_nil() )
{
SALOMEDS::SObject_wrap refSO;
if ( so->FindSubObject( GetRefOnShapeTag(), refSO.inout() ))
{
SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
SALOMEDS::GenericAttribute_wrap attr =
studyBuilder->FindOrCreateAttribute( refSO, "AttributeDrawable" );
SALOMEDS::AttributeDrawable_wrap ga = attr;
ga->SetDrawable( false );
}
}
}
}
catch (...) {
}
return subMesh._retn();
}
// ============== // ==============

View File

@ -838,7 +838,13 @@ void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter)
Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
} }
TPythonDump()<< SMESH::SMESH_GroupOnFilter_var(_this()) <<".SetFilter( "<<theFilter<<" )"; SMESH::SMESH_GroupOnFilter_var me = _this();
// mark the group valid after edition
GetMeshServant()->GetGen()->HighLightInvalid( me, false );
TPythonDump()<< me <<".SetFilter( "<< theFilter <<" )";
} }
//================================================================================ //================================================================================

View File

@ -40,6 +40,7 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector>
class TCollection_AsciiString; class TCollection_AsciiString;
@ -97,7 +98,18 @@ public:
// Persistence // Persistence
virtual char* SaveTo(); virtual char* SaveTo();
virtual void LoadFrom( const char* theStream ); virtual void LoadFrom( const char* theStream );
virtual void UpdateAsMeshesRestored(); // for hyps needing full data restored virtual void UpdateAsMeshesRestored(); // for hyps needing full study data restored
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const = 0;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) = 0;
protected: protected:

View File

@ -2460,9 +2460,25 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theS
if(MYDEBUG) MESSAGE( "createSubMesh" ); if(MYDEBUG) MESSAGE( "createSubMesh" );
TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject); TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject);
::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape); ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
const int subMeshId = mySubMesh->GetId(); int subMeshId = 0;
SMESH_subMesh_i * subMeshServant;
if ( mySubMesh )
{
subMeshId = mySubMesh->GetId();
subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId);
}
else // "invalid sub-mesh"
{
// The invalid sub-mesh is created for the case where a valid sub-shape not found
// by SMESH_Gen_i::CopyMeshWithGeom(). The invalid sub-mesh has GetId() < 0.
if ( _mapSubMesh.empty() )
subMeshId = -1;
else
subMeshId = _mapSubMesh.begin()->first - 1;
subMeshServant = new SMESH_Invalid_subMesh_i(myPOA, _gen_i, this, subMeshId, theSubShapeObject);
}
SMESH_subMesh_i * subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId);
SMESH::SMESH_subMesh_var subMesh = subMeshServant->_this(); SMESH::SMESH_subMesh_var subMesh = subMeshServant->_this();
_mapSubMesh [subMeshId] = mySubMesh; _mapSubMesh [subMeshId] = mySubMesh;
@ -2477,7 +2493,8 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theS
else { nextId = 0; } // avoid "unused variable" warning else { nextId = 0; } // avoid "unused variable" warning
// to track changes of GEOM groups // to track changes of GEOM groups
addGeomGroupData( theSubShapeObject, subMesh ); if ( subMeshId > 0 )
addGeomGroupData( theSubShapeObject, subMesh );
return subMesh._retn(); return subMesh._retn();
} }
@ -2513,7 +2530,8 @@ bool SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh,
if ( theSubShapeObject->_is_nil() ) // not published shape (IPAL13617) if ( theSubShapeObject->_is_nil() ) // not published shape (IPAL13617)
{ {
if ( _mapSubMesh.find( subMeshId ) != _mapSubMesh.end()) if ( _mapSubMesh.find( subMeshId ) != _mapSubMesh.end() &&
_mapSubMesh[ subMeshId ])
{ {
TopoDS_Shape S = _mapSubMesh[ subMeshId ]->GetSubShape(); TopoDS_Shape S = _mapSubMesh[ subMeshId ]->GetSubShape();
if ( !S.IsNull() ) if ( !S.IsNull() )
@ -2735,7 +2753,7 @@ namespace
SMESH_Mesh_i* _mesh; SMESH_Mesh_i* _mesh;
TCallUp_i(SMESH_Mesh_i* mesh):_mesh(mesh) {} TCallUp_i(SMESH_Mesh_i* mesh):_mesh(mesh) {}
virtual void RemoveGroup (const int theGroupID) { _mesh->removeGroup( theGroupID ); } virtual void RemoveGroup (const int theGroupID) { _mesh->removeGroup( theGroupID ); }
virtual void HypothesisModified () { _mesh->onHypothesisModified(); } virtual void HypothesisModified (int theHypID) { _mesh->onHypothesisModified( theHypID ); }
virtual void Load () { _mesh->Load(); } virtual void Load () { _mesh->Load(); }
}; };
} }
@ -2746,13 +2764,30 @@ namespace
*/ */
//================================================================================ //================================================================================
void SMESH_Mesh_i::onHypothesisModified() void SMESH_Mesh_i::onHypothesisModified(int theHypID)
{ {
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->ForgetOrLoad(); _preMeshInfo->ForgetOrLoad();
SMESH::SMESH_Mesh_var mesh = _this(); SMESH::SMESH_Mesh_var mesh = _this();
_gen_i->UpdateIcons( mesh ); _gen_i->UpdateIcons( mesh );
// mark a hypothesis as valid after edition
SALOMEDS::SComponent_wrap smeshComp = _gen_i->PublishComponent();
SALOMEDS::SObject_wrap hypRoot;
if ( !smeshComp->_is_nil() &&
smeshComp->FindSubObject( _gen_i->GetHypothesisRootTag(), hypRoot.inout() ))
{
SALOMEDS::ChildIterator_wrap anIter = _gen_i->getStudyServant()->NewChildIterator( hypRoot );
for ( ; anIter->More(); anIter->Next() )
{
SALOMEDS::SObject_wrap hypSO = anIter->Value();
CORBA::Object_var obj = _gen_i->SObjectToObject( hypSO );
SMESH::SMESH_Hypothesis_var hyp = SMESH::SMESH_Hypothesis::_narrow( obj );
if ( !hyp->_is_nil() && hyp->GetId() == theHypID )
_gen_i->HighLightInvalid( hyp, false );
}
}
} }
//============================================================================= //=============================================================================

View File

@ -439,7 +439,7 @@ public:
const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; } const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
// return existing group objects // return existing group objects
void onHypothesisModified(); void onHypothesisModified(int theHypID);
// callback from _impl to forget not loaded mesh data (issue 0021208) // callback from _impl to forget not loaded mesh data (issue 0021208)
void checkMeshLoaded(); void checkMeshLoaded();

View File

@ -540,6 +540,16 @@ namespace SMESH
DumpArray( theList, *this ); DumpArray( theList, *this );
return *this; return *this;
} }
TPythonDump& TPythonDump::operator<<(const SMESH::submesh_array& theList)
{
DumpArray( theList, *this );
return *this;
}
TPythonDump& TPythonDump::operator<<(const SMESH::ListOfHypothesis& theList)
{
DumpArray( theList, *this );
return *this;
}
TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB) TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
{ {
// dump CoincidentFreeBorders as a list of lists, each enclosed list // dump CoincidentFreeBorders as a list of lists, each enclosed list

View File

@ -227,6 +227,12 @@ namespace SMESH
TPythonDump& TPythonDump&
operator<<(const SMESH::ListOfIDSources& theList); operator<<(const SMESH::ListOfIDSources& theList);
TPythonDump&
operator<<(const SMESH::submesh_array& theList);
TPythonDump&
operator<<(const SMESH::ListOfHypothesis& theList);
TPythonDump& TPythonDump&
operator<<(const SMESH::CoincidentFreeBorders& theCFB); operator<<(const SMESH::CoincidentFreeBorders& theCFB);

View File

@ -96,6 +96,8 @@ typedef list<SMESHDS_SubMesh*> TListOfSubMeshes;
bool getSubMeshes(::SMESH_subMesh* theSubMesh, bool getSubMeshes(::SMESH_subMesh* theSubMesh,
TListOfSubMeshes& theSubMeshList) TListOfSubMeshes& theSubMeshList)
{ {
if ( !theSubMesh )
return false; // "invalid sub-mesh" created by SMESH_Gen_i::CopyMeshWithGeom()
size_t size = theSubMeshList.size(); size_t size = theSubMeshList.size();
// check all child sub-meshes of one complexity, // check all child sub-meshes of one complexity,
@ -582,3 +584,30 @@ SALOMEDS::TMPFile* SMESH_subMesh_i::GetVtkUgStream()
SALOMEDS::TMPFile_var SeqFile; SALOMEDS::TMPFile_var SeqFile;
return SeqFile._retn(); return SeqFile._retn();
} }
//=======================================================================
//function : SMESH_Invalid_subMesh_i
//purpose : constructor of "invalid sub-mesh" created by SMESH_Gen_i::CopyMeshWithGeom()
//=======================================================================
SMESH_Invalid_subMesh_i::SMESH_Invalid_subMesh_i( PortableServer::POA_ptr thePOA,
SMESH_Gen_i* gen_i,
SMESH_Mesh_i* mesh_i,
int localId,
GEOM::GEOM_Object_ptr shape )
: SALOME::GenericObj_i( thePOA ),
SMESH_subMesh_i( thePOA, gen_i, mesh_i, localId )
{
_geom = GEOM::GEOM_Object::_duplicate( shape );
}
//=======================================================================
//function : GetSubShape
//purpose : return geomtry which is not a sub-shape of the main shape
//=======================================================================
GEOM::GEOM_Object_ptr SMESH_Invalid_subMesh_i::GetSubShape()
throw (SALOME::SALOME_Exception)
{
return GEOM::GEOM_Object::_duplicate( _geom );
}

View File

@ -130,4 +130,26 @@ protected:
friend class SMESH_PreMeshInfo; friend class SMESH_PreMeshInfo;
}; };
class SMESH_I_EXPORT SMESH_Invalid_subMesh_i:
public virtual POA_SMESH::SMESH_subMesh,
public virtual SALOME::GenericObj_i,
public virtual SMESH_subMesh_i
{
public:
SMESH_Invalid_subMesh_i( PortableServer::POA_ptr thePOA,
SMESH_Gen_i* gen_i,
SMESH_Mesh_i* mesh_i,
int localId,
GEOM::GEOM_Object_ptr shape);
virtual GEOM::GEOM_Object_ptr GetSubShape()
throw (SALOME::SALOME_Exception);
protected:
GEOM::GEOM_Object_var _geom;
};
#endif #endif

View File

@ -782,11 +782,46 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
an instance of class :class:`Mesh` an instance of class :class:`Mesh`
""" """
if (isinstance( meshPart, Mesh )): if isinstance( meshPart, Mesh ):
meshPart = meshPart.GetMesh() meshPart = meshPart.GetMesh()
mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs ) mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
return Mesh(self, self.geompyD, mesh) return Mesh(self, self.geompyD, mesh)
def CopyMeshWithGeom( self, sourceMesh, newGeom, meshName="", toCopyGroups=True,
toReuseHypotheses=True, toCopyElements=True):
"""
Create a mesh by copying a mesh definition (hypotheses and groups) to a new geometry.
It is supposed that the new geometry is a modified geometry of *sourceMesh*.
To facilitate and speed up the operation, consider using
"Set presentation parameters and sub-shapes from arguments" option in
a dialog of geometrical operation used to create the new geometry.
Parameters:
sourceMesh: the mesh to copy definition of.
newGeom: the new geomtry.
meshName: an optional name of the new mesh. If omitted, the mesh name is kept.
toCopyGroups: to create groups in the new mesh.
toReuseHypotheses: to reuse hypotheses of the *sourceMesh*.
toCopyElements: to copy mesh elements present on non-modified sub-shapes of
*sourceMesh*.
Returns:
tuple ( ok, newMesh, newGroups, newSubMeshes, newHypotheses, invalidEntries )
*invalidEntries* are study entries of objects whose
counterparts are not found in the *newGeom*, followed by entries
of mesh sub-objects that are invalid because they depend on a not found
preceeding sub-shape
"""
if isinstance( sourceMesh, Mesh ):
sourceMesh = sourceMesh.GetMesh()
ok, newMesh, newGroups, newSubMeshes, newHypotheses, invalidEntries = \
SMESH._objref_SMESH_Gen.CopyMeshWithGeom( self, sourceMesh, newGeom, meshName,
toCopyGroups,
toReuseHypotheses,
toCopyElements)
return ( ok, Mesh(self, self.geompyD, newMesh),
newGroups, newSubMeshes, newHypotheses, invalidEntries )
def GetSubShapesId( self, theMainObject, theListOfSubObjects ): def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
""" """
Return IDs of sub-shapes Return IDs of sub-shapes
@ -6156,7 +6191,7 @@ class Mesh(metaclass = MeshMeta):
Fill with 2D elements a hole defined by a SMESH.FreeBorder. Fill with 2D elements a hole defined by a SMESH.FreeBorder.
Parameters: Parameters:
FreeBorder: either a SMESH.FreeBorder or a list on node IDs. These nodes holeNodes: either a SMESH.FreeBorder or a list on node IDs. These nodes
must describe all sequential nodes of the hole border. The first and the last must describe all sequential nodes of the hole border. The first and the last
nodes must be the same. Use :meth:`FindFreeBorders` to get nodes of holes. nodes must be the same. Use :meth:`FindFreeBorders` to get nodes of holes.
groupName (string): name of a group to add new faces groupName (string): name of a group to add new faces

View File

@ -49,7 +49,7 @@ using namespace std;
//============================================================================= //=============================================================================
StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, SMESH_Gen * gen) StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, SMESH_Gen * gen)
:SMESH_Hypothesis(hypId, gen) :StdMeshers_Reversible1D(hypId, gen)
{ {
_begLength = 1.; _begLength = 1.;
_endLength = 10.; _endLength = 10.;
@ -105,21 +105,6 @@ double StdMeshers_Arithmetic1D::GetLength(bool isStartLength) const
*/ */
//============================================================================= //=============================================================================
void StdMeshers_Arithmetic1D::SetReversedEdges( std::vector<int>& ids )
{
if ( ids != _edgeIDs ) {
_edgeIDs = ids;
NotifySubMeshesHypothesisModification();
}
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save) ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save)
{ {
int listSize = _edgeIDs.size(); int listSize = _edgeIDs.size();
@ -165,28 +150,6 @@ istream & StdMeshers_Arithmetic1D::LoadFrom(istream & load)
return load; return load;
} }
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator <<(ostream & save, StdMeshers_Arithmetic1D & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >>(istream & load, StdMeshers_Arithmetic1D & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================ //================================================================================
/*! /*!
* \brief Initialize start and end length by the mesh built on the geometry * \brief Initialize start and end length by the mesh built on the geometry

View File

@ -32,13 +32,11 @@
#include "SMESH_StdMeshers.hxx" #include "SMESH_StdMeshers.hxx"
#include "StdMeshers_Reversible1D.hxx"
#include "SMESH_Hypothesis.hxx" #include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx" #include "Utils_SALOME_Exception.hxx"
#include <vector> class STDMESHERS_EXPORT StdMeshers_Arithmetic1D: public StdMeshers_Reversible1D
class STDMESHERS_EXPORT StdMeshers_Arithmetic1D:
public SMESH_Hypothesis
{ {
public: public:
StdMeshers_Arithmetic1D(int hypId, SMESH_Gen* gen); StdMeshers_Arithmetic1D(int hypId, SMESH_Gen* gen);
@ -48,18 +46,8 @@ public:
double GetLength(bool isStartLength) const; double GetLength(bool isStartLength) const;
void SetReversedEdges( std::vector<int>& ids);
void SetObjectEntry( const char* entry ) { _objEntry = entry; }
const char* GetObjectEntry() { return _objEntry.c_str(); }
const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
virtual std::ostream & SaveTo(std::ostream & save); virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load); virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream& operator << (std::ostream & save, StdMeshers_Arithmetic1D & hyp);
friend std::istream& operator >> (std::istream & load, StdMeshers_Arithmetic1D & hyp);
/*! /*!
* \brief Initialize start and end length by the mesh built on the geometry * \brief Initialize start and end length by the mesh built on the geometry
@ -77,8 +65,6 @@ public:
protected: protected:
double _begLength, _endLength; double _begLength, _endLength;
std::vector<int> _edgeIDs;
std::string _objEntry;
}; };
#endif #endif

View File

@ -35,9 +35,8 @@ using namespace std;
*/ */
//============================================================================= //=============================================================================
StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, SMESH_Gen * gen)
SMESH_Gen * gen) :StdMeshers_Reversible1D(hypId, gen)
:SMESH_Hypothesis(hypId, gen)
{ {
_name = "FixedPoints1D"; _name = "FixedPoints1D";
_param_algo_dim = 1; _param_algo_dim = 1;
@ -81,27 +80,6 @@ void StdMeshers_FixedPoints1D::SetNbSegments(std::vector<int>& listNbSeg)
NotifySubMeshesHypothesisModification(); NotifySubMeshesHypothesisModification();
} }
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_FixedPoints1D::SetReversedEdges( std::vector<int>& ids )
{
if ( ids != _edgeIDs ) {
_edgeIDs = ids;
NotifySubMeshesHypothesisModification();
}
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save) ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
{ {
int listSize = _params.size(); int listSize = _params.size();

View File

@ -29,13 +29,13 @@
#include "SMESH_StdMeshers.hxx" #include "SMESH_StdMeshers.hxx"
#include "StdMeshers_Reversible1D.hxx"
#include "SMESH_Hypothesis.hxx" #include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx" #include "Utils_SALOME_Exception.hxx"
#include <vector> #include <vector>
class STDMESHERS_EXPORT StdMeshers_FixedPoints1D: class STDMESHERS_EXPORT StdMeshers_FixedPoints1D: public StdMeshers_Reversible1D
public SMESH_Hypothesis
{ {
public: public:
StdMeshers_FixedPoints1D(int hypId, SMESH_Gen* gen); StdMeshers_FixedPoints1D(int hypId, SMESH_Gen* gen);
@ -51,14 +51,6 @@ public:
const std::vector<int>& GetNbSegments() const { return _nbsegs; } const std::vector<int>& GetNbSegments() const { return _nbsegs; }
void SetReversedEdges( std::vector<int>& ids);
void SetObjectEntry( const char* entry ) { _objEntry = entry; }
const char* GetObjectEntry() { return _objEntry.c_str(); }
const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
virtual std::ostream & SaveTo(std::ostream & save); virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load); virtual std::istream & LoadFrom(std::istream & load);
@ -79,8 +71,6 @@ public:
protected: protected:
std::vector<double> _params; std::vector<double> _params;
std::vector<int> _nbsegs; std::vector<int> _nbsegs;
std::vector<int> _edgeIDs;
std::string _objEntry;
}; };
#endif #endif

View File

@ -60,7 +60,7 @@ const double PRECISION = 1e-7;
StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId, StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId,
SMESH_Gen * gen) SMESH_Gen * gen)
: SMESH_Hypothesis(hypId, gen), : StdMeshers_Reversible1D(hypId, gen),
_numberOfSegments(15),//issue 19923 _numberOfSegments(15),//issue 19923
_distrType(DT_Regular), _distrType(DT_Regular),
_scaleFactor(1.), _scaleFactor(1.),
@ -721,19 +721,3 @@ bool StdMeshers_NumberOfSegments::SetParametersByDefaults(const TDefaults& dflt
{ {
return (_numberOfSegments = dflts._nbSegments ); return (_numberOfSegments = dflts._nbSegments );
} }
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_NumberOfSegments::SetReversedEdges( std::vector<int>& ids )
{
if ( ids != _edgeIDs ) {
_edgeIDs = ids;
NotifySubMeshesHypothesisModification();
}
}

View File

@ -29,10 +29,10 @@
#ifndef _SMESH_NUMBEROFSEGMENTS_HXX_ #ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
#define _SMESH_NUMBEROFSEGMENTS_HXX_ #define _SMESH_NUMBEROFSEGMENTS_HXX_
#include "SMESH_StdMeshers.hxx" #include "StdMeshers_Reversible1D.hxx"
#include "SMESH_Hypothesis.hxx" #include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx" #include "Utils_SALOME_Exception.hxx"
#include <vector> #include <vector>
/*! /*!
@ -41,8 +41,7 @@
* It provides parameters for subdivision an edge by various * It provides parameters for subdivision an edge by various
* distribution types, considering the given number of resulting segments * distribution types, considering the given number of resulting segments
*/ */
class STDMESHERS_EXPORT StdMeshers_NumberOfSegments: class STDMESHERS_EXPORT StdMeshers_NumberOfSegments: public StdMeshers_Reversible1D
public SMESH_Hypothesis
{ {
public: public:
StdMeshers_NumberOfSegments(int hypId, SMESH_Gen* gen); StdMeshers_NumberOfSegments(int hypId, SMESH_Gen* gen);
@ -171,14 +170,6 @@ public:
int ConversionMode() const int ConversionMode() const
throw (SALOME_Exception); throw (SALOME_Exception);
void SetReversedEdges( std::vector<int>& ids);
void SetObjectEntry( const char* entry ) { _objEntry = entry; }
const char* GetObjectEntry() { return _objEntry.c_str(); }
const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
/*! /*!
* \brief Initialize number of segments by the mesh built on the geometry * \brief Initialize number of segments by the mesh built on the geometry
* \param theMesh - the built mesh * \param theMesh - the built mesh
@ -205,8 +196,6 @@ protected:
std::vector<double> _table, _distr; //!< the table for DT_TabFunc, a sequence of pairs of numbers std::vector<double> _table, _distr; //!< the table for DT_TabFunc, a sequence of pairs of numbers
std::string _func; //!< the expression of the function for DT_ExprFunc std::string _func; //!< the expression of the function for DT_ExprFunc
int _convMode; //!< flag of conversion mode: 0=exponent, 1=cut negative int _convMode; //!< flag of conversion mode: 0=exponent, 1=cut negative
std::vector<int> _edgeIDs; //!< list of reversed edges ids
std::string _objEntry; //!< Entry of the main object to reverse edges
}; };
#endif #endif

View File

@ -51,7 +51,7 @@ public:
int GetTriaVertex() const { return _triaVertexID; } int GetTriaVertex() const { return _triaVertexID; }
void SetObjectEntry (const char* entry) { _objEntry = entry; } void SetObjectEntry (const char* entry) { _objEntry = entry; }
const char* GetObjectEntry() { return _objEntry.c_str(); } const char* GetObjectEntry() const { return _objEntry.c_str(); }
void SetQuadType (StdMeshers_QuadType type); void SetQuadType (StdMeshers_QuadType type);
StdMeshers_QuadType GetQuadType() const { return _quadType; } StdMeshers_QuadType GetQuadType() const { return _quadType; }

View File

@ -44,7 +44,7 @@ public:
void SetObjectEntry( const char* entry ) { _objEntry = entry; } void SetObjectEntry( const char* entry ) { _objEntry = entry; }
const char* GetObjectEntry() { return _objEntry.c_str(); } const char* GetObjectEntry() const { return _objEntry.c_str(); }
const std::vector<int>& GetReversedEdges() const { return _edgeIDs; } const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }

View File

@ -47,9 +47,8 @@ using namespace std;
*/ */
//============================================================================= //=============================================================================
StdMeshers_StartEndLength::StdMeshers_StartEndLength(int hypId, StdMeshers_StartEndLength::StdMeshers_StartEndLength( int hypId, SMESH_Gen* gen )
SMESH_Gen * gen) :StdMeshers_Reversible1D(hypId, gen)
:SMESH_Hypothesis(hypId, gen)
{ {
_begLength = 1.; _begLength = 1.;
_endLength = 10.; _endLength = 10.;
@ -105,21 +104,6 @@ double StdMeshers_StartEndLength::GetLength(bool isStartLength) const
*/ */
//============================================================================= //=============================================================================
void StdMeshers_StartEndLength::SetReversedEdges( std::vector<int>& ids )
{
if ( ids != _edgeIDs ) {
_edgeIDs = ids;
NotifySubMeshesHypothesisModification();
}
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_StartEndLength::SaveTo(ostream & save) ostream & StdMeshers_StartEndLength::SaveTo(ostream & save)
{ {
int listSize = _edgeIDs.size(); int listSize = _edgeIDs.size();
@ -166,28 +150,6 @@ istream & StdMeshers_StartEndLength::LoadFrom(istream & load)
return load; return load;
} }
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator <<(ostream & save, StdMeshers_StartEndLength & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================ //================================================================================
/*! /*!
* \brief Initialize start and end length by the mesh built on the geometry * \brief Initialize start and end length by the mesh built on the geometry

View File

@ -29,12 +29,13 @@
#include "SMESH_StdMeshers.hxx" #include "SMESH_StdMeshers.hxx"
#include "StdMeshers_Reversible1D.hxx"
#include "SMESH_Hypothesis.hxx" #include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx" #include "Utils_SALOME_Exception.hxx"
#include <vector> #include <vector>
class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis class STDMESHERS_EXPORT StdMeshers_StartEndLength: public StdMeshers_Reversible1D
{ {
public: public:
StdMeshers_StartEndLength(int hypId, SMESH_Gen * gen); StdMeshers_StartEndLength(int hypId, SMESH_Gen * gen);
@ -44,19 +45,8 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
double GetLength(bool isStartLength) const; double GetLength(bool isStartLength) const;
void SetReversedEdges( std::vector<int>& ids);
const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
void SetObjectEntry( const char* entry ) { _objEntry = entry; }
const char* GetObjectEntry() { return _objEntry.c_str(); }
virtual std::ostream & SaveTo(std::ostream & save); virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load); virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator <<(std::ostream & save, StdMeshers_StartEndLength & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_StartEndLength & hyp);
/*! /*!
* \brief Initialize start and end length by the mesh built on the geometry * \brief Initialize start and end length by the mesh built on the geometry
@ -74,8 +64,6 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
protected: protected:
double _begLength, _endLength; double _begLength, _endLength;
std::vector<int> _edgeIDs;
std::string _objEntry;
}; };
#endif #endif

View File

@ -83,6 +83,12 @@ class STDMESHERS_I_EXPORT StdMeshers_Adaptive1D_i:
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/ */
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return false; }
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -48,7 +48,8 @@ using namespace std;
StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr thePOA, StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl ) ::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ), : SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ) SMESH_Hypothesis_i( thePOA ),
StdMeshers_Reversible1D_i( this )
{ {
myBaseImpl = new ::StdMeshers_Arithmetic1D( theGenImpl->GetANewId(), myBaseImpl = new ::StdMeshers_Arithmetic1D( theGenImpl->GetANewId(),
theGenImpl ); theGenImpl );
@ -131,98 +132,6 @@ CORBA::Double StdMeshers_Arithmetic1D_i::GetLength( CORBA::Boolean theIsStart)
return this->GetImpl()->GetLength( theIsStart ); return this->GetImpl()->GetLength( theIsStart );
} }
//=============================================================================
/*!
* StdMeshers_Arithmetic1D_i::SetReversedEdges
*
* Set edges to reverse
*/
//=============================================================================
void StdMeshers_Arithmetic1D_i::SetReversedEdges( const SMESH::long_array& theIds )
{
ASSERT( myBaseImpl );
try {
std::vector<int> ids( theIds.length() );
CORBA::Long iEnd = theIds.length();
for ( CORBA::Long i = 0; i < iEnd; i++ )
ids[ i ] = theIds[ i ];
this->GetImpl()->SetReversedEdges( ids );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
// Update Python script
SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
}
//=============================================================================
/*!
* StdMeshers_Arithmetic1D_i::SetObjectEntry
*
* Set the Entry for the Main Object
*/
//=============================================================================
void StdMeshers_Arithmetic1D_i::SetObjectEntry( const char* theEntry )
{
ASSERT( myBaseImpl );
string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
try {
this->GetImpl()->SetObjectEntry( entry.c_str() );
// Update Python script
SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
}
}
//=============================================================================
/*!
* StdMeshers_Arithmetic1D_i::GetObjectEntry
*
* Set the Entry for the Main Object
*/
//=============================================================================
char* StdMeshers_Arithmetic1D_i::GetObjectEntry()
{
ASSERT( myBaseImpl );
const char* entry;
try {
entry = this->GetImpl()->GetObjectEntry();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
return CORBA::string_dup( entry );
}
//=============================================================================
/*!
* StdMeshers_Arithmetic1D_i::GetReversedEdges
*
* Get reversed edges
*/
//=============================================================================
SMESH::long_array* StdMeshers_Arithmetic1D_i::GetReversedEdges()
{
ASSERT( myBaseImpl );
SMESH::long_array_var anArray = new SMESH::long_array;
std::vector<int> ids = this->GetImpl()->GetReversedEdges();
anArray->length( ids.size() );
for ( CORBA::ULong i = 0; i < ids.size(); i++)
anArray [ i ] = ids [ i ];
return anArray._retn();
}
//============================================================================= //=============================================================================
/*! /*!
* StdMeshers_Arithmetic1D_i::GetImpl * StdMeshers_Arithmetic1D_i::GetImpl
@ -261,3 +170,30 @@ std::string StdMeshers_Arithmetic1D_i::getMethodOfParameter(const int paramIndex
{ {
return paramIndex == 0 ? "SetStartLength" : "SetEndLength"; return paramIndex == 0 ? "SetStartLength" : "SetEndLength";
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_Arithmetic1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_Arithmetic1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
}

View File

@ -33,7 +33,7 @@
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
#include "SMESH_Hypothesis_i.hxx" #include "StdMeshers_Reversible1D_i.hxx"
#include "StdMeshers_Arithmetic1D.hxx" #include "StdMeshers_Arithmetic1D.hxx"
// ====================================================== // ======================================================
@ -41,7 +41,8 @@
// ====================================================== // ======================================================
class STDMESHERS_I_EXPORT StdMeshers_Arithmetic1D_i: class STDMESHERS_I_EXPORT StdMeshers_Arithmetic1D_i:
public virtual POA_StdMeshers::StdMeshers_Arithmetic1D, public virtual POA_StdMeshers::StdMeshers_Arithmetic1D,
public virtual SMESH_Hypothesis_i public virtual SMESH_Hypothesis_i,
public virtual StdMeshers_Reversible1D_i
{ {
public: public:
// Constructor // Constructor
@ -64,24 +65,23 @@ public:
// Get length // Get length
CORBA::Double GetLength(CORBA::Boolean theIsStart); CORBA::Double GetLength(CORBA::Boolean theIsStart);
//Set Reversed Edges
void SetReversedEdges( const SMESH::long_array& theIDs);
//Get Reversed Edges
SMESH::long_array* GetReversedEdges();
//Set the Entry of the Object
void SetObjectEntry( const char* theEntry);
//Get Object Entry
char* GetObjectEntry();
// Get implementation // Get implementation
::StdMeshers_Arithmetic1D* GetImpl(); ::StdMeshers_Arithmetic1D* GetImpl();
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -66,6 +66,12 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return false; }
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -141,6 +141,13 @@ class STDMESHERS_I_EXPORT StdMeshers_CartesianParameters3D_i:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return false; }
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -65,6 +65,11 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return false; }
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -45,8 +45,9 @@ using namespace std;
StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA, StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl ) ::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ), : SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ) SMESH_Hypothesis_i( thePOA ),
StdMeshers_Reversible1D_i( this )
{ {
myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(), myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
theGenImpl); theGenImpl);
@ -156,98 +157,6 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
return anArray._retn(); return anArray._retn();
} }
//=============================================================================
/*!
* StdMeshers_FixedPoints1D_i::SetReversedEdges
*
* Set edges to reverse
*/
//=============================================================================
void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds )
{
ASSERT( myBaseImpl );
try {
std::vector<int> ids( theIds.length() );
CORBA::Long iEnd = theIds.length();
for ( CORBA::Long i = 0; i < iEnd; i++ )
ids[ i ] = theIds[ i ];
this->GetImpl()->SetReversedEdges( ids );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
// Update Python script
SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
}
//=============================================================================
/*!
* StdMeshers_FixedPoints1D_i::SetObjectEntry
*
* Set the Entry for the Main Object
*/
//=============================================================================
void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry )
{
ASSERT( myBaseImpl );
string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
try {
this->GetImpl()->SetObjectEntry( entry.c_str() );
// Update Python script
SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
}
}
//=============================================================================
/*!
* StdMeshers_FixedPoints1D_i::GetObjectEntry
*
* Set the Entry for the Main Object
*/
//=============================================================================
char* StdMeshers_FixedPoints1D_i::GetObjectEntry()
{
ASSERT( myBaseImpl );
const char* entry;
try {
entry = this->GetImpl()->GetObjectEntry();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
return CORBA::string_dup( entry );
}
//=============================================================================
/*!
* StdMeshers_FixedPoints1D_i::GetReversedEdges
*
* Get reversed edges
*/
//=============================================================================
SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
{
ASSERT( myBaseImpl );
SMESH::long_array_var anArray = new SMESH::long_array;
std::vector<int> ids = this->GetImpl()->GetReversedEdges();
anArray->length( ids.size() );
for ( CORBA::ULong i = 0; i < ids.size(); i++)
anArray [ i ] = ids [ i ];
return anArray._retn();
}
//============================================================================= //=============================================================================
/*! /*!
* StdMeshers_FixedPoints1D_i::GetImpl * StdMeshers_FixedPoints1D_i::GetImpl
@ -269,9 +178,34 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
* *
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/ */
//================================================================================ //================================================================================
CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type ) CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
{ {
return type == SMESH::DIM_1D; return type == SMESH::DIM_1D;
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_FixedPoints1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_FixedPoints1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
}

View File

@ -30,7 +30,7 @@
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
#include "SMESH_Hypothesis_i.hxx" #include "StdMeshers_Reversible1D_i.hxx"
#include "StdMeshers_FixedPoints1D.hxx" #include "StdMeshers_FixedPoints1D.hxx"
// ====================================================== // ======================================================
@ -38,7 +38,8 @@
// ====================================================== // ======================================================
class STDMESHERS_I_EXPORT StdMeshers_FixedPoints1D_i: class STDMESHERS_I_EXPORT StdMeshers_FixedPoints1D_i:
public virtual POA_StdMeshers::StdMeshers_FixedPoints1D, public virtual POA_StdMeshers::StdMeshers_FixedPoints1D,
public virtual SMESH_Hypothesis_i public virtual SMESH_Hypothesis_i,
public virtual StdMeshers_Reversible1D_i
{ {
public: public:
// Constructor // Constructor
@ -62,23 +63,22 @@ public:
// Returns list of numbers of segments // Returns list of numbers of segments
SMESH::long_array* GetNbSegments(); SMESH::long_array* GetNbSegments();
//Set Reversed Edges
void SetReversedEdges( const SMESH::long_array& theIDs);
//Get Reversed Edges
SMESH::long_array* GetReversedEdges();
//Set the Entry of the Object
void SetObjectEntry( const char* theEntry);
//Get Object Entry
char* GetObjectEntry();
// Get implementation // Get implementation
::StdMeshers_FixedPoints1D* GetImpl(); ::StdMeshers_FixedPoints1D* GetImpl();
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
}; };
#endif #endif

View File

@ -127,15 +127,41 @@ CORBA::Double StdMeshers_Geometric1D_i::GetCommonRatio()
//================================================================================ //================================================================================
/*! /*!
* \brief Verify whether hypothesis supports given entity type * \brief Verify whether hypothesis supports given entity type
* \param type - dimension (see SMESH::Dimension enumeration) * \param type - dimension (see SMESH::Dimension enumeration)
* \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
* *
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/ */
//================================================================================ //================================================================================
CORBA::Boolean StdMeshers_Geometric1D_i::IsDimSupported(::SMESH::Dimension type) CORBA::Boolean StdMeshers_Geometric1D_i::IsDimSupported(::SMESH::Dimension type)
{ {
return type == SMESH::DIM_1D; return type == SMESH::DIM_1D;
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_Geometric1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_Geometric1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
}

View File

@ -59,6 +59,18 @@ class STDMESHERS_I_EXPORT StdMeshers_Geometric1D_i:
// Get implementation // Get implementation
::StdMeshers_Geometric1D* GetImpl(); ::StdMeshers_Geometric1D* GetImpl();
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
}; };
#endif #endif

View File

@ -64,6 +64,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ImportSource1D_i:
virtual void LoadFrom( const char* theStream ); virtual void LoadFrom( const char* theStream );
virtual void UpdateAsMeshesRestored(); virtual void UpdateAsMeshesRestored();
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
private: private:
SMESH::string_array_var _groupEntries; SMESH::string_array_var _groupEntries;
std::vector< std::string > _groupIDs; std::vector< std::string > _groupIDs;

View File

@ -64,6 +64,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ImportSource2D_i:
virtual void LoadFrom( const char* theStream ); virtual void LoadFrom( const char* theStream );
virtual void UpdateAsMeshesRestored(); virtual void UpdateAsMeshesRestored();
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
private: private:
SMESH::string_array_var _groupEntries; SMESH::string_array_var _groupEntries;
std::vector< std::string > _groupIDs; std::vector< std::string > _groupIDs;

View File

@ -54,6 +54,17 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -77,6 +77,17 @@ public:
virtual char* SaveTo(); virtual char* SaveTo();
virtual void LoadFrom( const char* theStream ); virtual void LoadFrom( const char* theStream );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
// restore myMethod2VarParams by parameters stored in an old study // restore myMethod2VarParams by parameters stored in an old study
virtual void setOldParameters (const char* theParameters); virtual void setOldParameters (const char* theParameters);

View File

@ -66,6 +66,17 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -71,6 +71,17 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -63,6 +63,18 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -63,6 +63,17 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -77,6 +77,17 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -50,6 +50,17 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
::StdMeshers_NotConformAllowed* _impl; ::StdMeshers_NotConformAllowed* _impl;
}; };

View File

@ -52,6 +52,17 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -68,6 +68,17 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -36,7 +36,6 @@
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
using namespace std;
//============================================================================= //=============================================================================
/*! /*!
* StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
@ -47,8 +46,9 @@ using namespace std;
StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA, StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl ) ::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ), : SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ) SMESH_Hypothesis_i( thePOA ),
StdMeshers_Reversible1D_i( this )
{ {
myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(), myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
theGenImpl ); theGenImpl );
@ -159,100 +159,6 @@ CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
return this->GetImpl()->GetNumberOfSegments(); return this->GetImpl()->GetNumberOfSegments();
} }
//=============================================================================
/*!
* StdMeshers_NumberOfSegments_i::SetReversedEdges
*
* Set edges to reverse
*/
//=============================================================================
void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds )
{
ASSERT( myBaseImpl );
try {
std::vector<int> ids( theIds.length() );
CORBA::Long iEnd = theIds.length();
for ( CORBA::Long i = 0; i < iEnd; i++ )
ids[ i ] = theIds[ i ];
this->GetImpl()->SetReversedEdges( ids );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
// Update Python script
SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
}
//=============================================================================
/*!
* StdMeshers_NumberOfSegments_i::SetObjectEntry
*
* Set the Entry for the Main Object
*/
//=============================================================================
void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* theEntry )
{
ASSERT( myBaseImpl );
string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
try {
this->GetImpl()->SetObjectEntry( entry.c_str() );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
// Update Python script
SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
}
//=============================================================================
/*!
* StdMeshers_NumberOfSegments_i::GetObjectEntry
*
* Set the Entry for the Main Object
*/
//=============================================================================
char* StdMeshers_NumberOfSegments_i::GetObjectEntry()
{
ASSERT( myBaseImpl );
const char* entry;
try {
entry = this->GetImpl()->GetObjectEntry();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
return CORBA::string_dup( entry );
}
//=============================================================================
/*!
* StdMeshers_NumberOfSegments_i::GetReversedEdges
*
* Get reversed edges
*/
//=============================================================================
SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges()
{
ASSERT( myBaseImpl );
SMESH::long_array_var anArray = new SMESH::long_array;
std::vector<int> ids = this->GetImpl()->GetReversedEdges();
anArray->length( ids.size() );
for ( size_t i = 0; i < ids.size(); i++)
anArray [ i ] = ids [ i ];
return anArray._retn();
}
//============================================================================= //=============================================================================
/*! /*!
*/ */
@ -497,3 +403,30 @@ std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramI
{ {
return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor"; return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_NumberOfSegments_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_NumberOfSegments_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
}

View File

@ -35,7 +35,7 @@
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
#include "SMESH_Hypothesis_i.hxx" #include "StdMeshers_Reversible1D_i.hxx"
#include "StdMeshers_NumberOfSegments.hxx" #include "StdMeshers_NumberOfSegments.hxx"
// ====================================================== // ======================================================
@ -43,7 +43,8 @@
// ====================================================== // ======================================================
class STDMESHERS_I_EXPORT StdMeshers_NumberOfSegments_i: class STDMESHERS_I_EXPORT StdMeshers_NumberOfSegments_i:
public virtual POA_StdMeshers::StdMeshers_NumberOfSegments, public virtual POA_StdMeshers::StdMeshers_NumberOfSegments,
public virtual SMESH_Hypothesis_i public virtual SMESH_Hypothesis_i,
public virtual StdMeshers_Reversible1D_i
{ {
public: public:
// Constructor // Constructor
@ -104,18 +105,16 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
//Set Reversed Edges
void SetReversedEdges( const SMESH::long_array& theIDs);
//Get Reversed Edges // Methods for copying mesh definition to other geometry
SMESH::long_array* GetReversedEdges();
//Set Object Entry // Return geometry this hypothesis depends on. Return false if there is no geometry parameter
void SetObjectEntry( const char* entry); virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
//Get Object Entry
char* GetObjectEntry();
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -162,3 +162,21 @@ void StdMeshers_ObjRefUlils::SaveToStream( const std::string& studyEntry,
else else
stream << " " << studyEntry; stream << " " << studyEntry;
} }
//=======================================================================
//function : EntryToShape
//purpose : Return TopoDS_Shape by a study entry
//=======================================================================
TopoDS_Shape StdMeshers_ObjRefUlils::EntryToShape(const std::string theEntry)
{
TopoDS_Shape shape;
if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() );
CORBA::Object_var obj = gen->SObjectToObject( sobj );
GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj );
shape = gen->GeomObjectToShape( geom.in() );
}
return shape;
}

View File

@ -65,6 +65,13 @@ public:
return TopoDS_Shape(); return TopoDS_Shape();
} }
/*!
* \brief Return TopoDS_Shape by a study entry
* \param theEntry - study entry
* \retval TopoDS_Shape - result TopoDS_Shape
*/
static TopoDS_Shape EntryToShape(const std::string theEntry);
/*! /*!
* \brief Return study entry of GEOM Object * \brief Return study entry of GEOM Object
*/ */

View File

@ -298,3 +298,46 @@ void StdMeshers_ProjectionSource1D_i::LoadFrom( const char* theStream )
str >> myShapeEntries[ i ]; str >> myShapeEntries[ i ];
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_ProjectionSource1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
for ( int i = 0; i < NB_SHAPES; ++i )
entryArray.push_back( myShapeEntries[ i ]);
return true;
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_ProjectionSource1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
TopoDS_Shape shapes[ NB_SHAPES ];
for ( int i = 0; i < NB_SHAPES; ++i )
{
myShapeEntries[ i ] = entryArray[ i ];
shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]);
}
try {
GetImpl()->SetSourceEdge ( shapes[ SRC_EDGE ] );
GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX ],
shapes[ TGT_VERTEX ]);
}
catch (...) {
return false;
}
return true;
}

View File

@ -109,6 +109,15 @@ public:
virtual char* SaveTo(); virtual char* SaveTo();
virtual void LoadFrom( const char* theStream ); virtual void LoadFrom( const char* theStream );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
private: private:
// keep entries because the same shape can be published several times with // keep entries because the same shape can be published several times with
// different names and in this case a correct name can't be restored by a TopoDS_Shape // different names and in this case a correct name can't be restored by a TopoDS_Shape

View File

@ -311,3 +311,48 @@ void StdMeshers_ProjectionSource2D_i::LoadFrom( const char* theStream )
str >> myShapeEntries[ i ]; str >> myShapeEntries[ i ];
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_ProjectionSource2D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
for ( int i = 0; i < NB_SHAPES; ++i )
entryArray.push_back( myShapeEntries[ i ]);
return true;
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_ProjectionSource2D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
TopoDS_Shape shapes[ NB_SHAPES ];
for ( int i = 0; i < NB_SHAPES; ++i )
{
myShapeEntries[ i ] = entryArray[ i ];
shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]);
}
try {
GetImpl()->SetSourceFace ( shapes[ SRC_FACE ] );
GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX1 ],
shapes[ SRC_VERTEX2 ],
shapes[ TGT_VERTEX1 ],
shapes[ TGT_VERTEX2 ]);
}
catch (...) {
return false;
}
return true;
}

View File

@ -113,6 +113,16 @@ public:
virtual char* SaveTo(); virtual char* SaveTo();
virtual void LoadFrom( const char* theStream ); virtual void LoadFrom( const char* theStream );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
private: private:
// keep entries because the same shape can be published several times with // keep entries because the same shape can be published several times with
// different names and in this case a correct name can't be restored by a TopoDS_Shape // different names and in this case a correct name can't be restored by a TopoDS_Shape

View File

@ -312,3 +312,48 @@ void StdMeshers_ProjectionSource3D_i::LoadFrom( const char* theStream )
str >> myShapeEntries[ i ]; str >> myShapeEntries[ i ];
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_ProjectionSource3D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
for ( int i = 0; i < NB_SHAPES; ++i )
entryArray.push_back( myShapeEntries[ i ]);
return true;
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_ProjectionSource3D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
TopoDS_Shape shapes[ NB_SHAPES ];
for ( int i = 0; i < NB_SHAPES; ++i )
{
myShapeEntries[ i ] = entryArray[ i ];
shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]);
}
try {
GetImpl()->SetSource3DShape ( shapes[ SRC_SHAPE3D ] );
GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX1 ],
shapes[ SRC_VERTEX2 ],
shapes[ TGT_VERTEX1 ],
shapes[ TGT_VERTEX2 ]);
}
catch (...) {
return false;
}
return true;
}

View File

@ -114,6 +114,17 @@ public:
virtual char* SaveTo(); virtual char* SaveTo();
virtual void LoadFrom( const char* theStream ); virtual void LoadFrom( const char* theStream );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
private: private:
// keep entries because the same shape can be published several times with // keep entries because the same shape can be published several times with
// different names and in this case a correct name can't be restored by a TopoDS_Shape // different names and in this case a correct name can't be restored by a TopoDS_Shape
@ -124,4 +135,3 @@ private:
}; };
#endif #endif

View File

@ -52,6 +52,12 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return false; }
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
// ====================================================== // ======================================================
@ -69,6 +75,12 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return false; }
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -378,3 +378,54 @@ void StdMeshers_QuadrangleParams_i::LoadFrom( const char* theStream )
myBaseImpl->LoadFrom( is ); myBaseImpl->LoadFrom( is );
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_QuadrangleParams_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
const ::StdMeshers_QuadrangleParams* impl =
static_cast<const ::StdMeshers_QuadrangleParams*>( myBaseImpl );
subIDArray.push_back( impl->GetTriaVertex() );
entryArray.push_back( impl->GetObjectEntry() );
entryArray.insert( entryArray.end(), myShapeEntries.begin(), myShapeEntries.end() );
return true;
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_QuadrangleParams_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
if ( !subIDArray.empty() )
GetImpl()->SetTriaVertex( subIDArray[0] );
GetImpl()->SetObjectEntry( entryArray[0].c_str() );
myShapeEntries.assign( ++entryArray.begin(), entryArray.end() );
std::vector< TopoDS_Shape > shapes;
std::vector< gp_Pnt > points;
this->GetImpl()->GetEnforcedNodes( shapes, points );
shapes.clear();
for ( size_t i = 0; i < myShapeEntries.size(); ++i )
shapes.push_back( StdMeshers_ObjRefUlils::EntryToShape( myShapeEntries[i] ));
this->GetImpl()->SetEnforcedNodes( shapes, points );
return true;
}

View File

@ -84,6 +84,16 @@ public:
virtual char* SaveTo(); virtual char* SaveTo();
virtual void LoadFrom( const char* theStream ); virtual void LoadFrom( const char* theStream );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
protected: protected:
std::vector<std::string> myShapeEntries; std::vector<std::string> myShapeEntries;

View File

@ -58,6 +58,12 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return false; }
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -59,6 +59,12 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return false; }
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
}; };
#endif #endif

View File

@ -139,5 +139,46 @@ SMESH::long_array* StdMeshers_Reversible1D_i::GetReversedEdges()
::StdMeshers_Reversible1D* StdMeshers_Reversible1D_i::GetImpl() ::StdMeshers_Reversible1D* StdMeshers_Reversible1D_i::GetImpl()
{ {
return ( ::StdMeshers_Reversible1D* )myHyp->GetImpl(); return static_cast<::StdMeshers_Reversible1D* >( myHyp->GetImpl() );
}
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_Reversible1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
const ::StdMeshers_Reversible1D* impl = ( const ::StdMeshers_Reversible1D* ) myHyp->GetImpl();
subIDArray = impl->GetReversedEdges();
entryArray.push_back( impl->GetObjectEntry() );
return true;
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_Reversible1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
std::vector< int > newIDs;
newIDs.reserve( subIDArray.size() );
for ( size_t i = 0; i < subIDArray.size(); ++i )
if ( subIDArray[ i ] > 0 )
newIDs.push_back( subIDArray[ i ]);
GetImpl()->SetReversedEdges( newIDs );
if ( !entryArray.empty() )
GetImpl()->SetObjectEntry( entryArray[0].c_str() );
return true;
} }

View File

@ -36,7 +36,7 @@
#include "StdMeshers_Reversible1D.hxx" #include "StdMeshers_Reversible1D.hxx"
// ====================================================== // ======================================================
// Common metrhods of Reversible 1D hypotheses // Common methods of Reversible 1D hypotheses
// ====================================================== // ======================================================
class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i: class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i:
public virtual POA_StdMeshers::Reversible1D public virtual POA_StdMeshers::Reversible1D
@ -59,8 +59,17 @@ class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i:
// Get implementation // Get implementation
::StdMeshers_Reversible1D* GetImpl(); ::StdMeshers_Reversible1D* GetImpl();
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
private: private:
SMESH_Hypothesis_i* myHyp; SMESH_Hypothesis_i* myHyp;
}; };
#endif #endif

View File

@ -63,6 +63,16 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };

View File

@ -49,7 +49,8 @@ using namespace std;
StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i( PortableServer::POA_ptr thePOA, StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl ) ::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ), : SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ) SMESH_Hypothesis_i( thePOA ),
StdMeshers_Reversible1D_i( this )
{ {
myBaseImpl = new ::StdMeshers_StartEndLength( theGenImpl->GetANewId(), myBaseImpl = new ::StdMeshers_StartEndLength( theGenImpl->GetANewId(),
theGenImpl ); theGenImpl );
@ -132,97 +133,6 @@ CORBA::Double StdMeshers_StartEndLength_i::GetLength( CORBA::Boolean theIsStart)
return this->GetImpl()->GetLength( theIsStart ); return this->GetImpl()->GetLength( theIsStart );
} }
//=============================================================================
/*!
* StdMeshers_StartEndLength_i::SetReversedEdges
*
* Set edges to reverse
*/
//=============================================================================
void StdMeshers_StartEndLength_i::SetReversedEdges( const SMESH::long_array& theIds )
{
ASSERT( myBaseImpl );
try {
std::vector<int> ids( theIds.length() );
CORBA::Long iEnd = theIds.length();
for ( CORBA::Long i = 0; i < iEnd; i++ )
ids[ i ] = theIds[ i ];
this->GetImpl()->SetReversedEdges( ids );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
// Update Python script
SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
}
//=============================================================================
/*!
* StdMeshers_StartEndLength_i::SetObjectEntry
*
* Set the Entry for the Main Object
*/
//=============================================================================
void StdMeshers_StartEndLength_i::SetObjectEntry( const char* theEntry )
{
ASSERT( myBaseImpl );
string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
try {
this->GetImpl()->SetObjectEntry( entry.c_str() );
// Update Python script
SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry.c_str() << "' )";
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
}
}
//=============================================================================
/*!
* StdMeshers_StartEndLength_i::GetObjectEntry
*
* Set the Entry for the Main Object
*/
//=============================================================================
char* StdMeshers_StartEndLength_i::GetObjectEntry()
{
ASSERT( myBaseImpl );
const char* entry;
try {
entry = this->GetImpl()->GetObjectEntry();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
}
return CORBA::string_dup( entry );
}
//=============================================================================
/*!
* StdMeshers_StartEndLength_i::GetReversedEdges
*
* Get reversed edges
*/
//=============================================================================
SMESH::long_array* StdMeshers_StartEndLength_i::GetReversedEdges()
{
ASSERT( myBaseImpl );
SMESH::long_array_var anArray = new SMESH::long_array;
std::vector<int> ids = this->GetImpl()->GetReversedEdges();
anArray->length( ids.size() );
for ( CORBA::ULong i = 0; i < ids.size(); i++)
anArray [ i ] = ids [ i ];
return anArray._retn();
}
//============================================================================= //=============================================================================
/*! /*!
* StdMeshers_StartEndLength_i::GetImpl * StdMeshers_StartEndLength_i::GetImpl
@ -261,3 +171,29 @@ std::string StdMeshers_StartEndLength_i::getMethodOfParameter(const int paramInd
{ {
return paramIndex == 0 ? "SetStartLength" : "SetEndLength"; return paramIndex == 0 ? "SetStartLength" : "SetEndLength";
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_StartEndLength_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_StartEndLength_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
}

View File

@ -34,7 +34,7 @@
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
#include "SMESH_Hypothesis_i.hxx" #include "StdMeshers_Reversible1D_i.hxx"
#include "StdMeshers_StartEndLength.hxx" #include "StdMeshers_StartEndLength.hxx"
class SMESH_Gen; class SMESH_Gen;
@ -44,7 +44,8 @@ class SMESH_Gen;
// ====================================================== // ======================================================
class STDMESHERS_I_EXPORT StdMeshers_StartEndLength_i: class STDMESHERS_I_EXPORT StdMeshers_StartEndLength_i:
public virtual POA_StdMeshers::StdMeshers_StartEndLength, public virtual POA_StdMeshers::StdMeshers_StartEndLength,
public virtual SMESH_Hypothesis_i public virtual SMESH_Hypothesis_i,
public virtual StdMeshers_Reversible1D_i
{ {
public: public:
// Constructor // Constructor
@ -73,17 +74,16 @@ public:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
//Set Reversed Edges
void SetReversedEdges( const SMESH::long_array& theIDs);
//Get Reversed Edges // Methods for copying mesh definition to other geometry
SMESH::long_array* GetReversedEdges();
//Set Object Entry // Return geometry this hypothesis depends on. Return false if there is no geometry parameter
void SetObjectEntry( const char* entry); virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
//Get Object Entry // Set new geometry instead of that returned by getObjectsDependOn()
char* GetObjectEntry(); virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;

View File

@ -235,13 +235,13 @@ throw ( SALOME::SALOME_Exception )
//================================================================================ //================================================================================
/*! /*!
* \brief Verify whether hypothesis supports given entity type * \brief Verify whether hypothesis supports given entity type
* \param type - dimension (see SMESH::Dimension enumeration) * \param type - dimension (see SMESH::Dimension enumeration)
* \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
* *
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/ */
//================================================================================ //================================================================================
CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type ) CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
{ {
@ -251,7 +251,7 @@ CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension ty
//================================================================================ //================================================================================
/*! /*!
* \brief Sets sub-mesh event listeners to clear sub-meshes of edges * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
* shrinked by viscous layers * shrinked by viscous layers
*/ */
//================================================================================ //================================================================================
@ -259,3 +259,43 @@ void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored()
{ {
GetImpl()->RestoreListeners(); GetImpl()->RestoreListeners();
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_ViscousLayers2D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
const ::StdMeshers_ViscousLayers2D* impl =
static_cast<const ::StdMeshers_ViscousLayers2D*>( myBaseImpl );
subIDArray = impl->GetBndShapes();
return true;
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_ViscousLayers2D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
std::vector< int > newIDs;
newIDs.reserve( subIDArray.size() );
for ( size_t i = 0; i < subIDArray.size(); ++i )
if ( subIDArray[ i ] > 0 )
newIDs.push_back( subIDArray[ i ]);
GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreEdges() );
return true;
}

View File

@ -73,6 +73,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers2D_i:
// Sets sub-mesh event listeners to clear sub-meshes of edges // Sets sub-mesh event listeners to clear sub-meshes of edges
// shrinked by viscous layers // shrinked by viscous layers
virtual void UpdateAsMeshesRestored(); virtual void UpdateAsMeshesRestored();
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
}; };
#endif #endif

View File

@ -295,3 +295,44 @@ std::string StdMeshers_ViscousLayers_i::getMethodOfParameter(const int paramInde
} }
return ""; return "";
} }
//================================================================================
/*!
* \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
*/
//================================================================================
bool
StdMeshers_ViscousLayers_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
{
const ::StdMeshers_ViscousLayers* impl =
static_cast<const ::StdMeshers_ViscousLayers*>( myBaseImpl );
subIDArray = impl->GetBndShapes();
return true;
}
//================================================================================
/*!
* \brief Set new geometry instead of that returned by getObjectsDependOn()
*/
//================================================================================
bool
StdMeshers_ViscousLayers_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
{
std::vector< int > newIDs;
newIDs.reserve( subIDArray.size() );
for ( size_t i = 0; i < subIDArray.size(); ++i )
if ( subIDArray[ i ] > 0 )
newIDs.push_back( subIDArray[ i ]);
GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreFaces() );
return true;
}

View File

@ -73,6 +73,15 @@ class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers_i:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const;
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray );
protected: protected:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
}; };