Salome HOME
23586: [EDF] HYDRO: Copy mesh to new geometry
authoreap <eap@opencascade.com>
Tue, 18 Sep 2018 14:36:18 +0000 (17:36 +0300)
committereap <eap@opencascade.com>
Tue, 18 Sep 2018 14:36:18 +0000 (17:36 +0300)
88 files changed:
doc/salome/gui/SMESH/input/copy_mesh.rst
idl/SMESH_Gen.idl
resources/CMakeLists.txt
resources/copy_mesh_with_geom.png [new file with mode: 0644]
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESH/SMESH_subMesh.cxx
src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx
src/SMESHGUI/SMESHGUI_CopyMeshDlg.h
src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx
src/SMESHGUI/SMESHGUI_GEOMGenUtils.h
src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESHGUI/SMESHGUI_MeshOp.h
src/SMESHGUI/SMESHGUI_Utils.cxx
src/SMESHGUI/SMESHGUI_Utils.h
src/SMESHGUI/SMESH_images.ts
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_Algo_i.cxx
src/SMESH_I/SMESH_Algo_i.hxx
src/SMESH_I/SMESH_DumpPython.cxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_I/SMESH_Group_i.cxx
src/SMESH_I/SMESH_Hypothesis_i.hxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/SMESH_I/SMESH_PythonDump.hxx
src/SMESH_I/SMESH_subMesh_i.cxx
src/SMESH_I/SMESH_subMesh_i.hxx
src/SMESH_SWIG/smeshBuilder.py
src/StdMeshers/StdMeshers_Arithmetic1D.cxx
src/StdMeshers/StdMeshers_Arithmetic1D.hxx
src/StdMeshers/StdMeshers_FixedPoints1D.cxx
src/StdMeshers/StdMeshers_FixedPoints1D.hxx
src/StdMeshers/StdMeshers_NumberOfSegments.cxx
src/StdMeshers/StdMeshers_NumberOfSegments.hxx
src/StdMeshers/StdMeshers_QuadrangleParams.hxx
src/StdMeshers/StdMeshers_Reversible1D.hxx
src/StdMeshers/StdMeshers_StartEndLength.cxx
src/StdMeshers/StdMeshers_StartEndLength.hxx
src/StdMeshers_I/StdMeshers_Adaptive1D_i.hxx
src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx
src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx
src/StdMeshers_I/StdMeshers_AutomaticLength_i.hxx
src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.hxx
src/StdMeshers_I/StdMeshers_Deflection1D_i.hxx
src/StdMeshers_I/StdMeshers_FixedPoints1D_i.cxx
src/StdMeshers_I/StdMeshers_FixedPoints1D_i.hxx
src/StdMeshers_I/StdMeshers_Geometric1D_i.cxx
src/StdMeshers_I/StdMeshers_Geometric1D_i.hxx
src/StdMeshers_I/StdMeshers_ImportSource1D_i.hxx
src/StdMeshers_I/StdMeshers_ImportSource2D_i.hxx
src/StdMeshers_I/StdMeshers_LayerDistribution2D_i.hxx
src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx
src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx
src/StdMeshers_I/StdMeshers_LocalLength_i.hxx
src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx
src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx
src/StdMeshers_I/StdMeshers_MaxLength_i.hxx
src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx
src/StdMeshers_I/StdMeshers_NumberOfLayers2D_i.hxx
src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx
src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx
src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx
src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx
src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx
src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx
src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx
src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx
src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx
src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx
src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx
src/StdMeshers_I/StdMeshers_Propagation_i.hxx
src/StdMeshers_I/StdMeshers_QuadrangleParams_i.cxx
src/StdMeshers_I/StdMeshers_QuadrangleParams_i.hxx
src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx
src/StdMeshers_I/StdMeshers_QuadraticMesh_i.hxx
src/StdMeshers_I/StdMeshers_Reversible1D_i.cxx
src/StdMeshers_I/StdMeshers_Reversible1D_i.hxx
src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.hxx
src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx
src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx
src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx
src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx
src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx
src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx

index 0f542df433ce84e0d56de14ad7329fb7a4d74cb3..501352a005d23fef222af46aa4553c570679b882 100644 (file)
@@ -4,17 +4,16 @@
 Copy Mesh
 *********
 
 Copy Mesh
 *********
 
-A mesh can be created by copying a part of or the whole other mesh.
+A mesh can be created by copying a part of or the whole other mesh. There are two modes of the operation:
 
 
-**To make a copy of a mesh:**
+* 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.
 
 
-From the contextual menu in the Object Browser of from the **Mesh** menu select **Copy Mesh** or click **"Copy Mesh"** button in the toolbar.
+*To make a copy of a mesh:*
 
 
-.. image:: ../images/copy_mesh_icon.png
-       :align: center
+.. |img| image:: ../images/copy_mesh_icon.png
 
 
-.. centered::
-       **"Copy Mesh" button**
+From the contextual menu in the Object Browser of from the **Mesh** menu select **Copy Mesh** or click *"Copy Mesh"* button |img| in the toolbar.
 
 The following dialog box will appear:
 
 
 The following dialog box will appear:
 
@@ -24,20 +23,25 @@ The following dialog box will appear:
 
 In the dialog:
 
 
 In the dialog:
 
