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:*
In the dialog:
+* select the mode of the operation.
* specify the part of mesh to copy:
* **Select whole mesh, sub-mesh or group** by mouse activating this checkbox; or
* 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**;
+* select the **New Geometry**;
* 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.
+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`.
in boolean toKeepIDs)
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.
* Union groups with the same name and type if
mesh_tree_hypo_quadratic.png
mesh_build_compound.png
copy_mesh.png
+ copy_mesh_with_geom.png
mesh_node_to_point.png
mesh_tree_mesh_partial.png
mesh_extractGroup.png
if ( !GetMeshDS()->IsUsedHypothesis( hyp ))
return;
- if (_callUp)
- _callUp->HypothesisModified();
+ if (_callUp && hyp)
+ _callUp->HypothesisModified( hyp->GetID() );
SMESH_Algo *algo;
const SMESH_HypoFilter* compatibleHypoKind;
struct TCallUp // callback from SMESH to SMESH_I level
{
virtual void RemoveGroup (const int theGroupID)=0;
- virtual void HypothesisModified ()=0;
+ virtual void HypothesisModified (int theHypID)=0;
virtual void Load ()=0;
virtual ~TCallUp() {}
};
*/
//=============================================================================
-const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn()
+const std::map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn()
{
if ( _dependenceAnalysed || !_father->HasShapeToMesh() )
return _mapDepend;
#include "SMESHGUI_CopyMeshDlg.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_Utils.h"
#include "SMESHGUI_VTKUtils.h"
-#include "SMESHGUI_MeshUtils.h"
-#include "SMESHGUI_IdValidator.h"
-#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
#include <SMDS_Mesh.hxx>
// SALOME GUI includes
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SALOME_ListIO.hxx>
#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_SelectionMgr.h>
-
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
#include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h>
-#include <SALOME_ListIO.hxx>
+#include <SalomeApp_Tools.h>
// SALOME KERNEL includes
+#include <SALOMEDSClient_Study.hxx>
#include <SALOMEDSClient_SObject.hxx>
// OCCT includes
myFilterDlg(0),
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);
setAttribute(Qt::WA_DeleteOnClose, true);
/***************************************************************/
ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this);
- QButtonGroup* GroupConstructors = new QButtonGroup(this);
+ GroupConstructors = new QButtonGroup(this);
QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
ConstructorsBoxLayout->setSpacing(SPACING);
ConstructorsBoxLayout->setMargin(MARGIN);
QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox);
- RadioButton1->setIcon(image);
+ RadioButton1->setIcon(image1);
GroupConstructors->addButton(RadioButton1, 0);
+ QRadioButton* RadioButton2= new QRadioButton(ConstructorsBox);
+ RadioButton2->setIcon(image2);
+ GroupConstructors->addButton(RadioButton2, 1);
ConstructorsBoxLayout->addWidget(RadioButton1);
+ ConstructorsBoxLayout->addWidget(RadioButton2);
RadioButton1->setChecked(true);
- GroupConstructors->addButton(RadioButton1, 0);
/***************************************************************/
GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
// CheckBox for copying groups
myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
- myCopyGroupsCheck->setChecked(false);
+ myCopyGroupsCheck->setChecked(true);
// CheckBox for keeping ids ( OBSOLETE )
myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments);
myKeepIdsCheck->setChecked(true);
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
GroupArgumentsLayout->addWidget(myTextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(myLineEditElements, 0, 1, 1, 5);
GroupArgumentsLayout->addWidget(myIdSourceCheck, 1, 0, 1, 6);
GroupArgumentsLayout->addWidget(meshNameLabel, 2, 0);
GroupArgumentsLayout->addWidget(myMeshNameEdit, 2, 1, 1, 5);
- GroupArgumentsLayout->addWidget(myCopyGroupsCheck, 3, 0, 1, 6);
- // GroupArgumentsLayout->addWidget(myKeepIdsCheck, 4, 0, 1, 6);
+ GroupArgumentsLayout->addWidget(myGeomLabel, 3, 0);
+ 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);
this, SLOT (onTextChange(const QString&)));
connect(myIdSourceCheck, SIGNAL(toggled(bool)),
this, SLOT (onSelectIdSource(bool)));
+ connect(GroupConstructors, SIGNAL(buttonClicked(int)),
+ this, SLOT (onConstructor(int)));
+
SelectionIntoArgument();
}
{
myBusy = false;
- myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
+ if ( !isWithGeomMode() )
+ myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
+
if ( ResetControls )
{
myLineEditElements->clear();
- //myElementsId = "";
myNbOkElements = 0;
buttonOk->setEnabled(false);
myMesh = SMESH::SMESH_Mesh::_nil();
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;
}
//=================================================================================
bool SMESHGUI_CopyMeshDlg::ClickOnApply()
{
- if (SMESHGUI::isStudyLocked())
+ if ( SMESHGUI::isStudyLocked() )
return false;
if( !isValid() )
return false;
QStringList anEntryList;
+ bool toShowObjects = isApplyAndClose();
try
{
SUIT_OverrideCursor aWaitCursor;
}
QByteArray meshName = myMeshNameEdit->text().toUtf8();
bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
+ bool toReuseHyps = ( myReuseHypCheck->isChecked() );
+ bool toCopyElems = ( myCopyElementsCheck->isChecked() );
bool toKeepIDs = ( myKeepIdsCheck->isChecked() );
SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
- SMESH::SMESH_Mesh_var newMesh =
- gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
- if( !newMesh->_is_nil() )
- if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
+ SMESH::SMESH_Mesh_var newMesh;
+ if ( isWithGeomMode() )
+ {
+ 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() );
+
+ if ( isWithGeomMode() )
+ SMESH::SetName( aSObject, meshName );
+ }
}
- catch (...) {
+ catch(const SALOME::SALOME_Exception & S_ex)
+ {
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
+ }
+ catch (...)
+ {
}
mySMESHGUI->updateObjBrowser(true);
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
- anApp->browseObjects( anEntryList, isApplyAndClose() );
+ anApp->browseObjects( anEntryList, toShowObjects );
Init(false);
mySelectedObject = SMESH::SMESH_IDSource::_nil();
myActor = 0;
QString aString = "";
- myLineEditElements->setText(aString);
myNbOkElements = 0;
buttonOk->setEnabled(false);
buttonApply->setEnabled(false);
myFilterBtn->setEnabled(false);
- // get selected mesh
+ // get selected mesh or geometry
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList);
int nbSel = aList.Extent();
return;
Handle(SALOME_InteractiveObject) IO = aList.First();
- mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
- if ( mySelectedObject->_is_nil() )
- return;
- myMesh = SMESH::GetMeshByIO(IO);
- if (myMesh->_is_nil())
- return;
+ SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(IO);
+ GEOM::GEOM_Object_var geom = SMESH::GetGeom(IO);
- myActor = SMESH::FindActorByEntry(IO->getEntry());
- if (!myActor)
- myActor = SMESH::FindActorByObject(myMesh);
+ 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;
- if (myIdSourceCheck->isChecked())
+ if (myIdSourceCheck->isChecked() || isWithGeomMode() )
{
SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
if ( aString.isEmpty() ) aString = " ";
myNbOkElements = aString.size();
myFilterBtn->setEnabled(true);
}
- myLineEditElements->setText( aString );
+
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);
buttonApply->setEnabled(ok);
//=======================================================================
void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
{
- if (toSelectMesh)
+ if ( isWithGeomMode() )
+ myTextLabelElements->setText(tr("SMESH_MESH"));
+ else if ( toSelectMesh )
myTextLabelElements->setText(tr("OBJECT_NAME"));
else
myTextLabelElements->setText(tr("ELEM_IDS"));
}
mySelectionMgr->clearFilters();
- mySelectionMgr->installFilter(myIdSourceFilter);
+ if ( !isWithGeomMode() )
+ mySelectionMgr->installFilter(myIdSourceFilter);
SMESH::SetPointRepresentation(false);
if (toSelectMesh) {
bool SMESHGUI_CopyMeshDlg::isValid()
{
- if ( myIdSourceCheck->isChecked() )
- return !mySelectedObject->_is_nil();
+ bool ok = false;
+ if ( myIdSourceCheck->isChecked() || isWithGeomMode() )
+ {
+ ok = ( !mySelectedObject->_is_nil() );
+ if ( isWithGeomMode() )
+ ok = ok && ( !myNewGeometry->_is_nil() );
+ }
+ else
+ {
+ ok = ( myNbOkElements > 0 );
+ }
+
+ return ok;
+}
- return myNbOkElements > 0;
+//=======================================================================
+//function : isWithGeomMode
+//purpose : Return true if the mode is "with geometry"
+//=======================================================================
+
+bool SMESHGUI_CopyMeshDlg::isWithGeomMode()
+{
+ return ( GroupConstructors->checkedId() == 1 );
}
//=================================================================================
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Gen)
class QCheckBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
+class QButtonGroup;
class SMESHGUI;
class SMESHGUI_IdValidator;
//=================================================================================
class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public QDialog
-{
+{
Q_OBJECT
-public:
+ public:
SMESHGUI_CopyMeshDlg( SMESHGUI* );
~SMESHGUI_CopyMeshDlg();
void Init( bool = true );
void enterEvent( QEvent* ); /* mouse enter the QWidget */
void keyPressEvent( QKeyEvent* );
- int GetConstructorId();
void setNewMeshName();
+ QString getErrorMsg( SMESH::string_array_var invalidEntries,
+ QStringList & entriesToBrowse );
bool isValid();
+ bool isWithGeomMode();
void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const;
bool myBusy;
SMESH::SMESH_Mesh_var myMesh;
+ GEOM::GEOM_Object_var myNewGeometry;
SMESH_Actor* myActor;
SUIT_SelectionFilter* myIdSourceFilter;
SMESH::SMESH_IDSource_var mySelectedObject;
+ QButtonGroup* GroupConstructors;
+
QGroupBox* ConstructorsBox;
QGroupBox* GroupArguments;
QGroupBox* GroupButtons;
QPushButton* buttonHelp;
QLabel* myTextLabelElements;
+ QLabel* myGeomLabel;
QLineEdit* myLineEditElements;
QLineEdit* myMeshNameEdit;
+ QLineEdit* myGeomNameEdit;
QCheckBox* myIdSourceCheck;
QCheckBox* myCopyGroupsCheck;
+ QCheckBox* myReuseHypCheck;
+ QCheckBox* myCopyElementsCheck;
QCheckBox* myKeepIdsCheck;
QPushButton* myFilterBtn;
void SelectionIntoArgument();
void DeactivateActiveDialog();
void ActivateThisDialog();
+ void onConstructor( int );
void onTextChange( const QString& );
void onSelectIdSource( bool );
void setFilters();
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 )
{
if (!smeshSO)
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 GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long );
if(MYDEBUG) MESSAGE("Loading client meshers plugin library ...");
#ifdef WIN32
#ifdef UNICODE
- LPTSTR path = new TCHAR[aClientLibName.length() + 1];
- path[aClientLibName.toWCharArray(path)] = '\0';
+ LPTSTR path = new TCHAR[aClientLibName.length() + 1];
+ path[aClientLibName.toWCharArray(path)] = '\0';
#else
- const char* path = aClientLibName.toUtf8().data();
+ QByteArray baPath = aClientLibName.toUtf8();
+ const char* path = baPath.data();
#endif
#else
- char* path = aClientLibName.toUtf8().data();
+ QByteArray baPath = aClientLibName.toUtf8();
+ char* path = baPath.data();
#endif
LibHandle libHandle = LoadLib( path );
if (!libHandle) {
myShapeByMeshOp( 0 ),
myToCreate( theToCreate ),
myIsMesh( theIsMesh ),
+ myIsInvalidSubMesh( false ),
myHypoSet( 0 )
{
if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
QStringList anEntryList;
if ( myToCreate && myIsMesh )
aResult = createMesh( aMess, anEntryList );
- if ( myToCreate && !myIsMesh )
+ if (( myToCreate && !myIsMesh ) || myIsInvalidSubMesh )
aResult = createSubMesh( aMess, anEntryList );
else if ( !myToCreate )
aResult = editMeshOrSubMesh( aMess );
try
{
myIsOnGeometry = true;
+ myIsInvalidSubMesh = false;
//Check geometry for mesh
QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
SMESH::SMESH_subMesh_var submeshVar =
SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
myIsMesh = submeshVar->_is_nil();
+ myIsInvalidSubMesh = ( !myIsMesh && submeshVar->GetId() < 1 );
myDlg->setTitile( myToCreate, myIsMesh );
myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !submeshVar->_is_nil() );
myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
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->adjustSize();
readMesh();
//================================================================================
/*!
* \brief Creates sub-mesh
- * \param theMess - Output parameter intended for returning error message
- * \param theEntryList - List of entries of published objects
- * \retval bool - TRUE if sub-mesh is created, FALSE otherwise
+ * \param theMess - Output parameter intended for returning error message
+ * \param theEntryList - List of entries of published objects
+ * \retval bool - TRUE if sub-mesh is created, FALSE otherwise
*
* Creates sub-mesh
*/
return false;
// 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::_narrow( _CAST( SObject,pMesh )->GetObject() );
- if (aMeshVar->_is_nil())
+ SMESH::EntryToInterface<SMESH::SMESH_Mesh>( myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ));
+ 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;
// GEOM shape of the main mesh
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
- 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() );
if ( aSubMeshSO ) {
SMESH::SetName( aSubMeshSO, aName.toUtf8().data() );
myHasConcurrentSubBefore = checkSubMeshConcurrency( aMeshVar, aSubMeshVar );
}
- // Get name of geometry object
- CORBA::String_var name = SMESH::GetGeomName( pObj );
- if ( name.in() )
- myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, name.in() );
+ if ( !myIsInvalidSubMesh )
+ {
+ // Get name of geometry object
+ 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
SMESHGUI_ShapeByMeshOp* myShapeByMeshOp;
bool myToCreate;
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 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 myObjHyps; //!< hypothesis assigned to the current
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)
{
if (!theMgr)
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
int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& );
<source>ICON_COPY_MESH</source>
<translation>copy_mesh.png</translation>
</message>
+ <message>
+ <source>ICON_COPY_MESH_WG</source>
+ <translation>copy_mesh_with_geom.png</translation>
+ </message>
<message>
<source>ICON_COMPUTE</source>
<translation>mesh_compute.png</translation>
<source>SMESH_HYPOTHESES</source>
<translation>Hypotheses</translation>
</message>
+ <message>
+ <source>SMESH_HYPOTHESIS</source>
+ <translation>Hypothesis</translation>
+ </message>
+ <message>
+ <source>SMESH_ALGORITHM</source>
+ <translation>Algorithm</translation>
+ </message>
<message>
<source>SMESH_HYP_1</source>
<translation>Algorithm misses a hypothesis</translation>
<source>NEW_NAME</source>
<translation>New Mesh Name</translation>
</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>
<name>SMESHGUI_MeasureDlg</name>
AddObject( mesh );
return;
}
- if( method == "CreateMeshesFromMED" ||
- method == "CreateMeshesFromSAUV"||
- method == "CreateMeshesFromCGNS" ||
- method == "CreateMeshesFromGMF" ) // command result is ( [mesh1,mesh2], status )
+ if ( method == "CreateMeshesFromMED" ||
+ method == "CreateMeshesFromSAUV"||
+ method == "CreateMeshesFromCGNS" ||
+ method == "CreateMeshesFromGMF" ) // command result is ( [mesh1,mesh2], status )
{
std::list< _pyID > meshIDs = theCommand->GetStudyEntries( theCommand->GetResultValue() );
std::list< _pyID >::iterator meshID = meshIDs.begin();
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()
if ( method == "CreateHypothesis" )
}
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;
+}
// Gets list of compatible hypotheses
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
#include "SMESH_PreMeshInfo.hxx"
#include "SMESH_PythonDump.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 CORBA_SERVER_HEADER(SMESH_Group)
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
+#include <GEOMImpl_Types.hxx>
#include <GEOM_Client.hxx>
#include <Basics_Utils.hxx>
#include <sstream>
#include <cstdio>
#include <cstdlib>
+#include <memory>
using namespace std;
using SMESH::TPythonDump;
// load plugin library
if(MYDEBUG) MESSAGE("Loading server meshers plugin library ...");
#ifdef WIN32
- #ifdef UNICODE
- const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName);
- #else
- const char* path = aPlatformLibName.c_str();
- #endif
+#ifdef UNICODE
+ const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName);
+#else
+ const char* path = aPlatformLibName.c_str();
+#endif
#else
- const char* path = aPlatformLibName.c_str();
+ const char* path = aPlatformLibName.c_str();
#endif
LibHandle libHandle = LoadLib( path );
#if defined(WIN32) && defined(UNICODE)
- delete path;
+ delete path;
#endif
if (!libHandle)
{
try {
// 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 );
if ( meshServant ) {
meshServant->Load();
meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
myLocMesh.GetMeshDS()->Modified();
UpdateIcons( theMesh );
+ HighLightInvalid( theMesh, /*isInvalid=*/!ok );
return ok;
}
}
const char* meshName,
CORBA::Boolean toCopyGroups,
CORBA::Boolean toKeepIDs)
+ throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh()
+ std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
// 1. Get source mesh
<< toCopyGroups << ", "
<< toKeepIDs << ")";
- delete pyDump; pyDump = 0; // allow dump in GetGroups()
+ pyDumpDeleter.reset(); // allow dump in GetGroups()
if ( nbNewGroups > 0 ) // dump created groups
SMESH::ListOfGroups_var groups = newMesh->GetGroups();
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.
SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
const char* meshName,
CORBA::Boolean toCopyGroups,
- CORBA::Boolean toKeepIDs);
+ CORBA::Boolean toKeepIDs)
+ throw ( SALOME::SALOME_Exception );
+
+ // 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
+ // Compute mesh on a shape
CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject )
throw ( SALOME::SALOME_Exception );
GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0);
void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
+ void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid);
bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp);
SMESH::SMESH_Mesh_ptr createMesh()
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 );
SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,
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
// (to support tree representation customization and drag-n-drop)
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
if ( theMesh->_is_nil() || theSubMesh->_is_nil() || theShapeObject->_is_nil() )
return SALOMEDS::SObject::_nil();
+ std::string newName( theName ? theName : "" );
+
SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theSubMesh );
if ( aSubMeshSO->_is_nil() )
{
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();
const int isEmpty = ( elemTypes->length() == 0 );
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() )
return aSubMeshSO._retn();
+
+ highLightInvalid( aSubMeshSO, false ); // now it is valid
}
- SetName( aSubMeshSO, theName, "SubMesh" );
+ SetName( aSubMeshSO, newName.c_str(), "SubMesh" );
// Add reference to theShapeObject
// Publish hypothesis
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 ]);
SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp );
AddHypothesisToShape( theMesh, theShapeObject, aHyp );
}
}
+//=======================================================================
+//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
//purpose :
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();
+}
// ==============
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 <<" )";
}
//================================================================================
#include <map>
#include <string>
+#include <vector>
class TCollection_AsciiString;
// Persistence
virtual char* SaveTo();
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:
if(MYDEBUG) MESSAGE( "createSubMesh" );
TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject);
::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();
_mapSubMesh [subMeshId] = mySubMesh;
else { nextId = 0; } // avoid "unused variable" warning
// to track changes of GEOM groups
- addGeomGroupData( theSubShapeObject, subMesh );
+ if ( subMeshId > 0 )
+ addGeomGroupData( theSubShapeObject, subMesh );
return subMesh._retn();
}
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();
if ( !S.IsNull() )
SMESH_Mesh_i* _mesh;
TCallUp_i(SMESH_Mesh_i* mesh):_mesh(mesh) {}
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(); }
};
}
*/
//================================================================================
-void SMESH_Mesh_i::onHypothesisModified()
+void SMESH_Mesh_i::onHypothesisModified(int theHypID)
{
if ( _preMeshInfo )
_preMeshInfo->ForgetOrLoad();
SMESH::SMESH_Mesh_var mesh = _this();
_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 );
+ }
+ }
}
//=============================================================================
const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
// return existing group objects
- void onHypothesisModified();
+ void onHypothesisModified(int theHypID);
// callback from _impl to forget not loaded mesh data (issue 0021208)
void checkMeshLoaded();
DumpArray( theList, *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)
{
// dump CoincidentFreeBorders as a list of lists, each enclosed list
TPythonDump&
operator<<(const SMESH::ListOfIDSources& theList);
+ TPythonDump&
+ operator<<(const SMESH::submesh_array& theList);
+
+ TPythonDump&
+ operator<<(const SMESH::ListOfHypothesis& theList);
+
TPythonDump&
operator<<(const SMESH::CoincidentFreeBorders& theCFB);
bool getSubMeshes(::SMESH_subMesh* theSubMesh,
TListOfSubMeshes& theSubMeshList)
{
+ if ( !theSubMesh )
+ return false; // "invalid sub-mesh" created by SMESH_Gen_i::CopyMeshWithGeom()
size_t size = theSubMeshList.size();
// check all child sub-meshes of one complexity,
SALOMEDS::TMPFile_var SeqFile;
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 );
+}
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
an instance of class :class:`Mesh`
"""
- if (isinstance( meshPart, Mesh )):
+ if isinstance( meshPart, Mesh ):
meshPart = meshPart.GetMesh()
mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
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 ):
"""
Return IDs of sub-shapes
Fill with 2D elements a hole defined by a SMESH.FreeBorder.
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
nodes must be the same. Use :meth:`FindFreeBorders` to get nodes of holes.
groupName (string): name of a group to add new faces
//=============================================================================
StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, gen)
+ :StdMeshers_Reversible1D(hypId, gen)
{
_begLength = 1.;
_endLength = 10.;
*/
//=============================================================================
-void StdMeshers_Arithmetic1D::SetReversedEdges( std::vector<int>& ids )
-{
- if ( ids != _edgeIDs ) {
- _edgeIDs = ids;
-
- NotifySubMeshesHypothesisModification();
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save)
{
int listSize = _edgeIDs.size();
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
#include "SMESH_StdMeshers.hxx"
+#include "StdMeshers_Reversible1D.hxx"
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
-#include <vector>
-
-class STDMESHERS_EXPORT StdMeshers_Arithmetic1D:
- public SMESH_Hypothesis
+class STDMESHERS_EXPORT StdMeshers_Arithmetic1D: public StdMeshers_Reversible1D
{
public:
StdMeshers_Arithmetic1D(int hypId, SMESH_Gen* gen);
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::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
protected:
double _begLength, _endLength;
- std::vector<int> _edgeIDs;
- std::string _objEntry;
};
#endif
*/
//=============================================================================
-StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId,
- SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, gen)
+StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, SMESH_Gen * gen)
+ :StdMeshers_Reversible1D(hypId, gen)
{
_name = "FixedPoints1D";
_param_algo_dim = 1;
NotifySubMeshesHypothesisModification();
}
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-void StdMeshers_FixedPoints1D::SetReversedEdges( std::vector<int>& ids )
-{
- if ( ids != _edgeIDs ) {
- _edgeIDs = ids;
-
- NotifySubMeshesHypothesisModification();
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
{
int listSize = _params.size();
#include "SMESH_StdMeshers.hxx"
+#include "StdMeshers_Reversible1D.hxx"
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include <vector>
-class STDMESHERS_EXPORT StdMeshers_FixedPoints1D:
- public SMESH_Hypothesis
+class STDMESHERS_EXPORT StdMeshers_FixedPoints1D: public StdMeshers_Reversible1D
{
public:
StdMeshers_FixedPoints1D(int hypId, SMESH_Gen* gen);
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::istream & LoadFrom(std::istream & load);
protected:
std::vector<double> _params;
std::vector<int> _nbsegs;
- std::vector<int> _edgeIDs;
- std::string _objEntry;
};
#endif
StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId,
SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, gen),
+ : StdMeshers_Reversible1D(hypId, gen),
_numberOfSegments(15),//issue 19923
_distrType(DT_Regular),
_scaleFactor(1.),
{
return (_numberOfSegments = dflts._nbSegments );
}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-void StdMeshers_NumberOfSegments::SetReversedEdges( std::vector<int>& ids )
-{
- if ( ids != _edgeIDs ) {
- _edgeIDs = ids;
-
- NotifySubMeshesHypothesisModification();
- }
-}
-
#ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
#define _SMESH_NUMBEROFSEGMENTS_HXX_
-#include "SMESH_StdMeshers.hxx"
-
+#include "StdMeshers_Reversible1D.hxx"
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
+
#include <vector>
/*!
* It provides parameters for subdivision an edge by various
* distribution types, considering the given number of resulting segments
*/
-class STDMESHERS_EXPORT StdMeshers_NumberOfSegments:
- public SMESH_Hypothesis
+class STDMESHERS_EXPORT StdMeshers_NumberOfSegments: public StdMeshers_Reversible1D
{
public:
StdMeshers_NumberOfSegments(int hypId, SMESH_Gen* gen);
int ConversionMode() const
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
* \param theMesh - the built mesh
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
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
int GetTriaVertex() const { return _triaVertexID; }
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);
StdMeshers_QuadType GetQuadType() const { return _quadType; }
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; }
*/
//=============================================================================
-StdMeshers_StartEndLength::StdMeshers_StartEndLength(int hypId,
- SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, gen)
+StdMeshers_StartEndLength::StdMeshers_StartEndLength( int hypId, SMESH_Gen* gen )
+ :StdMeshers_Reversible1D(hypId, gen)
{
_begLength = 1.;
_endLength = 10.;
*/
//=============================================================================
-void StdMeshers_StartEndLength::SetReversedEdges( std::vector<int>& ids )
-{
- if ( ids != _edgeIDs ) {
- _edgeIDs = ids;
-
- NotifySubMeshesHypothesisModification();
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
ostream & StdMeshers_StartEndLength::SaveTo(ostream & save)
{
int listSize = _edgeIDs.size();
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
#include "SMESH_StdMeshers.hxx"
+#include "StdMeshers_Reversible1D.hxx"
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include <vector>
-class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
+class STDMESHERS_EXPORT StdMeshers_StartEndLength: public StdMeshers_Reversible1D
{
public:
StdMeshers_StartEndLength(int hypId, SMESH_Gen * gen);
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::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
protected:
double _begLength, _endLength;
- std::vector<int> _edgeIDs;
- std::string _objEntry;
};
#endif
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/
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
StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ),
- SMESH_Hypothesis_i( thePOA )
+ SMESH_Hypothesis_i( thePOA ),
+ StdMeshers_Reversible1D_i( this )
{
myBaseImpl = new ::StdMeshers_Arithmetic1D( theGenImpl->GetANewId(),
theGenImpl );
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
{
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 );
+}
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
-#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_Reversible1D_i.hxx"
#include "StdMeshers_Arithmetic1D.hxx"
// ======================================================
// ======================================================
class STDMESHERS_I_EXPORT StdMeshers_Arithmetic1D_i:
public virtual POA_StdMeshers::StdMeshers_Arithmetic1D,
- public virtual SMESH_Hypothesis_i
+ public virtual SMESH_Hypothesis_i,
+ public virtual StdMeshers_Reversible1D_i
{
public:
// Constructor
// Get length
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
::StdMeshers_Arithmetic1D* GetImpl();
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
// Verify whether hypothesis supports given entity 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
// Verify whether hypothesis supports given entity 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
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl )
- : SALOME::GenericObj_i( thePOA ),
- SMESH_Hypothesis_i( thePOA )
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ StdMeshers_Reversible1D_i( this )
{
myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
theGenImpl);
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
*
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/
-//================================================================================
+//================================================================================
CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
{
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 );
+}
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
-#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_Reversible1D_i.hxx"
#include "StdMeshers_FixedPoints1D.hxx"
// ======================================================
// ======================================================
class STDMESHERS_I_EXPORT StdMeshers_FixedPoints1D_i:
public virtual POA_StdMeshers::StdMeshers_FixedPoints1D,
- public virtual SMESH_Hypothesis_i
+ public virtual SMESH_Hypothesis_i,
+ public virtual StdMeshers_Reversible1D_i
{
public:
// Constructor
// Returns list of numbers of segments
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
::StdMeshers_FixedPoints1D* GetImpl();
// Verify whether hypothesis supports given entity 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
//================================================================================
/*!
- * \brief Verify whether hypothesis supports given entity type
- * \param type - dimension (see SMESH::Dimension enumeration)
- * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
- *
+ * \brief Verify whether hypothesis supports given entity type
+ * \param type - dimension (see SMESH::Dimension enumeration)
+ * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
+ *
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/
-//================================================================================
+//================================================================================
CORBA::Boolean StdMeshers_Geometric1D_i::IsDimSupported(::SMESH::Dimension type)
{
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 );
+}
// Get implementation
::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
virtual void LoadFrom( const char* theStream );
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:
SMESH::string_array_var _groupEntries;
std::vector< std::string > _groupIDs;
virtual void LoadFrom( const char* theStream );
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:
SMESH::string_array_var _groupEntries;
std::vector< std::string > _groupIDs;
// Verify whether hypothesis supports given entity 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
virtual char* SaveTo();
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:
// restore myMethod2VarParams by parameters stored in an old study
virtual void setOldParameters (const char* theParameters);
// Verify whether hypothesis supports given entity 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
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
// Verify whether hypothesis supports given entity 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:
::StdMeshers_NotConformAllowed* _impl;
};
// Verify whether hypothesis supports given entity 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
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
#include <TCollection_AsciiString.hxx>
-using namespace std;
//=============================================================================
/*!
* StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl )
- : SALOME::GenericObj_i( thePOA ),
- SMESH_Hypothesis_i( thePOA )
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ StdMeshers_Reversible1D_i( this )
{
myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
theGenImpl );
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();
-}
-
//=============================================================================
/*!
*/
{
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 );
+}
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
-#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_Reversible1D_i.hxx"
#include "StdMeshers_NumberOfSegments.hxx"
// ======================================================
// ======================================================
class STDMESHERS_I_EXPORT StdMeshers_NumberOfSegments_i:
public virtual POA_StdMeshers::StdMeshers_NumberOfSegments,
- public virtual SMESH_Hypothesis_i
+ public virtual SMESH_Hypothesis_i,
+ public virtual StdMeshers_Reversible1D_i
{
public:
// Constructor
// Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type );
- //Set Reversed Edges
- void SetReversedEdges( const SMESH::long_array& theIDs);
- //Get Reversed Edges
- SMESH::long_array* GetReversedEdges();
+ // Methods for copying mesh definition to other geometry
- //Set Object Entry
- void SetObjectEntry( const char* entry);
-
- //Get Object Entry
- char* GetObjectEntry();
+ // 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
else
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;
+}
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
*/
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;
+}
virtual char* SaveTo();
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:
// 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
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;
+}
virtual char* SaveTo();
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:
// 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
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;
+}
virtual char* SaveTo();
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:
// 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
};
#endif
-
// Verify whether hypothesis supports given entity 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; }
};
// ======================================================
// Verify whether hypothesis supports given entity 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
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;
+}
virtual char* SaveTo();
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:
std::vector<std::string> myShapeEntries;
// Verify whether hypothesis supports given entity 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
// Verify whether hypothesis supports given entity 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
::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;
}
#include "StdMeshers_Reversible1D.hxx"
// ======================================================
-// Common metrhods of Reversible 1D hypotheses
+// Common methods of Reversible 1D hypotheses
// ======================================================
class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i:
public virtual POA_StdMeshers::Reversible1D
// Get implementation
::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:
SMESH_Hypothesis_i* myHyp;
};
-
#endif
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ),
- SMESH_Hypothesis_i( thePOA )
+ SMESH_Hypothesis_i( thePOA ),
+ StdMeshers_Reversible1D_i( this )
{
myBaseImpl = new ::StdMeshers_StartEndLength( theGenImpl->GetANewId(),
theGenImpl );
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
{
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 );
+}
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
-#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_Reversible1D_i.hxx"
#include "StdMeshers_StartEndLength.hxx"
class SMESH_Gen;
// ======================================================
class STDMESHERS_I_EXPORT StdMeshers_StartEndLength_i:
public virtual POA_StdMeshers::StdMeshers_StartEndLength,
- public virtual SMESH_Hypothesis_i
+ public virtual SMESH_Hypothesis_i,
+ public virtual StdMeshers_Reversible1D_i
{
public:
// Constructor
// Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type );
- //Set Reversed Edges
- void SetReversedEdges( const SMESH::long_array& theIDs);
- //Get Reversed Edges
- SMESH::long_array* GetReversedEdges();
+ // Methods for copying mesh definition to other geometry
- //Set Object Entry
- void SetObjectEntry( const char* entry);
+ // 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;
- //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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
//================================================================================
/*!
- * \brief Verify whether hypothesis supports given entity type
- * \param type - dimension (see SMESH::Dimension enumeration)
- * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
- *
+ * \brief Verify whether hypothesis supports given entity type
+ * \param type - dimension (see SMESH::Dimension enumeration)
+ * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
+ *
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/
-//================================================================================
+//================================================================================
CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
{
//================================================================================
/*!
* \brief Sets sub-mesh event listeners to clear sub-meshes of edges
- * shrinked by viscous layers
+ * shrinked by viscous layers
*/
//================================================================================
{
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;
+}
// Sets sub-mesh event listeners to clear sub-meshes of edges
// shrinked by viscous layers
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
}
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;
+}
// Verify whether hypothesis supports given entity 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:
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};