-       * specify the part of mesh to copy:
+* 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
-               * choose mesh elements with the mouse in the 3D Viewer. It is possible to select a whole area with a mouse frame; or 
-               * input the **Source Element IDs** directly in this field. The selected elements will be highlighted in the viewer; 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` "Selection filter library" page.
+  * **Select whole mesh, sub-mesh or group** by mouse activating this checkbox; or
+  * choose mesh elements with the mouse in the 3D Viewer. It is possible to select a whole area with a mouse frame; or 
+  * input the **Source Element IDs** directly in this field. The selected elements will be highlighted in the viewer; 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**;
-       * specify the conditions of copying:
+* 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.
+* 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 :ref:`tui_copy_mesh`.
+**See Also** a sample script of :ref:`tui_copy_mesh`.
 
 
index dd0866f8a240579c824e61ceea0755e75a0217b6..6cb7fd72d95a88e77c2bed6a9029840d88304303 100644 (file)
@@ -275,6 +275,37 @@ module SMESH
                         in boolean        toKeepIDs)
       raises ( SALOME::SALOME_Exception );
 
                         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
     /*!
      * Concatenate the given meshes or groups into one mesh.
      * Union groups with the same name and type if
index ab8792bc1b435e9d6769d383b8ecc91280667a6e..3bd0b5e78d6c01ec5e02ecc511b1e75d7f9cc657 100755 (executable)
@@ -196,6 +196,7 @@ SET(SMESH_RESOURCES_FILES
   mesh_tree_hypo_quadratic.png
   mesh_build_compound.png
   copy_mesh.png
   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
   mesh_node_to_point.png
   mesh_tree_mesh_partial.png
   mesh_extractGroup.png
diff --git a/resources/copy_mesh_with_geom.png b/resources/copy_mesh_with_geom.png
new file mode 100644 (file)
index 0000000..87bfba8
Binary files /dev/null and b/resources/copy_mesh_with_geom.png differ
index 1dcdd53595ecb66ff5fa662adf984135cb596b6b..9b5411ab47855b7a591175aa800c7b4b95099dbc 100644 (file)
@@ -1196,8 +1196,8 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
   if ( !GetMeshDS()->IsUsedHypothesis( hyp ))
     return;
 
   if ( !GetMeshDS()->IsUsedHypothesis( hyp ))
     return;
 
-  if (_callUp)
-    _callUp->HypothesisModified();
+  if (_callUp && hyp)
+    _callUp->HypothesisModified( hyp->GetID() );
 
   SMESH_Algo *algo;
   const SMESH_HypoFilter* compatibleHypoKind;
 
   SMESH_Algo *algo;
   const SMESH_HypoFilter* compatibleHypoKind;
index 054616c5e361ec3833fe375d482a1bb211f33142..898e934abb8c13f6c29d7f2eb6e00dafdd16a528 100644 (file)
@@ -330,7 +330,7 @@ class SMESH_EXPORT SMESH_Mesh
   struct TCallUp // callback from SMESH to SMESH_I level
   {
     virtual void RemoveGroup (const int theGroupID)=0;
   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() {}
   };
     virtual void Load ()=0;
     virtual ~TCallUp() {}
   };
index e8a61f295e8675f80d042240b222e5d77b3c80f9..d470c5c6322def2a6a9b7949505cb12aa528b5b3 100644 (file)
@@ -365,7 +365,7 @@ int SMESH_subMesh::computeCost() const
  */
 //=============================================================================
 
  */
 //=============================================================================
 
-const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn()
+const std::map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn()
 {
   if ( _dependenceAnalysed || !_father->HasShapeToMesh() )
     return _mapDepend;
 {
   if ( _dependenceAnalysed || !_father->HasShapeToMesh() )
     return _mapDepend;
index 2f38c9a3f825cb0f7a26e0b2f9ac3033f6088ae5..1e6c7396cacbdceae2b285795a76beee41cfe443 100644 (file)
 #include "SMESHGUI_CopyMeshDlg.h"
 
 #include "SMESHGUI.h"
 #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_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 <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_Desktop.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_OverrideCursor.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 <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
-#include <SALOME_ListIO.hxx>
+#include <SalomeApp_Tools.h>
 
 // SALOME KERNEL includes
 
 // SALOME KERNEL includes
+#include <SALOMEDSClient_Study.hxx>
 #include <SALOMEDSClient_SObject.hxx>
 
 // OCCT includes
 #include <SALOMEDSClient_SObject.hxx>
 
 // OCCT includes
@@ -113,7 +115,8 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
     myFilterDlg(0),
     myIsApplyAndClose( false )
 {
     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);
 
   setModal(false);
   setAttribute(Qt::WA_DeleteOnClose, true);
@@ -126,18 +129,21 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
 
   /***************************************************************/
   ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this);
 
   /***************************************************************/
   ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this);
-  QButtonGroup* GroupConstructors = new QButtonGroup(this);
+  GroupConstructors = new QButtonGroup(this);
   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
   ConstructorsBoxLayout->setSpacing(SPACING);
   ConstructorsBoxLayout->setMargin(MARGIN);
 
   QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox);
   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);
   GroupConstructors->addButton(RadioButton1, 0);
+  QRadioButton* RadioButton2= new QRadioButton(ConstructorsBox);
+  RadioButton2->setIcon(image2);
+  GroupConstructors->addButton(RadioButton2, 1);
 
   ConstructorsBoxLayout->addWidget(RadioButton1);
 
   ConstructorsBoxLayout->addWidget(RadioButton1);
+  ConstructorsBoxLayout->addWidget(RadioButton2);
   RadioButton1->setChecked(true);
   RadioButton1->setChecked(true);
-  GroupConstructors->addButton(RadioButton1, 0);
 
   /***************************************************************/
   GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
 
   /***************************************************************/
   GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
@@ -164,13 +170,26 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
 
   // CheckBox for copying groups
   myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
 
   // 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();
 
 
   // 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);
   // layout
   GroupArgumentsLayout->addWidget(myTextLabelElements,  0, 0);
   GroupArgumentsLayout->addWidget(myLineEditElements,   0, 1, 1, 5);
@@ -178,8 +197,13 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
   GroupArgumentsLayout->addWidget(myIdSourceCheck,      1, 0, 1, 6);
   GroupArgumentsLayout->addWidget(meshNameLabel,        2, 0);
   GroupArgumentsLayout->addWidget(myMeshNameEdit,       2, 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);
 
   /***************************************************************/
   GroupButtons = new QGroupBox(this);
@@ -243,6 +267,9 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
           this,               SLOT  (onTextChange(const QString&)));
   connect(myIdSourceCheck,    SIGNAL(toggled(bool)),
           this,               SLOT  (onSelectIdSource(bool)));
           this,               SLOT  (onTextChange(const QString&)));
   connect(myIdSourceCheck,    SIGNAL(toggled(bool)),
           this,               SLOT  (onSelectIdSource(bool)));
+  connect(GroupConstructors,  SIGNAL(buttonClicked(int)),
+          this,               SLOT  (onConstructor(int)));
+
 
   SelectionIntoArgument();
 }
 
   SelectionIntoArgument();
 }
@@ -275,11 +302,12 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
 {
   myBusy = false;
 
 {
   myBusy = false;
 
-  myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
+  if ( !isWithGeomMode() )
+    myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
+
   if ( ResetControls )
   {
     myLineEditElements->clear();
   if ( ResetControls )
   {
     myLineEditElements->clear();
-    //myElementsId = "";
     myNbOkElements = 0;
 
     buttonOk->setEnabled(false);
     myNbOkElements = 0;
 
     buttonOk->setEnabled(false);
@@ -289,11 +317,99 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
     myMesh = SMESH::SMESH_Mesh::_nil();
 
     myIdSourceCheck->setChecked(true);
     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(Study) study = SMESH::GetActiveStudyDocument();
+    _PTR(SObject) so = study->FindObjectID( theInvalidEntries[i].in() );
+
+    int objType = SMESHGUI_Selection::type( theInvalidEntries[i].in(), study );
+    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;
 }
 
 //=================================================================================
 }
 
 //=================================================================================
@@ -310,6 +426,7 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
     return false;
 
   QStringList anEntryList;
     return false;
 
   QStringList anEntryList;
+  bool toShowObjects = isApplyAndClose();
   try
   {
     SUIT_OverrideCursor aWaitCursor;
   try
   {
     SUIT_OverrideCursor aWaitCursor;
@@ -333,16 +450,55 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
     }
     QByteArray meshName = myMeshNameEdit->text().toLatin1();
     bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
     }
     QByteArray meshName = myMeshNameEdit->text().toLatin1();
     bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
+    bool toReuseHyps  = ( myReuseHypCheck->isChecked() );
+    bool toCopyElems  = ( myCopyElementsCheck->isChecked() );
     bool toKeepIDs    = ( myKeepIdsCheck->isChecked() );
 
     SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
     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() );
         anEntryList.append( aSObject->GetID().c_str() );
+
+        if ( isWithGeomMode() )
+          SMESH::SetName( aSObject, meshName );
+      }
   }
   }
-  catch (...) {
+  catch(const SALOME::SALOME_Exception & S_ex)
+  {
+    SalomeApp_Tools::QtCatchCorbaException(S_ex);
+  }
+  catch (...)
+  {
   }
 
   mySMESHGUI->updateObjBrowser(true);
   }
 
   mySMESHGUI->updateObjBrowser(true);
@@ -350,7 +506,7 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
 
   if( LightApp_Application* anApp =
       dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
 
   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();
 
   Init(false);
   mySelectedObject = SMESH::SMESH_IDSource::_nil();
@@ -503,13 +659,12 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
   myActor = 0;
   QString aString = "";
 
   myActor = 0;
   QString aString = "";
 
-  myLineEditElements->setText(aString);
   myNbOkElements = 0;
   buttonOk->setEnabled(false);
   buttonApply->setEnabled(false);
   myFilterBtn->setEnabled(false);
 
   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();
   SALOME_ListIO aList;
   mySelectionMgr->selectedObjects(aList);
   int nbSel = aList.Extent();
@@ -517,19 +672,29 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
     return;
 
   Handle(SALOME_InteractiveObject) IO = aList.First();
     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 = " ";
   {
     SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
     if ( aString.isEmpty() ) aString = " ";
@@ -541,8 +706,23 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
     myNbOkElements = aString.size();
     myFilterBtn->setEnabled(true);
   }
     myNbOkElements = aString.size();
     myFilterBtn->setEnabled(true);
   }
-  myLineEditElements->setText( aString );
+
   bool ok = !aString.isEmpty();
   bool ok = !aString.isEmpty();
+  if ( !mesh->_is_nil() )
+  {
+    myLineEditElements->setText( aString );
+    if ( isWithGeomMode() )
+      myMeshNameEdit->setText( aString );
+  }
+  else if ( !geom->_is_nil() )
+  {
+    myGeomNameEdit->setText( aString );
+    ok = ok && !myLineEditElements->text().isEmpty();
+  }
+
+  if ( ok && isWithGeomMode() && !myMesh->_is_nil() )
+    ok = myMesh->HasShapeToMesh();
+
 
   buttonOk->setEnabled(ok);
   buttonApply->setEnabled(ok);
 
   buttonOk->setEnabled(ok);
   buttonApply->setEnabled(ok);
@@ -554,7 +734,9 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
 //=======================================================================
 void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
 {
 //=======================================================================
 void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
 {
-  if (toSelectMesh)
+  if ( isWithGeomMode() )
+    myTextLabelElements->setText(tr("SMESH_MESH"));
+  else if ( toSelectMesh )
     myTextLabelElements->setText(tr("OBJECT_NAME"));
   else
     myTextLabelElements->setText(tr("ELEM_IDS"));
     myTextLabelElements->setText(tr("OBJECT_NAME"));
   else
     myTextLabelElements->setText(tr("ELEM_IDS"));
@@ -564,7 +746,8 @@ void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
   }
 
   mySelectionMgr->clearFilters();
   }
 
   mySelectionMgr->clearFilters();
-  mySelectionMgr->installFilter(myIdSourceFilter);
+  if ( !isWithGeomMode() )
+    mySelectionMgr->installFilter(myIdSourceFilter);
   SMESH::SetPointRepresentation(false);
 
   if (toSelectMesh) {
   SMESH::SetPointRepresentation(false);
 
   if (toSelectMesh) {
@@ -592,10 +775,29 @@ void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
 
 bool SMESHGUI_CopyMeshDlg::isValid()
 {
 
 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 );
 }
 
 //=================================================================================
 }
 
 //=================================================================================
index fe4a8f1a9e275fb534dd59731c31abc97d002caf..2566e7aa66a6f0f7aa02dba05a372e5d01da0724 100644 (file)
 // IDL includes
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 // 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 QCheckBox;
 class QGroupBox;
 class QLabel;
 class QLineEdit;
 class QPushButton;
+class QButtonGroup;
 
 class SMESHGUI;
 class SMESHGUI_IdValidator;
 
 class SMESHGUI;
 class SMESHGUI_IdValidator;
@@ -56,10 +58,10 @@ class SUIT_SelectionFilter;
 //=================================================================================
 
 class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public QDialog
 //=================================================================================
 
 class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public QDialog
-{ 
+{
   Q_OBJECT
 
   Q_OBJECT
 
-public:
+ public:
   SMESHGUI_CopyMeshDlg( SMESHGUI* );
   ~SMESHGUI_CopyMeshDlg();
 
   SMESHGUI_CopyMeshDlg( SMESHGUI* );
   ~SMESHGUI_CopyMeshDlg();
 
@@ -67,10 +69,12 @@ private:
   void                   Init( bool = true );
   void                   enterEvent( QEvent* );           /* mouse enter the QWidget */
   void                   keyPressEvent( QKeyEvent* );
   void                   Init( bool = true );
   void                   enterEvent( QEvent* );           /* mouse enter the QWidget */
   void                   keyPressEvent( QKeyEvent* );
-  int                    GetConstructorId();
   void                   setNewMeshName();
   void                   setNewMeshName();
+  QString                getErrorMsg( SMESH::string_array_var invalidEntries,
+                                      QStringList &           entriesToBrowse );
 
   bool                   isValid();
 
   bool                   isValid();
+  bool                   isWithGeomMode();
 
   void                   setIsApplyAndClose( const bool theFlag );
   bool                   isApplyAndClose() const;
 
   void                   setIsApplyAndClose( const bool theFlag );
   bool                   isApplyAndClose() const;
@@ -84,11 +88,14 @@ private:
 
   bool                   myBusy;
   SMESH::SMESH_Mesh_var  myMesh;
 
   bool                   myBusy;
   SMESH::SMESH_Mesh_var  myMesh;
+  GEOM::GEOM_Object_var  myNewGeometry;
   SMESH_Actor*           myActor;
   SUIT_SelectionFilter*  myIdSourceFilter;
 
   SMESH::SMESH_IDSource_var mySelectedObject;
 
   SMESH_Actor*           myActor;
   SUIT_SelectionFilter*  myIdSourceFilter;
 
   SMESH::SMESH_IDSource_var mySelectedObject;
 
+  QButtonGroup*          GroupConstructors;
+
   QGroupBox*             ConstructorsBox;
   QGroupBox*             GroupArguments;
   QGroupBox*             GroupButtons;
   QGroupBox*             ConstructorsBox;
   QGroupBox*             GroupArguments;
   QGroupBox*             GroupButtons;
@@ -99,10 +106,14 @@ private:
   QPushButton*           buttonHelp;
 
   QLabel*                myTextLabelElements;
   QPushButton*           buttonHelp;
 
   QLabel*                myTextLabelElements;
+  QLabel*                myGeomLabel;
   QLineEdit*             myLineEditElements;
   QLineEdit*             myMeshNameEdit;
   QLineEdit*             myLineEditElements;
   QLineEdit*             myMeshNameEdit;
+  QLineEdit*             myGeomNameEdit;
   QCheckBox*             myIdSourceCheck;
   QCheckBox*             myCopyGroupsCheck;
   QCheckBox*             myIdSourceCheck;
   QCheckBox*             myCopyGroupsCheck;
+  QCheckBox*             myReuseHypCheck;
+  QCheckBox*             myCopyElementsCheck;
   QCheckBox*             myKeepIdsCheck;
 
   QPushButton*           myFilterBtn;
   QCheckBox*             myKeepIdsCheck;
 
   QPushButton*           myFilterBtn;
@@ -122,6 +133,7 @@ private slots:
   void                   SelectionIntoArgument();
   void                   DeactivateActiveDialog();
   void                   ActivateThisDialog();
   void                   SelectionIntoArgument();
   void                   DeactivateActiveDialog();
   void                   ActivateThisDialog();
+  void                   onConstructor( int );
   void                   onTextChange( const QString& );
   void                   onSelectIdSource( bool );
   void                   setFilters();
   void                   onTextChange( const QString& );
   void                   onSelectIdSource( bool );
   void                   setFilters();
index 974b54ff88e1b17e6cae96b89332c9a59d62bcaa..f10942d5dce0239f22fdccbf89d1bcb17fb26ef0 100644 (file)
@@ -115,6 +115,18 @@ namespace SMESH
     return aMeshShape;
   }
 
     return aMeshShape;
   }
 
+  GEOM::GEOM_Object_var GetGeom( Handle(SALOME_InteractiveObject) io )
+  {
+    GEOM::GEOM_Object_var go;
+    _PTR(Study) study = GetActiveStudyDocument();
+    if ( !io.IsNull() && io->hasEntry() && study )
+    {
+      _PTR(SObject) so = study->FindObjectID( io->getEntry() );
+      go = GetGeom( so );
+    }
+    return go._retn();
+  }
+
   SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO )
   {
     if (!smeshSO)
   SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO )
   {
     if (!smeshSO)
index f59609e07e126c88378898c065853758701f3ab7..33031215ca923c3bb368267a2cfbfb90ee4f29da 100644 (file)
@@ -51,6 +51,8 @@ namespace SMESH
 
   SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( _PTR(SObject) );
 
 
   SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( _PTR(SObject) );
 
+  SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( Handle(SALOME_InteractiveObject) io );
+
   SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO );
 
   SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long );
   SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO );
 
   SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long );
index d70e1a38991d1b721c36fda8c92f882ad9049e54..c5350a76d8b41afb3ac60a48ebafb36761b3c074 100644 (file)
@@ -92,6 +92,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
   myShapeByMeshOp( 0 ),
   myToCreate( theToCreate ),
   myIsMesh( theIsMesh ),
   myShapeByMeshOp( 0 ),
   myToCreate( theToCreate ),
   myIsMesh( theIsMesh ),
+  myIsInvalidSubMesh( false ),
   myHypoSet( 0 )
 {
   if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
   myHypoSet( 0 )
 {
   if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
@@ -152,7 +153,7 @@ bool SMESHGUI_MeshOp::onApply()
     QStringList anEntryList;
     if ( myToCreate && myIsMesh )
       aResult = createMesh( aMess, anEntryList );
     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 );
       aResult = createSubMesh( aMess, anEntryList );
     else if ( !myToCreate )
       aResult = editMeshOrSubMesh( aMess );
@@ -520,6 +521,7 @@ void SMESHGUI_MeshOp::selectionDone()
   try
   {
     myIsOnGeometry = true;
   try
   {
     myIsOnGeometry = true;
+    myIsInvalidSubMesh = false;
 
     //Check geometry for mesh
     QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
 
     //Check geometry for mesh
     QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
@@ -639,11 +641,21 @@ void SMESHGUI_MeshOp::selectionDone()
           SMESH::SMESH_subMesh_var submeshVar =
             SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
           myIsMesh = submeshVar->_is_nil();
           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->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();
           myDlg->updateGeometry();
           myDlg->adjustSize();
           readMesh();
@@ -1879,9 +1891,9 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
 //================================================================================
 /*!
  * \brief Creates sub-mesh
 //================================================================================
 /*!
  * \brief Creates sub-mesh
 * \param theMess - Output parameter intended for returning error message
 * \param 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
  */
  *
  * Creates sub-mesh
  */
@@ -1895,10 +1907,15 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
     return false;
 
   // get mesh object
     return false;
 
   // get mesh object
-  QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
-  _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
   SMESH::SMESH_Mesh_var aMeshVar =
   SMESH::SMESH_Mesh_var aMeshVar =
-    SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
+    SMESH::EntryToInterface<SMESH::SMESH_Mesh>( myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ));
+  if ( aMeshVar->_is_nil() && 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;
 
   if (aMeshVar->_is_nil())
     return false;
 
@@ -1975,8 +1992,14 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
 
   SUIT_OverrideCursor aWaitCursor;
 
 
   SUIT_OverrideCursor aWaitCursor;
 
+  QString aNameOrID = aName;
+  if ( myIsInvalidSubMesh )
+    // pass a sub-mesh entry to mesh->GetSubMesh() to replace the invalid sub-mesh
+    // by a valid one in an existing SO
+    aNameOrID = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
+
   // create sub-mesh
   // create sub-mesh
-  SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toLatin1().data() );
+  SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aNameOrID.toLatin1().data() );
   _PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() );
   if ( aSubMeshSO ) {
     SMESH::SetName( aSubMeshSO, aName.toLatin1().data() );
   _PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() );
   if ( aSubMeshSO ) {
     SMESH::SetName( aSubMeshSO, aName.toLatin1().data() );
@@ -2253,10 +2276,13 @@ void SMESHGUI_MeshOp::readMesh()
       myHasConcurrentSubBefore = checkSubMeshConcurrency( aMeshVar, aSubMeshVar );
     }
 
       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
   }
 
   // Get hypotheses and algorithms assigned to the mesh/sub-mesh
index 8ba4f8c40b81bbe152d7a6fc51de9d4286904124..48879d0f086d2516f9fbf8e503c672c28223a9c3 100644 (file)
@@ -153,8 +153,11 @@ private:
   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
   bool                           myToCreate;
   bool                           myIsMesh;
   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                           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
 
   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current
index 21f74593fbde626c20cdcba8a1061971d4209417..3c83225bc80b638eb7c7c0f1b258a3bbeaa76590 100644 (file)
@@ -246,6 +246,16 @@ namespace SMESH
     return app->orb()->string_to_object(theIOR.toLatin1().data());
   }
 
     return app->orb()->string_to_object(theIOR.toLatin1().data());
   }
 
+  CORBA::Object_var EntryToObject( const QString& theEntry )
+  {
+    if ( _PTR(Study) aStudy = GetActiveStudyDocument() )
+    {
+      _PTR(SObject) anObj = aStudy->FindObjectID( theEntry.toLatin1().data() );
+      return SObjectToObject(anObj);
+    }
+    return CORBA::Object::_nil();
+  }
+
   int GetNameOfSelectedIObjects(LightApp_SelectionMgr* theMgr, QString& theName)
   {
     if (!theMgr)
   int GetNameOfSelectedIObjects(LightApp_SelectionMgr* theMgr, QString& theName)
   {
     if (!theMgr)
index 5b2e0b89ba662fb1caa7aa102767b8e7f04a880c..8ca7a316a43eda24534a2101c6d602cc75ba5d4e 100644 (file)
@@ -160,6 +160,18 @@ SMESHGUI_EXPORT
       return TInterface::_nil();
     }
 
       return TInterface::_nil();
     }
 
+SMESHGUI_EXPORT
+  CORBA::Object_var EntryToObject( const QString& );
+
+  template<class TInterface> typename TInterface::_var_type
+    EntryToInterface( const QString& theEntry )
+    {
+      CORBA::Object_var anObj = EntryToObject( theEntry );
+      if ( !CORBA::is_nil( anObj ) )
+        return TInterface::_narrow( anObj );
+      return TInterface::_nil();
+    }
+
 SMESHGUI_EXPORT
   int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& );
 
 SMESHGUI_EXPORT
   int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& );
 
index 629c0d1073a24ff2e9e8b2b46d4d24dacf23af3a..9605001fb82f2c06be7a3c29ae1e6f69a0415da9 100644 (file)
             <source>ICON_COPY_MESH</source>
             <translation>copy_mesh.png</translation>
         </message>
             <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>
         <message>
             <source>ICON_COMPUTE</source>
             <translation>mesh_compute.png</translation>
index f36fa04c73407e4dfb3cdac33b23121bf1192587..ab98955dd5f3b9dd6f0953be3d09ca3b90d39a17 100644 (file)
@@ -1941,6 +1941,14 @@ add the exported data to its contents?</translation>
         <source>SMESH_HYPOTHESES</source>
         <translation>Hypotheses</translation>
     </message>
         <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>
     <message>
         <source>SMESH_HYP_1</source>
         <translation>Algorithm misses a hypothesis</translation>
@@ -8069,6 +8077,25 @@ as they are of improper type:
         <source>NEW_NAME</source>
         <translation>New Mesh Name</translation>
     </message>
         <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>
 </context>
 <context>
     <name>SMESHGUI_MeasureDlg</name>
index b0d415b411fb7525867e8c2d07889e59572b6b08..f5bc18e5bc9f487f1c306b68b0c5bd6075ffbb85 100644 (file)
@@ -999,10 +999,10 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
     AddObject( mesh );
     return;
   }
     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();
   {
     std::list< _pyID > meshIDs = theCommand->GetStudyEntries( theCommand->GetResultValue() );
     std::list< _pyID >::iterator meshID = meshIDs.begin();
@@ -1020,6 +1020,12 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
       theCommand->SetArg( 1, file );
     }
   }
       theCommand->SetArg( 1, file );
     }
   }
+  if ( method == "CopyMeshWithGeom" )
+  {
+    std::list< _pyID > entries = theCommand->GetStudyEntries( theCommand->GetResultValue() );
+    Handle(_pyMesh) mesh = new _pyMesh( theCommand, entries.front() );
+    AddObject( mesh );
+  }
 
   // CreateHypothesis()
   if ( method == "CreateHypothesis" )
 
   // CreateHypothesis()
   if ( method == "CreateHypothesis" )
index 5c0f6bb80a765d6605a573f1fa4b40eb0031cf77..65ef32adb27d5722b51f51450bbc071bcad5bc9b 100644 (file)
@@ -81,3 +81,27 @@ SMESH::ListOfHypothesisName* SMESH_Algo_i::GetCompatibleHypothesis()
   }
   return listOfHypothesis._retn();
 }
   }
   return listOfHypothesis._retn();
 }
+
+//================================================================================
+/*!
+ * Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool SMESH_Algo_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                       std::vector< int >         & subIDArray ) const
+{
+  return false;
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool SMESH_Algo_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                       std::vector< int >         & subIDArray )
+{
+  return true;
+}
index 667a8170060fe6f714861f86ae9259c2394f275d..febea9b72eb3efff4d44473a26580aa3ed5980d9 100644 (file)
@@ -53,6 +53,15 @@ public:
   
   // Gets list of compatible hypotheses
   SMESH::ListOfHypothesisName* GetCompatibleHypothesis();
   
   // 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
 };
 
 #endif
index f2eff5b288c083a20b89ed0d68b93fb90a3888fe..0656e1d71c8297f20b8ccd5ff31f738722d32240 100644 (file)
@@ -568,6 +568,16 @@ namespace SMESH
     DumpArray( theList, *this );
     return *this;
   }
     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& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
   {
     // dump CoincidentFreeBorders as a list of lists, each enclosed list
index ea45c41ce356f2b2070925e3f1c829db0c7f5353..2e3753f733f33d0e960e7e0bc5792686e84f16a7 100644 (file)
 #include "SMESH_PreMeshInfo.hxx"
 #include "SMESH_PythonDump.hxx"
 #include "SMESH_ControlsDef.hxx"
 #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 "SMESH_TryCatch.hxx" // to include after OCC headers!
 
 #include CORBA_SERVER_HEADER(SMESH_Group)
 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
 
 
 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
 
 
+#include <GEOMImpl_Types.hxx>
 #include <GEOM_Client.hxx>
 
 #include <Basics_Utils.hxx>
 #include <GEOM_Client.hxx>
 
 #include <Basics_Utils.hxx>
 #include <fstream>
 #include <cstdio>
 #include <cstdlib>
 #include <fstream>
 #include <cstdio>
 #include <cstdlib>
+#include <memory>
 
 using namespace std;
 using SMESH::TPythonDump;
 
 using namespace std;
 using SMESH::TPythonDump;
@@ -1939,7 +1944,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
 
   try {
     // get mesh servant
 
   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();
     ASSERT( meshServant );
     if ( meshServant ) {
       meshServant->Load();
@@ -1960,6 +1965,8 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
       bool ok = myGen.Compute( myLocMesh, myLocShape, how );
       meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
       myLocMesh.GetMeshDS()->Modified();
       bool ok = myGen.Compute( myLocMesh, myLocShape, how );
       meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
       myLocMesh.GetMeshDS()->Modified();
+      if ( ok )
+        HighLightInvalid( theMesh, /*isInvalid=*/false );
       return ok;
     }
   }
       return ok;
     }
   }
@@ -2725,10 +2732,12 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
                                             const char*               meshName,
                                             CORBA::Boolean            toCopyGroups,
                                             CORBA::Boolean            toKeepIDs)
                                             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()
 {
   Unexpect aCatch(SALOME_SalomeException);
 
   TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh()
+  std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
 
   // 1. Get source mesh
 
 
   // 1. Get source mesh
 
@@ -2931,7 +2940,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
           << toCopyGroups << ", "
           << toKeepIDs << ")";
 
           << 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();
 
   if ( nbNewGroups > 0 ) // dump created groups
     SMESH::ListOfGroups_var groups = newMesh->GetGroups();
@@ -2939,6 +2948,877 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
   return newMesh._retn();
 }
 
   return newMesh._retn();
 }
 
+
+namespace // utils for CopyMeshWithGeom()
+{
+  typedef std::map< std::string, std::string >             TStr2StrMap;
+  typedef std::map< std::string, std::set< std::string > > TStr2StrSetMap;
+
+  //================================================================================
+  /*!
+   * \brief Return a new sub-shape corresponding to an old one
+   */
+  //================================================================================
+
+  struct ShapeMapper
+  {
+    SMESH_Mesh_i* mySrcMesh_i;
+    SMESH_Mesh_i* myNewMesh_i;
+    SMESH_Gen_i*  myGen_i;
+    bool          myToPublish;
+    bool          myIsSameGeom;
+
+    TStr2StrMap   myOld2NewEntryMap; // map of study entries
+
+    bool                       myGIPMapDone;
+    GEOM::ListOfListOfLong_var myGIPMap; // filled by GetInPlaceMap()
+
+    // not directly relating to shape search
+    TStr2StrSetMap myInvalidMap; // blame shape -> invalid objects
+
+    //================================================================================
+    /*!
+     * \brief Constructor
+     */
+    ShapeMapper( SMESH_Mesh_i* srcMesh_i,
+                 SMESH_Mesh_i* newMesh_i,
+                 SMESH_Gen_i*  smeshGen_i )
+      : mySrcMesh_i( srcMesh_i ),
+        myNewMesh_i( newMesh_i ),
+        myGen_i    ( smeshGen_i ),
+        myToPublish( !smeshGen_i->GetCurrentStudy()->_is_nil() ),
+        myGIPMapDone( false )
+    {
+      // retrieve from the study shape mapping made thanks to
+      // "Set presentation parameters and sub-shapes from arguments" option
+
+      SALOMEDS::Study_var study = smeshGen_i->GetCurrentStudy();
+      GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
+      GEOM::GEOM_Object_var mainShapeOld = mySrcMesh_i->GetShapeToMesh();
+      SALOMEDS::SObject_wrap oldSO = myGen_i->ObjectToSObject( study, mainShapeOld );
+      SALOMEDS::SObject_wrap newSO = myGen_i->ObjectToSObject( study, 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() )));
+
+      GEOM::GEOM_Gen_var           geomGen = myGen_i->GetGeomEngine();
+      GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations( myGen_i->GetCurrentStudyID() );
+      GEOM::ListOfGO_var         subShapes = op->GetExistingSubObjects( mainShapeNew,
+                                                                        /*groupsOnly=*/false );
+      for ( CORBA::ULong i = 0; i < subShapes->length(); ++i )
+      {
+        newSO = myGen_i->ObjectToSObject( study, 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( myGen_i->GetCurrentStudyID() );
+              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(myGen_i->GetCurrentStudyID() );
+              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] )
+        {
+          SALOMEDS::Study_var study = myGen_i->GetCurrentStudy();
+          CORBA::String_var    name = oldShape->GetName();
+          SALOMEDS::SObject_wrap so = geomGen->AddInStudy( study, 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::Study_var study = myGen_i->GetCurrentStudy();
+      if ( !study->_is_nil() )
+      {
+        SALOMEDS::SObject_wrap so = study->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(myGen_i->GetCurrentStudyID() );
+        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)
+    {
+      SALOMEDS::Study_var study = myGen_i->GetCurrentStudy();
+      if ( study->_is_nil() )
+        return;
+      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 = study->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;
+  SALOMEDS::Study_var study = GetCurrentStudy();
+
+  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( study, 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( study, 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( study, 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( study, 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( study, 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( study, 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( study, 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( study, 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( study, newGroup ));
+        ok = false;
+      }
+      if ( !badEntries.empty() )
+        ok = false;
+
+    } // treat a group on filter
+
+    append( theNewGroups, newGroup );
+
+    // fill old2newGroupMap
+    SALOMEDS::SObject_wrap srcSO = ObjectToSObject( study, groups[i] );
+    SALOMEDS::SObject_wrap newSO = ObjectToSObject( study, 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( study, theNewMesh );
+  SALOMEDS::SObject_wrap soOld = ObjectToSObject( study, 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;
+}
+
 //================================================================================
 /*!
  *  SMESH_Gen_i::GetMEDVersion
 //================================================================================
 /*!
  *  SMESH_Gen_i::GetMEDVersion
index 7f3765e8da804950228a2ccc700adb6dda331a9a..2fef1c766a5a202501ec5a5792e2f795d41b84fc 100644 (file)
@@ -275,9 +275,24 @@ public:
   SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
                                  const char*               meshName,
                                  CORBA::Boolean            toCopyGroups,
   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 );
   CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh,
                           GEOM::GEOM_Object_ptr theShapeObject )
     throw ( SALOME::SALOME_Exception );
@@ -531,6 +546,7 @@ public:
                                       SMESH::SMESH_GroupBase_ptr theGroup,
                                       GEOM::GEOM_Object_ptr  theShapeObject,
                                       const char*            theName = 0);
                                       SMESH::SMESH_GroupBase_ptr theGroup,
                                       GEOM::GEOM_Object_ptr  theShapeObject,
                                       const char*            theName = 0);
+  void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid);
   bool AddHypothesisToShape(SALOMEDS::Study_ptr         theStudy,
                             SMESH::SMESH_Mesh_ptr       theMesh,
                             GEOM::GEOM_Object_ptr       theShapeObject,
   bool AddHypothesisToShape(SALOMEDS::Study_ptr         theStudy,
                             SMESH::SMESH_Mesh_ptr       theMesh,
                             GEOM::GEOM_Object_ptr       theShapeObject,
@@ -641,6 +657,14 @@ private:
   SMESH::SMESH_Mesh_ptr createMesh()
     throw ( SALOME::SALOME_Exception );
 
   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,
   static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
 
   SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,
index 6444617c7f744bba743461d5be8ec288fe33fe43..dacbf60909053c6a9505fe96e349cffdd1c523d4 100644 (file)
@@ -442,6 +442,9 @@ static void addReference (SALOMEDS::Study_ptr   theStudy,
 
     aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
 
 
     aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
 
+    // make the reference visible (invisible ref is created by createInvalidSubMesh())
+    aStudyBuilder->RemoveAttribute( aReferenceSO, "AttributeDrawable" );
+
     // add reference to the use case tree
     // (to support tree representation customization and drag-n-drop)
     SALOMEDS::UseCaseBuilder_wrap  useCaseBuilder = theStudy->GetUseCaseBuilder();
     // add reference to the use case tree
     // (to support tree representation customization and drag-n-drop)
     SALOMEDS::UseCaseBuilder_wrap  useCaseBuilder = theStudy->GetUseCaseBuilder();
@@ -648,7 +651,7 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SALOMEDS::Study_ptr   theStudy,
 
 //=======================================================================
 //function : PublishSubMesh
 
 //=======================================================================
 //function : PublishSubMesh
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theStudy,
 //=======================================================================
 
 SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theStudy,
@@ -661,6 +664,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theS
       theSubMesh->_is_nil() || theShapeObject->_is_nil() )
     return SALOMEDS::SObject::_nil();
 
       theSubMesh->_is_nil() || theShapeObject->_is_nil() )
     return SALOMEDS::SObject::_nil();
 
+  std::string newName( theName ? theName : "" );
+
   SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theStudy, theSubMesh );
   if ( aSubMeshSO->_is_nil() )
   {
   SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theStudy, theSubMesh );
   if ( aSubMeshSO->_is_nil() )
   {
@@ -712,15 +717,37 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theS
 
     SetName( aRootSO, aRootName );
 
 
     SetName( aRootSO, aRootName );
 
-    // Add new submesh to corresponding sub-tree
+    // Add new sub-mesh to corresponding sub-tree
+    int tag = 0; // to use a new SObject
+    if ( theName && theName[0] == '0' )
+    {
+      // theName can be an entry of an invalid sub-mesh which theSubMesh should replace
+      SALOMEDS::SObject_wrap aSObj = theStudy->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" };
     SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes();
     const int isEmpty = ( elemTypes->length() == 0 );
     const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" };
-    aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, pm[isEmpty] );
+    aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, tag, pm[isEmpty] );
     if ( aSubMeshSO->_is_nil() )
       return aSubMeshSO._retn();
     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
 
 
   // Add reference to theShapeObject
 
@@ -729,7 +756,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theS
   // Publish hypothesis
 
   SMESH::ListOfHypothesis_var hypList = theMesh->GetHypothesisList( 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( theStudy, aHyp );
     AddHypothesisToShape( theStudy, theMesh, theShapeObject, aHyp );
     SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]);
     SALOMEDS::SObject_wrap so = PublishHypothesis( theStudy, aHyp );
     AddHypothesisToShape( theStudy, theMesh, theShapeObject, aHyp );
@@ -860,6 +888,42 @@ SALOMEDS::SObject_ptr
   return aHypSO._retn();
 }
 
   return aHypSO._retn();
 }
 
+//=======================================================================
+//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( myCurrentStudy, 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 = myCurrentStudy->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  : 
 //=======================================================================
 //function : GetMeshOrSubmeshByShape
 //purpose  : 
@@ -1244,3 +1308,48 @@ char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject)
   }
   return aResult._retn();
 }
   }
   return aResult._retn();
 }
+
+//================================================================================
+/*!
+ * \brief Create a sub-mesh on a geometry that is not a sub-shape of the main shape
+ * for the case where a valid sub-shape not found by CopyMeshWithGeom().
+ * The invalid sub-mesh has GetId() < 0.
+ */
+//================================================================================
+
+SMESH::SMESH_subMesh_ptr
+SMESH_Gen_i::createInvalidSubMesh(SMESH::SMESH_Mesh_ptr theMesh,
+                                  GEOM::GEOM_Object_ptr theStrangerGeom,
+                                  const char*           theName)
+{
+  SMESH::SMESH_subMesh_var subMesh;
+
+  try
+  {
+    SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
+    subMesh = mesh_i->createSubMesh( theStrangerGeom );
+
+    if ( !subMesh->_is_nil() && CanPublishInStudy( subMesh ))
+    {
+      SALOMEDS::SObject_wrap so = PublishSubMesh( myCurrentStudy, 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 = myCurrentStudy->NewBuilder();
+          SALOMEDS::GenericAttribute_wrap attr =
+            studyBuilder->FindOrCreateAttribute( refSO, "AttributeDrawable" );
+          SALOMEDS::AttributeDrawable_wrap ga = attr;
+          ga->SetDrawable( false );
+        }
+      }
+    }
+  }
+  catch (...) {
+  }
+
+  return subMesh._retn();
+}
index d580262ded1d33b8a9dc214ee0e14d6ed3e21475..66210a00f5d972e15d9c58ce9684bb952fdd76fb 100644 (file)
@@ -839,7 +839,13 @@ void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter)
     Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
   }
 
     Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
   }
 
-  TPythonDump()<< SMESH::SMESH_GroupOnFilter_var(_this()) <<".SetFilter( "<<theFilter<<" )";
+  SMESH::SMESH_GroupOnFilter_var me = _this();
+
+  // mark the group valid after edition
+  GetMeshServant()->GetGen()->HighLightInvalid( me, false );
+
+
+  TPythonDump()<< me <<".SetFilter( "<< theFilter <<" )";
 }
 
 //================================================================================
 }
 
 //================================================================================
index 85f1d01964e6fe6d89d8ed771132247748d4f6a4..a294ac6a6e7c2a61c52c5cf9c815d593e0de9ff1 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <map>
 #include <string>
 
 #include <map>
 #include <string>
+#include <vector>
 
 class TCollection_AsciiString;
 
 
 class TCollection_AsciiString;
 
@@ -97,7 +98,18 @@ public:
   // Persistence
   virtual char* SaveTo();
   virtual void  LoadFrom( const char* theStream );
   // 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:
 
 
  protected:
 
index 2b11922915c2f77addce88e7b2b928751be0ccb2..377240df426cd20236dd060ad84729d808cc0020 100644 (file)
@@ -2453,9 +2453,25 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theS
   if(MYDEBUG) MESSAGE( "createSubMesh" );
   TopoDS_Shape  myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject);
   ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
   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;
   SMESH::SMESH_subMesh_var subMesh = subMeshServant->_this();
 
   _mapSubMesh   [subMeshId] = mySubMesh;
@@ -2470,7 +2486,8 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theS
   else        { nextId = 0; } // avoid "unused variable" warning
 
   // to track changes of GEOM groups
   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();
 }
 
   return subMesh._retn();
 }
@@ -2506,7 +2523,8 @@ bool SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh,
 
   if ( theSubShapeObject->_is_nil() )  // not published shape (IPAL13617)
   {
 
   if ( theSubShapeObject->_is_nil() )  // not published shape (IPAL13617)
   {
-    if ( _mapSubMesh.find( subMeshId ) != _mapSubMesh.end())
+    if ( _mapSubMesh.find( subMeshId ) != _mapSubMesh.end() &&
+         _mapSubMesh[ subMeshId ])
     {
       TopoDS_Shape S = _mapSubMesh[ subMeshId ]->GetSubShape();
       if ( !S.IsNull() )
     {
       TopoDS_Shape S = _mapSubMesh[ subMeshId ]->GetSubShape();
       if ( !S.IsNull() )
@@ -2739,7 +2757,7 @@ namespace
     SMESH_Mesh_i* _mesh;
     TCallUp_i(SMESH_Mesh_i* mesh):_mesh(mesh) {}
     virtual void RemoveGroup (const int theGroupID) { _mesh->removeGroup( theGroupID ); }
     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(); }
   };
 }
     virtual void Load ()                            { _mesh->Load(); }
   };
 }
@@ -2750,10 +2768,28 @@ namespace
  */
 //================================================================================
 
  */
 //================================================================================
 
-void SMESH_Mesh_i::onHypothesisModified()
+void SMESH_Mesh_i::onHypothesisModified(int theHypID)
 {
   if ( _preMeshInfo )
     _preMeshInfo->ForgetOrLoad();
 {
   if ( _preMeshInfo )
     _preMeshInfo->ForgetOrLoad();
+
+  // mark a hypothesis as valid after edition
+  SALOMEDS::Study_var           study = _gen_i->GetCurrentStudy();
+  SALOMEDS::SComponent_wrap smeshComp = _gen_i->PublishComponent( study );
+  SALOMEDS::SObject_wrap hypRoot;
+  if ( !smeshComp->_is_nil() &&
+       smeshComp->FindSubObject( _gen_i->GetHypothesisRootTag(), hypRoot.inout() ))
+  {
+    SALOMEDS::ChildIterator_wrap anIter = study->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 );
+    }
+  }
 }
 
 //=============================================================================
 }
 
 //=============================================================================
index 39fd2aa1cd12d618a8ef6534acdb21ca6784b293..ad8bc8e0e6c0ce034be5c9a0cd3c5a17c598114b 100644 (file)
@@ -444,7 +444,7 @@ public:
   const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
   // return existing group objects
 
   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();
   // callback from _impl to forget not loaded mesh data (issue 0021208)
 
   void checkMeshLoaded();
index b5977f56bedbfa736b8af839595d219dde4861d0..944ad307fba0c25337e39a264873cdcc389dae4c 100644 (file)
@@ -231,6 +231,12 @@ namespace SMESH
     TPythonDump&
     operator<<(const SMESH::ListOfIDSources& theList);
 
     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);
 
     TPythonDump&
     operator<<(const SMESH::CoincidentFreeBorders& theCFB);
 
index 48ed4a1341b4a358838be88de1bfb8d7a1f33f47..4cdac187903e5f7ed3ec1872e45c825747f3ffbd 100644 (file)
@@ -95,6 +95,8 @@ typedef list<SMESHDS_SubMesh*> TListOfSubMeshes;
 bool getSubMeshes(::SMESH_subMesh*  theSubMesh,
                   TListOfSubMeshes& theSubMeshList)
 {
 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,
   size_t size = theSubMeshList.size();
 
   // check all child sub-meshes of one complexity,
@@ -565,3 +567,30 @@ SALOMEDS::TMPFile* SMESH_subMesh_i::GetVtkUgStream()
   SALOMEDS::TMPFile_var SeqFile;
   return SeqFile._retn();
 }
   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 );
+}
index 1b295761c3d4ff336ebec3f3e943e17f60ab0bc6..01ebf261ebd216b54979fd38d2f9268d4d5b4efa 100644 (file)
@@ -130,4 +130,26 @@ protected:
   friend class SMESH_PreMeshInfo;
 };
 
   friend class SMESH_PreMeshInfo;
 };
 
+
+class SMESH_I_EXPORT SMESH_Invalid_subMesh_i:
+  public virtual POA_SMESH::SMESH_subMesh,
+  public virtual SALOME::GenericObj_i,
+  public virtual SMESH_subMesh_i
+{
+ public:
+  SMESH_Invalid_subMesh_i( PortableServer::POA_ptr thePOA,
+                           SMESH_Gen_i*            gen_i,
+                           SMESH_Mesh_i*           mesh_i,
+                           int                     localId,
+                           GEOM::GEOM_Object_ptr   shape);
+
+  virtual GEOM::GEOM_Object_ptr GetSubShape()
+    throw (SALOME::SALOME_Exception);
+
+ protected:
+
+  GEOM::GEOM_Object_var _geom;
+
+};
+
 #endif
 #endif
index 4a0c5816e66db2a18854dc0bf63eefae17f45824..657f3c73d76c22e088d2136f70f7fb7161d6f240 100644 (file)
@@ -689,11 +689,46 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
                an instance of Mesh class
        """
 
                an instance of Mesh class
        """
 
-        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)
 
             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
     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
        """
        Return IDs of sub-shapes
index 1dff2051523f9b99505cac09045bc8c84c922410..6ec48fe42e85e52ee0da827b0b6683abdf833292 100644 (file)
@@ -49,7 +49,7 @@ using namespace std;
 //=============================================================================
 
 StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen * gen)
 //=============================================================================
 
 StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen * gen)
-  :SMESH_Hypothesis(hypId, studyId, gen)
+  :StdMeshers_Reversible1D(hypId, studyId, gen)
 {
   _begLength = 1.;
   _endLength = 10.;
 {
   _begLength = 1.;
   _endLength = 10.;
@@ -105,21 +105,6 @@ double StdMeshers_Arithmetic1D::GetLength(bool isStartLength) const
  */
 //=============================================================================
 
  */
 //=============================================================================
 
-void StdMeshers_Arithmetic1D::SetReversedEdges( std::vector<int>& ids )
-{
-  if ( ids != _edgeIDs ) {
-    _edgeIDs = ids;
-
-    NotifySubMeshesHypothesisModification();
-  }
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
 ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save)
 {
   int listSize = _edgeIDs.size();
 ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save)
 {
   int listSize = _edgeIDs.size();
@@ -165,28 +150,6 @@ istream & StdMeshers_Arithmetic1D::LoadFrom(istream & load)
   return load;
 }
 
   return load;
 }
 
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-ostream & operator <<(ostream & save, StdMeshers_Arithmetic1D & hyp)
-{
-  return hyp.SaveTo( save );
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & operator >>(istream & load, StdMeshers_Arithmetic1D & hyp)
-{
-  return hyp.LoadFrom( load );
-}
-
 //================================================================================
 /*!
  * \brief Initialize start and end length by the mesh built on the geometry
 //================================================================================
 /*!
  * \brief Initialize start and end length by the mesh built on the geometry
index a95940dc4915e2479c0cc838565a7f8d88d482ac..619acf9b40458a173148872e5598acc6f03afef0 100644 (file)
 
 #include "SMESH_StdMeshers.hxx"
 
 
 #include "SMESH_StdMeshers.hxx"
 
+#include "StdMeshers_Reversible1D.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.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, int studyId, SMESH_Gen* gen);
 {
 public:
   StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen* gen);
@@ -48,18 +46,8 @@ public:
 
   double GetLength(bool isStartLength) const;
 
 
   double GetLength(bool isStartLength) const;
 
-  void SetReversedEdges( std::vector<int>& ids);
-
-  void SetObjectEntry( const char* entry ) { _objEntry = entry; }
-
-  const char* GetObjectEntry() { return _objEntry.c_str(); }
-
-  const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
-
   virtual std::ostream & SaveTo(std::ostream & save);
   virtual std::istream & LoadFrom(std::istream & load);
   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
 
   /*!
    * \brief Initialize start and end length by the mesh built on the geometry
@@ -77,8 +65,6 @@ public:
 
 protected:
   double _begLength, _endLength;
 
 protected:
   double _begLength, _endLength;
-  std::vector<int>   _edgeIDs;
-  std::string        _objEntry;
 };
 
 #endif
 };
 
 #endif
index 254df4e1c2063d538d047ed2a4094d914ba0c542..63e1527ebd26b84ded4a93dae945d93166ac837c 100644 (file)
@@ -37,7 +37,7 @@ using namespace std;
 
 StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, int studyId,
                                                    SMESH_Gen * gen)
 
 StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, int studyId,
                                                    SMESH_Gen * gen)
-  :SMESH_Hypothesis(hypId, studyId, gen)
+  :StdMeshers_Reversible1D(hypId, studyId, gen)
 {
   _name = "FixedPoints1D";
   _param_algo_dim = 1;
 {
   _name = "FixedPoints1D";
   _param_algo_dim = 1;
@@ -81,27 +81,6 @@ void StdMeshers_FixedPoints1D::SetNbSegments(std::vector<int>& listNbSeg)
   NotifySubMeshesHypothesisModification();
 }
 
   NotifySubMeshesHypothesisModification();
 }
 
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-void StdMeshers_FixedPoints1D::SetReversedEdges( std::vector<int>& ids )
-{
-  if ( ids != _edgeIDs ) {
-    _edgeIDs = ids;
-
-    NotifySubMeshesHypothesisModification();
-  }
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
 {
   int listSize = _params.size();
 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
 {
   int listSize = _params.size();
index 342b5c9d5316d4486763c3b856eea534c6a62ff8..3f5b3d3a827c0f07eceb64c55f2eff0c7f713e9a 100644 (file)
 
 #include "SMESH_StdMeshers.hxx"
 
 
 #include "SMESH_StdMeshers.hxx"
 
+#include "StdMeshers_Reversible1D.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
 #include <vector>
 
 #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, int studyId, SMESH_Gen* gen);
 {
 public:
   StdMeshers_FixedPoints1D(int hypId, int studyId, SMESH_Gen* gen);
@@ -51,14 +51,6 @@ public:
 
   const std::vector<int>& GetNbSegments() const { return _nbsegs; }
 
 
   const std::vector<int>& GetNbSegments() const { return _nbsegs; }
 
-  void SetReversedEdges( std::vector<int>& ids);
-
-  void SetObjectEntry( const char* entry ) { _objEntry = entry; }
-
-  const char* GetObjectEntry() { return _objEntry.c_str(); }
-
-  const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
-
   virtual std::ostream & SaveTo(std::ostream & save);
   virtual std::istream & LoadFrom(std::istream & load);
 
   virtual std::ostream & SaveTo(std::ostream & save);
   virtual std::istream & LoadFrom(std::istream & load);
 
@@ -79,8 +71,6 @@ public:
 protected:
   std::vector<double> _params;
   std::vector<int>    _nbsegs;
 protected:
   std::vector<double> _params;
   std::vector<int>    _nbsegs;
-  std::vector<int>    _edgeIDs;
-  std::string         _objEntry;
 };
 
 #endif
 };
 
 #endif
index fc8da4162a1618b2844191f981091f90394ce84c..7df5c0e72762c8464f896e22fba383ce26e74880 100644 (file)
@@ -61,7 +61,7 @@ const double PRECISION = 1e-7;
 StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int         hypId,
                                                          int         studyId,
                                                          SMESH_Gen * gen)
 StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int         hypId,
                                                          int         studyId,
                                                          SMESH_Gen * gen)
-  : SMESH_Hypothesis(hypId, studyId, gen),
+  : StdMeshers_Reversible1D(hypId, studyId, gen),
     _numberOfSegments(15),//issue 19923
     _distrType(DT_Regular),
     _scaleFactor(1.),
     _numberOfSegments(15),//issue 19923
     _distrType(DT_Regular),
     _scaleFactor(1.),
@@ -722,19 +722,3 @@ bool StdMeshers_NumberOfSegments::SetParametersByDefaults(const TDefaults&  dflt
 {
   return (_numberOfSegments = dflts._nbSegments );
 }
 {
   return (_numberOfSegments = dflts._nbSegments );
 }
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-void StdMeshers_NumberOfSegments::SetReversedEdges( std::vector<int>& ids )
-{
-  if ( ids != _edgeIDs ) {
-    _edgeIDs = ids;
-
-    NotifySubMeshesHypothesisModification();
-  }
-}
-
index a85308bbfae94d1708e586547b46992cfd458263..88640cd4bb679d7aa681b0ace0c23179c40be6b7 100644 (file)
 #ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
 #define _SMESH_NUMBEROFSEGMENTS_HXX_
 
 #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 "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
+
 #include <vector>
 
 /*!
 #include <vector>
 
 /*!
@@ -41,8 +41,7 @@
  * It provides parameters for subdivision an edge by various
  * distribution types, considering the given number of resulting segments
  */
  * 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, int studyId, SMESH_Gen* gen);
 {
 public:
   StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
@@ -171,14 +170,6 @@ public:
   int ConversionMode() const
     throw (SALOME_Exception);
 
   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
   /*!
    * \brief Initialize number of segments by the mesh built on the geometry
    * \param theMesh - the built mesh
@@ -205,8 +196,6 @@ protected:
   std::vector<double> _table, _distr;    //!< the table for DT_TabFunc, a sequence of pairs of numbers
   std::string         _func;             //!< the expression of the function for DT_ExprFunc
   int                 _convMode;         //!< flag of conversion mode: 0=exponent, 1=cut negative
   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
 };
 
 #endif
index 051ec58a23dca00f17441c1da24fdc4015872699..dd25afa60ee75f8ae5941866d0e823cd6968381c 100644 (file)
@@ -51,7 +51,7 @@ public:
   int GetTriaVertex() const { return _triaVertexID; }
 
   void SetObjectEntry (const char* entry) { _objEntry = entry; }
   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 SetQuadType (StdMeshers_QuadType type);
   StdMeshers_QuadType GetQuadType() const { return _quadType; }
index a856eddfad1e94e1199d72224f2e247514aaff5f..75164f8611433434dbb021ec5576cf6111220c6b 100644 (file)
@@ -44,7 +44,7 @@ public:
 
   void SetObjectEntry( const char* entry ) { _objEntry = entry; }
 
 
   void SetObjectEntry( const char* entry ) { _objEntry = entry; }
 
-  const char* GetObjectEntry() { return _objEntry.c_str(); }
+  const char* GetObjectEntry() const { return _objEntry.c_str(); }
 
   const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
 
 
   const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
 
index 51bb2cf92e91f443425f7c0d6b24ff547d3b4294..e35f80a9c62801ae5b9b7abe2ec64aa4c358a1f7 100644 (file)
@@ -50,7 +50,7 @@ using namespace std;
 StdMeshers_StartEndLength::StdMeshers_StartEndLength(int         hypId,
                                                      int         studyId,
                                                      SMESH_Gen * gen)
 StdMeshers_StartEndLength::StdMeshers_StartEndLength(int         hypId,
                                                      int         studyId,
                                                      SMESH_Gen * gen)
-     :SMESH_Hypothesis(hypId, studyId, gen)
+     :StdMeshers_Reversible1D(hypId, studyId, gen)
 {
   _begLength = 1.;
   _endLength = 10.;
 {
   _begLength = 1.;
   _endLength = 10.;
@@ -106,21 +106,6 @@ double StdMeshers_StartEndLength::GetLength(bool isStartLength) const
  */
 //=============================================================================
 
  */
 //=============================================================================
 
-void StdMeshers_StartEndLength::SetReversedEdges( std::vector<int>& ids )
-{
-  if ( ids != _edgeIDs ) {
-    _edgeIDs = ids;
-
-    NotifySubMeshesHypothesisModification();
-  }
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
 ostream & StdMeshers_StartEndLength::SaveTo(ostream & save)
 {
   int listSize = _edgeIDs.size();
 ostream & StdMeshers_StartEndLength::SaveTo(ostream & save)
 {
   int listSize = _edgeIDs.size();
@@ -167,28 +152,6 @@ istream & StdMeshers_StartEndLength::LoadFrom(istream & load)
   return load;
 }
 
   return load;
 }
 
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-ostream & operator <<(ostream & save, StdMeshers_StartEndLength & hyp)
-{
-  return hyp.SaveTo( save );
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp)
-{
-  return hyp.LoadFrom( load );
-}
-
 //================================================================================
 /*!
  * \brief Initialize start and end length by the mesh built on the geometry
 //================================================================================
 /*!
  * \brief Initialize start and end length by the mesh built on the geometry
index 12f5f3c9573124f62ed4a769286e047cc12fe278..ddb3332f2ce7f1f9edc49dbdb1b7eceb4e0b5b85 100644 (file)
 
 #include "SMESH_StdMeshers.hxx"
 
 
 #include "SMESH_StdMeshers.hxx"
 
+#include "StdMeshers_Reversible1D.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
 #include <vector>
 
 #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, int studyId, SMESH_Gen * gen);
 {
  public:
   StdMeshers_StartEndLength(int hypId, int studyId, SMESH_Gen * gen);
@@ -44,19 +45,8 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
 
   double GetLength(bool isStartLength) const;
 
 
   double GetLength(bool isStartLength) const;
 
-  void SetReversedEdges( std::vector<int>& ids);
-
-  const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
-
-  void SetObjectEntry( const char* entry ) { _objEntry = entry; }
-
-  const char* GetObjectEntry() { return _objEntry.c_str(); }
-  
   virtual std::ostream & SaveTo(std::ostream & save);
   virtual std::istream & LoadFrom(std::istream & load);
   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
 
   /*!
    * \brief Initialize start and end length by the mesh built on the geometry
@@ -74,8 +64,6 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
 
 protected:
   double _begLength, _endLength;
 
 protected:
   double _begLength, _endLength;
-  std::vector<int>   _edgeIDs;
-  std::string        _objEntry;
 };
 
 #endif
 };
 
 #endif
index 7aa2c1879f5d19dde43a28423ba6944330341a85..dc40861a2376a8b5c7ca68aebf5cc44643d17ea5 100644 (file)
@@ -84,6 +84,12 @@ class STDMESHERS_I_EXPORT StdMeshers_Adaptive1D_i:
    * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
    */
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
    * 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
 };
 
 #endif
index 824530ec2b2db20ede5d099baee0371fe5bae779..38113affed2dde153bc4a21b0517d852b1743fd6 100644 (file)
@@ -49,7 +49,8 @@ StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr th
                                                     int                     theStudyId,
                                                     ::SMESH_Gen*            theGenImpl )
      : SALOME::GenericObj_i( thePOA ), 
                                                     int                     theStudyId,
                                                     ::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(),
                                              theStudyId,
 {
   myBaseImpl = new ::StdMeshers_Arithmetic1D( theGenImpl->GetANewId(),
                                              theStudyId,
@@ -133,98 +134,6 @@ CORBA::Double StdMeshers_Arithmetic1D_i::GetLength( CORBA::Boolean theIsStart)
   return this->GetImpl()->GetLength( theIsStart );
 }
 
   return this->GetImpl()->GetLength( theIsStart );
 }
 
-//=============================================================================
-/*!
- *  StdMeshers_Arithmetic1D_i::SetReversedEdges
- *
- *  Set edges to reverse
- */
-//=============================================================================
-
-void StdMeshers_Arithmetic1D_i::SetReversedEdges( const SMESH::long_array& theIds )
-{
-  ASSERT( myBaseImpl );
-  try {
-    std::vector<int> ids( theIds.length() );
-    CORBA::Long iEnd = theIds.length();
-    for ( CORBA::Long i = 0; i < iEnd; i++ )
-      ids[ i ] = theIds[ i ];
-
-    this->GetImpl()->SetReversedEdges( ids );
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-
-  // Update Python script
-  SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_Arithmetic1D_i::SetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-void StdMeshers_Arithmetic1D_i::SetObjectEntry( const char* theEntry )
-{
-  ASSERT( myBaseImpl );
-  string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
-  try {
-    this->GetImpl()->SetObjectEntry( entry.c_str() );
-    // Update Python script
-    SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
-  }
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_Arithmetic1D_i::GetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-char* StdMeshers_Arithmetic1D_i::GetObjectEntry()
-{
-  ASSERT( myBaseImpl );
-  const char* entry;
-  try {
-    entry = this->GetImpl()->GetObjectEntry();
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-  return CORBA::string_dup( entry );
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_Arithmetic1D_i::GetReversedEdges
- *
- *  Get reversed edges
- */
-//=============================================================================
-
-SMESH::long_array* StdMeshers_Arithmetic1D_i::GetReversedEdges()
-{
-  ASSERT( myBaseImpl );
-  SMESH::long_array_var anArray = new SMESH::long_array;
-  std::vector<int> ids = this->GetImpl()->GetReversedEdges();
-  anArray->length( ids.size() );
-  for ( CORBA::ULong i = 0; i < ids.size(); i++)
-    anArray [ i ] = ids [ i ];
-
-  return anArray._retn();
-}
-
 //=============================================================================
 /*!
  *  StdMeshers_Arithmetic1D_i::GetImpl
 //=============================================================================
 /*!
  *  StdMeshers_Arithmetic1D_i::GetImpl
@@ -263,3 +172,30 @@ std::string StdMeshers_Arithmetic1D_i::getMethodOfParameter(const int paramIndex
 {
   return paramIndex == 0 ? "SetStartLength" : "SetEndLength";
 }
 {
   return paramIndex == 0 ? "SetStartLength" : "SetEndLength";
 }
+
+
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_Arithmetic1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                               std::vector< int >         & subIDArray ) const
+{
+  return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_Arithmetic1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                               std::vector< int >         & subIDArray )
+{
+  return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
+}
index 6dece73a47107afb933eed017ccdd8bdc5a71abd..28d2d77f3c1910ffd69e5d73028e5d17235d6cbe 100644 (file)
@@ -33,7 +33,7 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
-#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_Reversible1D_i.hxx"
 #include "StdMeshers_Arithmetic1D.hxx"
 
 // ======================================================
 #include "StdMeshers_Arithmetic1D.hxx"
 
 // ======================================================
@@ -41,7 +41,8 @@
 // ======================================================
 class STDMESHERS_I_EXPORT StdMeshers_Arithmetic1D_i:
   public virtual POA_StdMeshers::StdMeshers_Arithmetic1D,
 // ======================================================
 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
 {
 public:
   // Constructor
@@ -65,24 +66,23 @@ public:
   // Get length
   CORBA::Double GetLength(CORBA::Boolean theIsStart);
 
   // 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 );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index d883d1b0b269e39764c7008b4d992dcd28abe54b..011bb1f779b1f97c71a3f4a0534e08cb6bb2872f 100644 (file)
@@ -67,6 +67,12 @@ public:
   
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
   
   // 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
 };
 
 #endif
index fb1fc91b3839f5b4a947196bb67be0f59e75c158..5f9a9e5dfc18e840f76d96d416ff61fcd3ef3190 100644 (file)
@@ -142,6 +142,13 @@ class STDMESHERS_I_EXPORT StdMeshers_CartesianParameters3D_i:
 
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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
 };
 
 #endif
index 722da9b4231e6e9799cd26cdf1c6d48c8ebca64d..0c7036bb0cf725ee324e1fc8f75917f15c708f75 100644 (file)
@@ -66,6 +66,11 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index fbaa715c6aabe4e899d7c840f3bef6478480ed14..749dc1be3212bf354bc4cfb915fb566c305f6bc3 100644 (file)
@@ -46,8 +46,9 @@ using namespace std;
 StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA,
                                                         int                     theStudyId,
                                                         ::SMESH_Gen*            theGenImpl )
 StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA,
                                                         int                     theStudyId,
                                                         ::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(),
                                               theStudyId,
 {
   myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
                                               theStudyId,
@@ -158,98 +159,6 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
   return anArray._retn();
 }
 
   return anArray._retn();
 }
 
-//=============================================================================
-/*!
- *  StdMeshers_FixedPoints1D_i::SetReversedEdges
- *
- *  Set edges to reverse
- */
-//=============================================================================
-
-void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds )
-{
-  ASSERT( myBaseImpl );
-  try {
-    std::vector<int> ids( theIds.length() );
-    CORBA::Long iEnd = theIds.length();
-    for ( CORBA::Long i = 0; i < iEnd; i++ )
-      ids[ i ] = theIds[ i ];
-
-    this->GetImpl()->SetReversedEdges( ids );
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-
-  // Update Python script
-  SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_FixedPoints1D_i::SetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry )
-{
-  ASSERT( myBaseImpl );
-  string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
-  try {
-    this->GetImpl()->SetObjectEntry( entry.c_str() );
-    // Update Python script
-    SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
-  }
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_FixedPoints1D_i::GetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-char* StdMeshers_FixedPoints1D_i::GetObjectEntry()
-{
-  ASSERT( myBaseImpl );
-  const char* entry;
-  try {
-    entry = this->GetImpl()->GetObjectEntry();
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-  return CORBA::string_dup( entry );
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_FixedPoints1D_i::GetReversedEdges
- *
- *  Get reversed edges
- */
-//=============================================================================
-
-SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
-{
-  ASSERT( myBaseImpl );
-  SMESH::long_array_var anArray = new SMESH::long_array;
-  std::vector<int> ids = this->GetImpl()->GetReversedEdges();
-  anArray->length( ids.size() );
-  for ( CORBA::ULong i = 0; i < ids.size(); i++)
-    anArray [ i ] = ids [ i ];
-
-  return anArray._retn();
-}
-
 //=============================================================================
 /*!
  *  StdMeshers_FixedPoints1D_i::GetImpl
 //=============================================================================
 /*!
  *  StdMeshers_FixedPoints1D_i::GetImpl
@@ -271,9 +180,34 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
  * 
  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
  */
  * 
  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
  */
-//================================================================================  
+//================================================================================
 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
 {
   return type == SMESH::DIM_1D;
 }
 
 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 );
+}
index 37522382183b177195efaf8e40ac8e52c7d27df1..b5edc1ffeb7f608f57f07e38b669c5bedb8558fa 100644 (file)
@@ -30,7 +30,7 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
-#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_Reversible1D_i.hxx"
 #include "StdMeshers_FixedPoints1D.hxx"
 
 // ======================================================
 #include "StdMeshers_FixedPoints1D.hxx"
 
 // ======================================================
@@ -38,7 +38,8 @@
 // ======================================================
 class STDMESHERS_I_EXPORT StdMeshers_FixedPoints1D_i:
   public virtual POA_StdMeshers::StdMeshers_FixedPoints1D,
 // ======================================================
 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
 {
 public:
   // Constructor
@@ -63,23 +64,22 @@ public:
   // Returns list of numbers of segments
   SMESH::long_array* GetNbSegments();
     
   // 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 );
   // 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
 };
 
 #endif
index cd4d6ec0d37a242f204cd97424972bfbe0274bd3..e772ba3d575847a3c2620e4de189b2eab8191fd8 100644 (file)
@@ -129,15 +129,41 @@ CORBA::Double StdMeshers_Geometric1D_i::GetCommonRatio()
 
 //================================================================================
 /*!
 
 //================================================================================
 /*!
- * \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)
  */
  * 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;
 }
 
 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 );
+}
index 38f0b6d8d26db1331db4827657aaf3f93ee03f55..bdae86d8ffa1f128181e50f67d06ff489a2056e1 100644 (file)
@@ -60,6 +60,18 @@ class STDMESHERS_I_EXPORT StdMeshers_Geometric1D_i:
 
   // Get implementation
   ::StdMeshers_Geometric1D* GetImpl();
 
   // 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
 };
 
 #endif
index 517549d6a17758fe2fc8d4bec64268519182c60e..419e311e67a372a43a6e587e2cb6e89c6d2d732e 100644 (file)
@@ -65,6 +65,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ImportSource1D_i:
   virtual void  LoadFrom( const char* theStream );
   virtual void  UpdateAsMeshesRestored();
 
   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;
  private:
   SMESH::string_array_var _groupEntries;
   std::vector< std::string > _groupIDs;
index bfa0e81b36f7d57b55cc7031cf4a118a35845c0e..851701398ddac9b10dd291936feb7a1d18e7d9f9 100644 (file)
@@ -65,6 +65,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ImportSource2D_i:
   virtual void  LoadFrom( const char* theStream );
   virtual void  UpdateAsMeshesRestored();
 
   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;
  private:
   SMESH::string_array_var _groupEntries;
   std::vector< std::string > _groupIDs;
index e95c43317f41d469ba996d7ee985bfd4a4e7ddc6..08be2d3cb5ff3893a77e531789289d9fbe847889 100644 (file)
@@ -55,6 +55,17 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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
 };
 
 #endif
index 98947b7cffbfb521f15a2f20ca340dbd6fe493cd..aa4b443baa09278d0cd1a08d507805323547a725 100644 (file)
@@ -78,6 +78,17 @@ public:
   virtual char* SaveTo();
   virtual void  LoadFrom( const char* theStream );
 
   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);
 protected:
   // restore myMethod2VarParams by parameters stored in an old study
   virtual void setOldParameters (const char* theParameters);
index 5c88c7dfff3a92fca03046f6d0efeb6586024f84..4148180ebbfd84ea0cd318266c58e9469feed158 100644 (file)
@@ -67,6 +67,17 @@ public:
   
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
   
   // 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
 };
 
 #endif
index e3b30927e309e1bbe658ebdbc13a48f0347f3454..b160a107c7a16a8574ef24806ac9448fab69dc3e 100644 (file)
@@ -72,6 +72,17 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index 2e46ff056057328f4faf24cf60d7df5d795c9cc6..6a6dc305f300f9d67446ad7028995a4a2a504d4a 100644 (file)
@@ -64,6 +64,18 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index 876d8e2c44d208ede4c155e73334b9461b005e2a..d97aecb57041ddb89a2c95721c19f83c2ea22fc8 100644 (file)
@@ -64,6 +64,17 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index 4f888e1be3b2347001cf2f759bea1b7b20a0d093..4cc81ac4ba9d5b78d36890fa6b70d5ea5e805284 100644 (file)
@@ -78,6 +78,17 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index 2ee4a512dc61c65435b6e02cf7af9b7f8c17aeab..3f3135cd61df190af10cabead0b72a8b8eb4224c 100644 (file)
@@ -51,6 +51,17 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
 protected:
   ::StdMeshers_NotConformAllowed* _impl;
 };
index e9c9b22f8101240fef623ccb160fb26dc794875f..e97b5404c19b5edba287605b9ea6dd211bcfef95 100644 (file)
@@ -53,6 +53,17 @@ public:
   
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
   
   // 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
 };
 
 #endif
index b47b10e795ac9c6050d3894ca962b1b3272b577f..ac8822abd0a242d612a177b2cfc2108d6e18bf92 100644 (file)
@@ -69,6 +69,17 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index 5a75bf78e45a6b2e7bc3d38b2193532f83a50593..6c7d8a7df9ff9a2c188bc5596d3175e891f14321 100644 (file)
@@ -36,7 +36,6 @@
 
 #include <TCollection_AsciiString.hxx>
 
 
 #include <TCollection_AsciiString.hxx>
 
-using namespace std;
 //=============================================================================
 /*!
  *  StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
 //=============================================================================
 /*!
  *  StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
@@ -49,7 +48,8 @@ StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::PO
                                                     int                     theStudyId,
                                                     ::SMESH_Gen*            theGenImpl )
      : SALOME::GenericObj_i( thePOA ), 
                                                     int                     theStudyId,
                                                     ::SMESH_Gen*            theGenImpl )
      : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA )
+       SMESH_Hypothesis_i( thePOA ),
+       StdMeshers_Reversible1D_i( this )
 {
   myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
                                              theStudyId,
 {
   myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
                                              theStudyId,
@@ -161,100 +161,6 @@ CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
   return this->GetImpl()->GetNumberOfSegments();
 }
 
   return this->GetImpl()->GetNumberOfSegments();
 }
 
-//=============================================================================
-/*!
- *  StdMeshers_NumberOfSegments_i::SetReversedEdges
- *
- *  Set edges to reverse
- */
-//=============================================================================
-
-void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds )
-{
-  ASSERT( myBaseImpl );
-  try {
-    std::vector<int> ids( theIds.length() );
-    CORBA::Long iEnd = theIds.length();
-    for ( CORBA::Long i = 0; i < iEnd; i++ )
-      ids[ i ] = theIds[ i ];
-
-    this->GetImpl()->SetReversedEdges( ids );
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-
-  // Update Python script
-  SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_NumberOfSegments_i::SetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* theEntry )
-{
-  ASSERT( myBaseImpl );
-  string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
-  try {
-    this->GetImpl()->SetObjectEntry( entry.c_str() );
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-  // Update Python script
-  SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_NumberOfSegments_i::GetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-char* StdMeshers_NumberOfSegments_i::GetObjectEntry()
-{
-  ASSERT( myBaseImpl );
-
-  const char* entry;
-  try {
-    entry = this->GetImpl()->GetObjectEntry();
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-  return CORBA::string_dup( entry );
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_NumberOfSegments_i::GetReversedEdges
- *
- *  Get reversed edges
- */
-//=============================================================================
-
-SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges()
-{
-  ASSERT( myBaseImpl );
-  SMESH::long_array_var anArray = new SMESH::long_array;
-  std::vector<int> ids = this->GetImpl()->GetReversedEdges();
-  anArray->length( ids.size() );
-  for ( size_t i = 0; i < ids.size(); i++)
-    anArray [ i ] = ids [ i ];
-
-  return anArray._retn();
-}
-
 //=============================================================================
 /*!
  */
 //=============================================================================
 /*!
  */
@@ -499,3 +405,30 @@ std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramI
 {
   return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
 }
 {
   return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
 }
+
+
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_NumberOfSegments_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                   std::vector< int >         & subIDArray ) const
+{
+  return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_NumberOfSegments_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                   std::vector< int >         & subIDArray )
+{
+  return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
+}
index 05be9d24d88e0bca5888bb4c8db903ea7c72ec73..02afc0956be5ab5f256b9c205d5d43fd2bf57426 100644 (file)
@@ -35,7 +35,7 @@
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #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"
 
 // ======================================================
 #include "StdMeshers_NumberOfSegments.hxx"
 
 // ======================================================
@@ -43,7 +43,8 @@
 // ======================================================
 class STDMESHERS_I_EXPORT StdMeshers_NumberOfSegments_i:
   public virtual POA_StdMeshers::StdMeshers_NumberOfSegments,
 // ======================================================
 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
 {
 public:
   // Constructor
@@ -105,18 +106,16 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index 7ad64cee20dd2cf27951e8106619a2d25be2023b..cd4eaa825e177fe75f282aacf5dc87e9d68cbb87 100644 (file)
@@ -166,3 +166,26 @@ void StdMeshers_ObjRefUlils::SaveToStream( const std::string& studyEntry,
   else
     stream << " " << studyEntry;
 }
   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::Study_var study = gen->GetCurrentStudy();
+    if ( !study->_is_nil() )
+    {
+      SALOMEDS::SObject_wrap sobj = study->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;
+}
index ca30fd3d242e259d4289c750db4328036d7cc07a..7728c02b91ec58857b222703d565ab872c6e4788 100644 (file)
@@ -65,6 +65,13 @@ public:
        return TopoDS_Shape();
   }
 
        return TopoDS_Shape();
   }
 
+  /*!
+   * \brief Return TopoDS_Shape by a study entry
+   *  \param theEntry - study entry
+   *  \retval TopoDS_Shape - result TopoDS_Shape
+   */
+  static TopoDS_Shape EntryToShape(const std::string theEntry);
+
   /*!
    * \brief Return study entry of GEOM Object
    */
   /*!
    * \brief Return study entry of GEOM Object
    */
index 6067de55bd7116ce39f241a40dbdfb2cb1742a9d..2e17b43f2fc01adc2e96e8131fe6f349e397e8bb 100644 (file)
@@ -300,3 +300,46 @@ void StdMeshers_ProjectionSource1D_i::LoadFrom( const char* theStream )
     str >> myShapeEntries[ i ];
 }
 
     str >> myShapeEntries[ i ];
 }
 
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_ProjectionSource1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                     std::vector< int >         & subIDArray ) const
+{
+  for ( int i = 0; i < NB_SHAPES; ++i )
+    entryArray.push_back( myShapeEntries[ i ]);
+
+  return true;
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_ProjectionSource1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                     std::vector< int >         & subIDArray )
+{
+  TopoDS_Shape shapes[ NB_SHAPES ];
+  for ( int i = 0; i < NB_SHAPES; ++i )
+  {
+    myShapeEntries[ i ] = entryArray[ i ];
+    shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]);
+  }
+
+  try {
+    GetImpl()->SetSourceEdge       ( shapes[ SRC_EDGE ] );
+    GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX ],
+                                     shapes[ TGT_VERTEX ]);
+  }
+  catch (...) {
+    return false;
+  }
+  return true;
+}
index 2a818f201baebf77112db24eafc93f114215ad4d..7d49676d137a35ca86870e28ab1d7d2d50b81c3a 100644 (file)
@@ -110,6 +110,15 @@ public:
   virtual char* SaveTo();
   virtual void  LoadFrom( const char* theStream );
 
   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
 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
index 369cc29dfee7cdd46bb10df40e91c1501715443c..cf0ac1acd73864012ba26a010b96def56e7d360d 100644 (file)
@@ -313,3 +313,48 @@ void StdMeshers_ProjectionSource2D_i::LoadFrom( const char* theStream )
     str >> myShapeEntries[ i ];
 }
 
     str >> myShapeEntries[ i ];
 }
 
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_ProjectionSource2D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                     std::vector< int >         & subIDArray ) const
+{
+  for ( int i = 0; i < NB_SHAPES; ++i )
+    entryArray.push_back( myShapeEntries[ i ]);
+
+  return true;
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_ProjectionSource2D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                     std::vector< int >         & subIDArray )
+{
+  TopoDS_Shape shapes[ NB_SHAPES ];
+  for ( int i = 0; i < NB_SHAPES; ++i )
+  {
+    myShapeEntries[ i ] = entryArray[ i ];
+    shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]);
+  }
+
+  try {
+    GetImpl()->SetSourceFace       ( shapes[ SRC_FACE ] );
+    GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX1 ],
+                                     shapes[ SRC_VERTEX2 ],
+                                     shapes[ TGT_VERTEX1 ],
+                                     shapes[ TGT_VERTEX2 ]);
+  }
+  catch (...) {
+    return false;
+  }
+  return true;
+}
index eb929dc49a4b64d09ef18d3443dc755ee7ae2a13..659c3826523bffbe7ccf5705da5e1e8d451e581c 100644 (file)
@@ -114,6 +114,16 @@ public:
   virtual char* SaveTo();
   virtual void  LoadFrom( const char* theStream );
 
   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
 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
index 195fafc656e29e7d1f4f836369980cce6f16e28d..ddf75d85b5c1b2acb28c775e1de4ee4b0ca1665b 100644 (file)
@@ -314,3 +314,48 @@ void StdMeshers_ProjectionSource3D_i::LoadFrom( const char* theStream )
     str >> myShapeEntries[ i ];
 }
 
     str >> myShapeEntries[ i ];
 }
 
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_ProjectionSource3D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                     std::vector< int >         & subIDArray ) const
+{
+  for ( int i = 0; i < NB_SHAPES; ++i )
+    entryArray.push_back( myShapeEntries[ i ]);
+
+  return true;
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_ProjectionSource3D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                     std::vector< int >         & subIDArray )
+{
+  TopoDS_Shape shapes[ NB_SHAPES ];
+  for ( int i = 0; i < NB_SHAPES; ++i )
+  {
+    myShapeEntries[ i ] = entryArray[ i ];
+    shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]);
+  }
+
+  try {
+    GetImpl()->SetSource3DShape    ( shapes[ SRC_SHAPE3D ] );
+    GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX1 ],
+                                     shapes[ SRC_VERTEX2 ],
+                                     shapes[ TGT_VERTEX1 ],
+                                     shapes[ TGT_VERTEX2 ]);
+  }
+  catch (...) {
+    return false;
+  }
+  return true;
+}
index 69d658827ce9faba54a0dc8f64fc89db0f8373e3..3f979b181eede80408e1a49ed916047d6b8b93d1 100644 (file)
@@ -115,6 +115,17 @@ public:
   virtual char* SaveTo();
   virtual void  LoadFrom( const char* theStream );
 
   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
 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
@@ -125,4 +136,3 @@ private:
 };
 
 #endif
 };
 
 #endif
-
index 00e07de4ca24d47c24c99a37979110d0c547c2ff..8a1f510f89a2ac373fc8ccbe5be154308d87d0aa 100644 (file)
@@ -53,6 +53,12 @@ public:
   
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
   
   // 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; }
 };
 
 // ======================================================
 };
 
 // ======================================================
@@ -71,6 +77,12 @@ public:
   
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
   
   // 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
 };
 
 #endif
index 1681544faff61bd86766d6c4b0e51985b121377c..bb08720730e9911f10d81c5cfe26f40aae71e54e 100644 (file)
@@ -380,3 +380,54 @@ void StdMeshers_QuadrangleParams_i::LoadFrom( const char* theStream )
 
   myBaseImpl->LoadFrom( is );
 }
 
   myBaseImpl->LoadFrom( is );
 }
+
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_QuadrangleParams_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                   std::vector< int >         & subIDArray ) const
+{
+  const ::StdMeshers_QuadrangleParams* impl =
+    static_cast<const ::StdMeshers_QuadrangleParams*>( myBaseImpl );
+
+  subIDArray.push_back( impl->GetTriaVertex() );
+
+  entryArray.push_back( impl->GetObjectEntry() );
+  entryArray.insert( entryArray.end(), myShapeEntries.begin(), myShapeEntries.end() );
+
+  return true;
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_QuadrangleParams_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                   std::vector< int >         & subIDArray )
+{
+  if ( !subIDArray.empty() )
+    GetImpl()->SetTriaVertex( subIDArray[0] );
+
+  GetImpl()->SetObjectEntry( entryArray[0].c_str() );
+
+  myShapeEntries.assign( ++entryArray.begin(), entryArray.end() );
+
+  std::vector< TopoDS_Shape > shapes;
+  std::vector< gp_Pnt       > points;
+  this->GetImpl()->GetEnforcedNodes( shapes, points );
+
+  shapes.clear();
+  for ( size_t i = 0; i < myShapeEntries.size(); ++i )
+    shapes.push_back( StdMeshers_ObjRefUlils::EntryToShape( myShapeEntries[i] ));
+
+  this->GetImpl()->SetEnforcedNodes( shapes, points );
+
+  return true;
+}
index 12c209f409537388be870e10de151b7ecdcd63d5..e3898c65e056d4881e43c368f158e370cfe51782 100644 (file)
@@ -85,6 +85,16 @@ public:
   virtual char* SaveTo();
   virtual void  LoadFrom( const char* theStream );
 
   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;
  protected:
 
   std::vector<std::string> myShapeEntries;
index a60e976bd3675c8acf42a713165286f36c1debd0..7844859e5f3ff970765f7fcc6cc739990ecf1f26 100644 (file)
@@ -59,6 +59,12 @@ public:
   
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
   
   // 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
 };
 
 #endif
index 785934aef3237ece7cc0ea972d2b99dc20f9e036..abf6464825457755c4bd7122450513c82e04e10f 100644 (file)
@@ -60,6 +60,12 @@ public:
   
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
   
   // 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
 };
 
 #endif
index 2c3028601350657c2e731a0bf5ea6e15553d6aa7..16e18e86a932a8f490e3683fdea4f9f616a307c2 100644 (file)
@@ -139,5 +139,46 @@ SMESH::long_array* StdMeshers_Reversible1D_i::GetReversedEdges()
 
 ::StdMeshers_Reversible1D* StdMeshers_Reversible1D_i::GetImpl()
 {
 
 ::StdMeshers_Reversible1D* StdMeshers_Reversible1D_i::GetImpl()
 {
-  return ( ::StdMeshers_Reversible1D* )myHyp->GetImpl();
+  return static_cast<::StdMeshers_Reversible1D* >( myHyp->GetImpl() );
+}
+
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_Reversible1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                               std::vector< int >         & subIDArray ) const
+{
+  const ::StdMeshers_Reversible1D* impl = ( const ::StdMeshers_Reversible1D* ) myHyp->GetImpl();
+  subIDArray = impl->GetReversedEdges();
+  entryArray.push_back( impl->GetObjectEntry() );
+
+  return true;
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_Reversible1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                               std::vector< int >         & subIDArray )
+{
+  std::vector< int > newIDs;
+  newIDs.reserve( subIDArray.size() );
+
+  for ( size_t i = 0; i < subIDArray.size(); ++i )
+    if ( subIDArray[ i ] > 0 )
+      newIDs.push_back( subIDArray[ i ]);
+  GetImpl()->SetReversedEdges( newIDs );
+
+  if ( !entryArray.empty() )
+    GetImpl()->SetObjectEntry( entryArray[0].c_str() );
+
+  return true;
 }
 }
index d753c18152ae24d6e742f7353540f6be55066331..645d5a9f08bf767867f5bee4420ae3f6d2b62031 100644 (file)
@@ -36,7 +36,7 @@
 #include "StdMeshers_Reversible1D.hxx"
 
 // ======================================================
 #include "StdMeshers_Reversible1D.hxx"
 
 // ======================================================
-// Common metrhods of Reversible 1D hypotheses
+// Common methods of Reversible 1D hypotheses
 // ======================================================
 class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i:
   public virtual POA_StdMeshers::Reversible1D
 // ======================================================
 class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i:
   public virtual POA_StdMeshers::Reversible1D
@@ -59,8 +59,17 @@ class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i:
   // Get implementation
   ::StdMeshers_Reversible1D* GetImpl();
 
   // 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;
 };
  private:
   SMESH_Hypothesis_i* myHyp;
 };
-
 #endif
 #endif
index c61971f020bf4221fa95168077b40f0da27c7347..d64cddd885085613ef6d90f5ea660012bedc5954 100644 (file)
@@ -64,6 +64,16 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index 8d1edd67f317314a1eb74554bc5b9307f7f7ba75..180d813fefe6f1e3280b68874133ac1bdba9d4bd 100644 (file)
@@ -50,7 +50,8 @@ StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i( PortableServer::POA_pt
                                                          int                     theStudyId,
                                                          ::SMESH_Gen*            theGenImpl )
      : SALOME::GenericObj_i( thePOA ), 
                                                          int                     theStudyId,
                                                          ::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(),
                                                theStudyId,
 {
   myBaseImpl = new ::StdMeshers_StartEndLength( theGenImpl->GetANewId(),
                                                theStudyId,
@@ -134,97 +135,6 @@ CORBA::Double StdMeshers_StartEndLength_i::GetLength( CORBA::Boolean theIsStart)
   return this->GetImpl()->GetLength( theIsStart );
 }
 
   return this->GetImpl()->GetLength( theIsStart );
 }
 
-//=============================================================================
-/*!
- *  StdMeshers_StartEndLength_i::SetReversedEdges
- *
- *  Set edges to reverse
- */
-//=============================================================================
-
-void StdMeshers_StartEndLength_i::SetReversedEdges( const SMESH::long_array& theIds )
-{
-  ASSERT( myBaseImpl );
-  try {
-    std::vector<int> ids( theIds.length() );
-    CORBA::Long iEnd = theIds.length();
-    for ( CORBA::Long i = 0; i < iEnd; i++ )
-      ids[ i ] = theIds[ i ];
-
-    this->GetImpl()->SetReversedEdges( ids );
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-
-  // Update Python script
-  SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_StartEndLength_i::SetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-void StdMeshers_StartEndLength_i::SetObjectEntry( const char* theEntry )
-{
-  ASSERT( myBaseImpl );
-  string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
-  try {
-    this->GetImpl()->SetObjectEntry( entry.c_str() );
-    // Update Python script
-    SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry.c_str() << "' )";
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
-  }
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_StartEndLength_i::GetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-char* StdMeshers_StartEndLength_i::GetObjectEntry()
-{
-  ASSERT( myBaseImpl );
-  const char* entry;
-  try {
-    entry = this->GetImpl()->GetObjectEntry();
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
-  }
-  return CORBA::string_dup( entry );
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_StartEndLength_i::GetReversedEdges
- *
- *  Get reversed edges
- */
-//=============================================================================
-
-SMESH::long_array* StdMeshers_StartEndLength_i::GetReversedEdges()
-{
-  ASSERT( myBaseImpl );
-  SMESH::long_array_var anArray = new SMESH::long_array;
-  std::vector<int> ids = this->GetImpl()->GetReversedEdges();
-  anArray->length( ids.size() );
-  for ( CORBA::ULong i = 0; i < ids.size(); i++)
-    anArray [ i ] = ids [ i ];
-
-  return anArray._retn();
-}
-
 //=============================================================================
 /*!
  *  StdMeshers_StartEndLength_i::GetImpl
 //=============================================================================
 /*!
  *  StdMeshers_StartEndLength_i::GetImpl
@@ -263,3 +173,29 @@ std::string StdMeshers_StartEndLength_i::getMethodOfParameter(const int paramInd
 {
   return paramIndex == 0 ? "SetStartLength" : "SetEndLength";
 }
 {
   return paramIndex == 0 ? "SetStartLength" : "SetEndLength";
 }
+
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_StartEndLength_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                 std::vector< int >         & subIDArray ) const
+{
+  return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_StartEndLength_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                 std::vector< int >         & subIDArray )
+{
+   return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
+}
index 9a9f3a17ba431901ca259cae409d8d86508ee946..b663adfdd37b0cd42b3acd5d4308179ee000d858 100644 (file)
@@ -34,7 +34,7 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #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;
 #include "StdMeshers_StartEndLength.hxx"
 
 class SMESH_Gen;
@@ -44,7 +44,8 @@ class SMESH_Gen;
 // ======================================================
 class STDMESHERS_I_EXPORT StdMeshers_StartEndLength_i:
   public virtual POA_StdMeshers::StdMeshers_StartEndLength,
 // ======================================================
 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
 {
 public:
   // Constructor
@@ -74,17 +75,16 @@ public:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
index fb0bbbcfd0e1c470af5c4da19ebac8387cb6fd7d..d47e6bb66256e34b2319919dd73421057cf1ef4a 100644 (file)
@@ -237,13 +237,13 @@ throw ( SALOME::SALOME_Exception )
 
 //================================================================================
 /*!
 
 //================================================================================
 /*!
- * \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)
  */
  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
  */
-//================================================================================  
+//================================================================================
 
 CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
 {
 
 CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
 {
@@ -253,7 +253,7 @@ CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension ty
 //================================================================================
 /*!
  * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
 //================================================================================
 /*!
  * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
- * shrinked by viscous layers
+ *        shrinked by viscous layers
  */
 //================================================================================
 
  */
 //================================================================================
 
@@ -261,3 +261,43 @@ void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored()
 {
   GetImpl()->RestoreListeners();
 }
 {
   GetImpl()->RestoreListeners();
 }
+
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_ViscousLayers2D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                  std::vector< int >         & subIDArray ) const
+{
+  const ::StdMeshers_ViscousLayers2D* impl =
+    static_cast<const ::StdMeshers_ViscousLayers2D*>( myBaseImpl );
+
+  subIDArray = impl->GetBndShapes();
+
+  return true;
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_ViscousLayers2D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                  std::vector< int >         & subIDArray )
+{
+  std::vector< int > newIDs;
+  newIDs.reserve( subIDArray.size() );
+
+  for ( size_t i = 0; i < subIDArray.size(); ++i )
+    if ( subIDArray[ i ] > 0 )
+      newIDs.push_back( subIDArray[ i ]);
+
+  GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreEdges() );
+
+  return true;
+}
index e13d2a905feab851c116317e714ff4c56e23d470..da246b606f9b9bc26b78205b5f62efafd53d86bc 100644 (file)
@@ -74,6 +74,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers2D_i:
   // Sets sub-mesh event listeners to clear sub-meshes of edges
   // shrinked by viscous layers
   virtual void  UpdateAsMeshesRestored();
   // 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
 };
 
 #endif
index ee39c26da774a0b39ea405dacbd9725e1a9f0a43..85a36e6fca1ee3ff3bef4b2532c56be9791ba30f 100644 (file)
@@ -297,3 +297,44 @@ std::string StdMeshers_ViscousLayers_i::getMethodOfParameter(const int paramInde
   }
   return "";
 }
   }
   return "";
 }
+
+
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_ViscousLayers_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                std::vector< int >         & subIDArray ) const
+{
+  const ::StdMeshers_ViscousLayers* impl =
+    static_cast<const ::StdMeshers_ViscousLayers*>( myBaseImpl );
+
+  subIDArray = impl->GetBndShapes();
+
+  return true;
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_ViscousLayers_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                std::vector< int >         & subIDArray )
+{
+  std::vector< int > newIDs;
+  newIDs.reserve( subIDArray.size() );
+
+  for ( size_t i = 0; i < subIDArray.size(); ++i )
+    if ( subIDArray[ i ] > 0 )
+      newIDs.push_back( subIDArray[ i ]);
+
+  GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreFaces() );
+
+  return true;
+}
index fe6bef741f341fdda77c6cc919a61ef6f12df9c0..d085eb373d33f57250f6c4bc46b22682d75d98d5 100644 (file)
@@ -74,6 +74,15 @@ class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers_i:
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
   // 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;
 };
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };