Salome HOME
23586: [EDF] HYDRO: Copy mesh to new geometry
authoreap <eap@opencascade.com>
Mon, 17 Sep 2018 19:24:36 +0000 (22:24 +0300)
committereap <eap@opencascade.com>
Mon, 17 Sep 2018 19:24:36 +0000 (22:24 +0300)
90 files changed:
doc/salome/gui/SMESH/images/copy_mesh_dlg.png
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_HypothesesUtils.cxx
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_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.cxx
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 c959e680f6f20123999988deef191927db99fd4c..97ca1cac7ad153d74e006363744a9dbf17d377da 100644 (file)
Binary files a/doc/salome/gui/SMESH/images/copy_mesh_dlg.png and b/doc/salome/gui/SMESH/images/copy_mesh_dlg.png differ
index 7d49ed37bed274bd14f6ac998c84193c457e4994..501352a005d23fef222af46aa4553c570679b882 100644 (file)
@@ -4,7 +4,10 @@
 Copy Mesh
 *********
 
-A mesh can be created by copying a part of or the whole other mesh.
+A mesh can be created by copying a part of or the whole other mesh. There are two modes of the operation:
+
+* copy mesh elements only;
+* copy mesh definition to another geometry. This mode can be used only if the source mesh is based on geometry. It is supposed that the new geometry is a modified geometry of the source mesh.
 
 *To make a copy of a mesh:*
 
@@ -20,6 +23,7 @@ The following dialog box will appear:
 
 In the dialog:
 
+* select the mode of the operation.
 * specify the part of mesh to copy:
 
   * **Select whole mesh, sub-mesh or group** by mouse activating this checkbox; or
@@ -28,12 +32,16 @@ In the dialog:
   * apply Filters. **Set filter** button allows to apply a filter to the selection of elements. See more about filters in the :ref:`selection_filter_library_page` page.
 
 * specify the **New Mesh Name**;
+* select the **New Geometry**;
 * specify the conditions of copying:
 
-  * activate **Generate groups** checkbox to copy the groups of the source mesh to the newly created mesh.
+  * activate **Generate groups** check-box to copy the groups of the source mesh to the newly created mesh. In the mode of copying to new geometry, standalone groups are copied only if **Copy Mesh Elements** is activated.
+  * activate **Reuse hypotheses** check-box to use hypotheses applied to the source mesh in the new mesh. Hypotheses having parameters defined as sub-shapes will be copied independently of this check-box state.
+  * activate **Copy Mesh Element** to copy mesh elements of sub-shapes that are not modified.
 
 * Click **Apply** or **Apply and Close** button to confirm the operation.
 
+When copying the mesh to the new geometry, it can happen that a sub-shape used to define a sub-mesh, group or hypotheses is not found in the new geometry. In this case a new object depending on the not found sub-shape is marked with red color in the Object Browser in order to allow identifying such objects and to fix them, either by modifying their definition or by removing. If a depending object is a group on geometry, a standalone group is created instead. You can't transform it to a group on geometry, it can only be removed and re-created anew.
 
 **See Also** a sample script of :ref:`tui_copy_mesh`.
 
index 81e4a48cc1636577b28140beb3dbf56043cabd12..29158a831e0c3a8aea9b68785d53fdb4b53c2b98 100644 (file)
@@ -280,6 +280,37 @@ module SMESH
                         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
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
+  copy_mesh_with_geom.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 dcdb4f0ac8975d6b16f5f9c9b9e50890adc9be98..4ee7e09c02c5d00af265fd5b5a5d9670c2b98056 100644 (file)
@@ -1193,8 +1193,8 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
   if ( !GetMeshDS()->IsUsedHypothesis( hyp ))
     return;
 
-  if (_callUp)
-    _callUp->HypothesisModified();
+  if (_callUp && hyp)
+    _callUp->HypothesisModified( hyp->GetID() );
 
   SMESH_Algo *algo;
   const SMESH_HypoFilter* compatibleHypoKind;
index c52b5ef2ef8705b0e4f522fa205c9fdd73c9b10c..dbe14fed8203f849ea94426941ed3f5a530a8d98 100644 (file)
@@ -334,7 +334,7 @@ class SMESH_EXPORT SMESH_Mesh
   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() {}
   };
index 7bab8d9e74cba84dc539cbfe16bb52fe83383501..8ef0c8827cdd8c344487f1a042548a3ddbf3925d 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;
index 4dabf6c90cf4e2c0b825bc574e52af6764094233..b7794c02d8d3a5b62bee922f6238e6e99cb88db7 100644 (file)
 #include "SMESHGUI_CopyMeshDlg.h"
 
 #include "SMESHGUI.h"
+#include "SMESHGUI_FilterDlg.h"
+#include "SMESHGUI_GEOMGenUtils.h"
+#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_Selection.h"
 #include "SMESHGUI_SpinBox.h"
 #include "SMESHGUI_Utils.h"
 #include "SMESHGUI_VTKUtils.h"
-#include "SMESHGUI_MeshUtils.h"
-#include "SMESHGUI_IdValidator.h"
-#include "SMESHGUI_FilterDlg.h"
 
 #include <SMESH_Actor.h>
 #include <SMESH_TypeFilter.hxx>
 #include <SMDS_Mesh.hxx>
 
 // SALOME GUI includes
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SALOME_ListIO.hxx>
 #include <SUIT_Desktop.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_OverrideCursor.h>
-
-#include <LightApp_Application.h>
-#include <LightApp_SelectionMgr.h>
-
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
-#include <SALOME_ListIO.hxx>
+#include <SalomeApp_Tools.h>
 
 // SALOME KERNEL includes
+#include <SALOMEDSClient_Study.hxx>
 #include <SALOMEDSClient_SObject.hxx>
 
 // OCCT includes
@@ -113,7 +115,8 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
     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);
@@ -126,18 +129,21 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
 
   /***************************************************************/
   ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this);
-  QButtonGroup* GroupConstructors = new QButtonGroup(this);
+  GroupConstructors = new QButtonGroup(this);
   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
   ConstructorsBoxLayout->setSpacing(SPACING);
   ConstructorsBoxLayout->setMargin(MARGIN);
 
   QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox);
-  RadioButton1->setIcon(image);
+  RadioButton1->setIcon(image1);
   GroupConstructors->addButton(RadioButton1, 0);
+  QRadioButton* RadioButton2= new QRadioButton(ConstructorsBox);
+  RadioButton2->setIcon(image2);
+  GroupConstructors->addButton(RadioButton2, 1);
 
   ConstructorsBoxLayout->addWidget(RadioButton1);
+  ConstructorsBoxLayout->addWidget(RadioButton2);
   RadioButton1->setChecked(true);
-  GroupConstructors->addButton(RadioButton1, 0);
 
   /***************************************************************/
   GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
@@ -164,13 +170,26 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
 
   // CheckBox for copying groups
   myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
-  myCopyGroupsCheck->setChecked(false);
+  myCopyGroupsCheck->setChecked(true);
 
   // CheckBox for keeping ids ( OBSOLETE )
   myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments);
   myKeepIdsCheck->setChecked(true);
   myKeepIdsCheck->hide();
 
+  // New geometry
+  myGeomLabel = new QLabel( tr("NEW_GEOM"), GroupArguments );
+  myGeomNameEdit = new QLineEdit( GroupArguments );
+  myGeomNameEdit->setReadOnly(true);
+
+  // CheckBox to reuse hypotheses
+  myReuseHypCheck = new QCheckBox(tr("REUSE_HYPOTHESES"), GroupArguments);
+  myReuseHypCheck->setChecked(true);
+
+  // CheckBox to copy mesh elements
+  myCopyElementsCheck = new QCheckBox(tr("COPY_ELEMENTS"), GroupArguments);
+  myCopyElementsCheck->setChecked(true);
+
   // layout
   GroupArgumentsLayout->addWidget(myTextLabelElements,  0, 0);
   GroupArgumentsLayout->addWidget(myLineEditElements,   0, 1, 1, 5);
@@ -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(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);
@@ -243,6 +267,9 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
           this,               SLOT  (onTextChange(const QString&)));
   connect(myIdSourceCheck,    SIGNAL(toggled(bool)),
           this,               SLOT  (onSelectIdSource(bool)));
+  connect(GroupConstructors,  SIGNAL(buttonClicked(int)),
+          this,               SLOT  (onConstructor(int)));
+
 
   SelectionIntoArgument();
 }
@@ -275,11 +302,12 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
 {
   myBusy = false;
 
-  myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
+  if ( !isWithGeomMode() )
+    myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
+
   if ( ResetControls )
   {
     myLineEditElements->clear();
-    //myElementsId = "";
     myNbOkElements = 0;
 
     buttonOk->setEnabled(false);
@@ -289,11 +317,98 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
     myMesh = SMESH::SMESH_Mesh::_nil();
 
     myIdSourceCheck->setChecked(true);
-    myCopyGroupsCheck->setChecked(false);
-    myKeepIdsCheck->setChecked(false);
 
-    onSelectIdSource( myIdSourceCheck->isChecked() );
+    onConstructor( 0 );
+  }
+}
+
+//=======================================================================
+//function : onConstructor
+//purpose  : switch operation mode
+//=======================================================================
+
+void SMESHGUI_CopyMeshDlg::onConstructor( int withGeom )
+{
+  myGeomLabel        ->setVisible( withGeom );
+  myGeomNameEdit     ->setVisible( withGeom );
+  myReuseHypCheck    ->setVisible( withGeom );
+  myCopyElementsCheck->setVisible( withGeom );
+  myFilterBtn        ->setVisible( !withGeom );
+  myIdSourceCheck    ->setVisible( !withGeom );
+
+  if ( !withGeom )
+    myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
+
+  onSelectIdSource( /*toSelectMesh=*/ myIdSourceCheck->isChecked() || withGeom );
+}
+
+//=======================================================================
+//function : getErrorMsg
+//purpose  : Return an error message and entries of invalid smesh object
+//=======================================================================
+
+QString SMESHGUI_CopyMeshDlg::getErrorMsg( SMESH::string_array_var theInvalidEntries,
+                                           QStringList &           theEntriesToBrowse )
+{
+  if ( theInvalidEntries->length() == 0 )
+    return tr("SMESH_OPERATION_FAILED");
+
+  // theInvalidEntries - SObject's that hold geometry objects whose
+  // counterparts are not found in the newGeometry, followed by SObject's
+  // holding mesh sub-objects that are invalid because they depend on a not found
+  // preceeding sub-shape
+
+  QString msg = tr("SUBSHAPES_NOT_FOUND_MSG") + "\n";
+
+  QString objString;
+  for ( CORBA::ULong i = 0; i < theInvalidEntries->length(); ++i )
+  {
+    _PTR(SObject) so = SMESH::getStudy()->FindObjectID( theInvalidEntries[i].in() );
+
+    int objType = SMESHGUI_Selection::type( theInvalidEntries[i].in() );
+    if ( objType < 0 ) // geom object
+    {
+      objString += "\n";
+      if ( so )
+        objString += so->GetName().c_str();
+      else
+        objString += theInvalidEntries[i].in(); // it's something like "FACE #2"
+    }
+    else // smesh object
+    {
+      theEntriesToBrowse.push_back( theInvalidEntries[i].in() );
+
+      objString += "\n   ";
+      switch ( objType ) {
+      case SMESH::MESH:
+        objString += tr("SMESH_MESH"); break;
+      case SMESH::HYPOTHESIS:
+        objString += tr("SMESH_HYPOTHESIS"); break;
+      case SMESH::ALGORITHM:
+        objString += tr("SMESH_ALGORITHM"); break;
+      case SMESH::SUBMESH_VERTEX:
+      case SMESH::SUBMESH_EDGE:
+      case SMESH::SUBMESH_FACE:
+      case SMESH::SUBMESH_SOLID:
+      case SMESH::SUBMESH_COMPOUND:
+      case SMESH::SUBMESH:
+        objString += tr("SMESH_SUBMESH"); break;
+      case SMESH::GROUP:
+        objString += tr("SMESH_GROUP"); break;
+      default:;
+      }
+      objString += " \"";
+      if ( so )
+        objString += so->GetName().c_str();
+      objString += "\" (";
+      objString += theInvalidEntries[i].in();
+      objString += ")";
+    }
   }
+  if ( !objString.isEmpty() )
+    msg += objString;
+
+  return msg;
 }
 
 //=================================================================================
@@ -303,13 +418,14 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
 
 bool SMESHGUI_CopyMeshDlg::ClickOnApply()
 {
-  if (SMESHGUI::isStudyLocked())
+  if ( SMESHGUI::isStudyLocked() )
     return false;
 
   if( !isValid() )
     return false;
 
   QStringList anEntryList;
+  bool toShowObjects = isApplyAndClose();
   try
   {
     SUIT_OverrideCursor aWaitCursor;
@@ -333,16 +449,55 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
     }
     QByteArray meshName = myMeshNameEdit->text().toUtf8();
     bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
+    bool toReuseHyps  = ( myReuseHypCheck->isChecked() );
+    bool toCopyElems  = ( myCopyElementsCheck->isChecked() );
     bool toKeepIDs    = ( myKeepIdsCheck->isChecked() );
 
     SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
-    SMESH::SMESH_Mesh_var newMesh =
-      gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
-    if( !newMesh->_is_nil() )
-      if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
+    SMESH::SMESH_Mesh_var newMesh;
+    if ( isWithGeomMode() )
+    {
+      SMESH::SMESH_Mesh_var       srcMesh = mySelectedObject->GetMesh();
+      SMESH::ListOfGroups_var     newGroups;
+      SMESH::submesh_array_var    newSubmeshes;
+      SMESH::ListOfHypothesis_var newHypotheses;
+      SMESH::string_array_var     invalidEntries;
+      CORBA::Boolean ok = gen->CopyMeshWithGeom( srcMesh, myNewGeometry,
+                                                 meshName.constData(),
+                                                 toCopyGroups, toReuseHyps, toCopyElems,
+                                                 newMesh.out(),
+                                                 newGroups.out(),
+                                                 newSubmeshes.out(),
+                                                 newHypotheses.out(),
+                                                 invalidEntries.out() );
+      if ( !ok )
+      {
+        if ( invalidEntries->length() > 0 )
+          toShowObjects = true;
+        SUIT_MessageBox::warning( this,
+                                  tr("SMESH_WRN_WARNING"),
+                                  getErrorMsg( invalidEntries, anEntryList ));
+      }
+    }
+    else
+    {
+      newMesh = gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
+    }
+    if ( !newMesh->_is_nil() )
+      if ( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
+      {
         anEntryList.append( aSObject->GetID().c_str() );
+
+        if ( isWithGeomMode() )
+          SMESH::SetName( aSObject, meshName );
+      }
   }
-  catch (...) {
+  catch(const SALOME::SALOME_Exception & S_ex)
+  {
+    SalomeApp_Tools::QtCatchCorbaException(S_ex);
+  }
+  catch (...)
+  {
   }
 
   mySMESHGUI->updateObjBrowser(true);
@@ -350,7 +505,7 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
 
   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();
@@ -503,13 +658,12 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
   myActor = 0;
   QString aString = "";
 
-  myLineEditElements->setText(aString);
   myNbOkElements = 0;
   buttonOk->setEnabled(false);
   buttonApply->setEnabled(false);
   myFilterBtn->setEnabled(false);
 
-  // get selected mesh
+  // get selected mesh or geometry
   SALOME_ListIO aList;
   mySelectionMgr->selectedObjects(aList);
   int nbSel = aList.Extent();
@@ -517,19 +671,29 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
     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 = " ";
@@ -541,8 +705,23 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
     myNbOkElements = aString.size();
     myFilterBtn->setEnabled(true);
   }
-  myLineEditElements->setText( aString );
+
   bool ok = !aString.isEmpty();
+  if ( !mesh->_is_nil() )
+  {
+    myLineEditElements->setText( aString );
+    if ( isWithGeomMode() )
+      myMeshNameEdit->setText( aString );
+  }
+  else if ( !geom->_is_nil() )
+  {
+    myGeomNameEdit->setText( aString );
+    ok = ok && !myLineEditElements->text().isEmpty();
+  }
+
+  if ( ok && isWithGeomMode() && !myMesh->_is_nil() )
+    ok = myMesh->HasShapeToMesh();
+
 
   buttonOk->setEnabled(ok);
   buttonApply->setEnabled(ok);
@@ -554,7 +733,9 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
 //=======================================================================
 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"));
@@ -564,7 +745,8 @@ void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
   }
 
   mySelectionMgr->clearFilters();
-  mySelectionMgr->installFilter(myIdSourceFilter);
+  if ( !isWithGeomMode() )
+    mySelectionMgr->installFilter(myIdSourceFilter);
   SMESH::SetPointRepresentation(false);
 
   if (toSelectMesh) {
@@ -592,10 +774,29 @@ void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
 
 bool SMESHGUI_CopyMeshDlg::isValid()
 {
-  if ( myIdSourceCheck->isChecked() )
-    return !mySelectedObject->_is_nil();
+  bool ok = false;
+  if ( myIdSourceCheck->isChecked() || isWithGeomMode() )
+  {
+    ok = ( !mySelectedObject->_is_nil() );
+    if ( isWithGeomMode() )
+      ok = ok && ( !myNewGeometry->_is_nil() );
+  }
+  else
+  {
+    ok = ( myNbOkElements > 0 );
+  }
+
+  return ok;
+}
 
-  return myNbOkElements > 0;
+//=======================================================================
+//function : isWithGeomMode
+//purpose  : Return true if the mode is "with geometry"
+//=======================================================================
+
+bool SMESHGUI_CopyMeshDlg::isWithGeomMode()
+{
+  return ( GroupConstructors->checkedId() == 1 );
 }
 
 //=================================================================================
index fe4a8f1a9e275fb534dd59731c31abc97d002caf..2566e7aa66a6f0f7aa02dba05a372e5d01da0724 100644 (file)
 // IDL includes
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Gen)
 
 class QCheckBox;
 class QGroupBox;
 class QLabel;
 class QLineEdit;
 class QPushButton;
+class QButtonGroup;
 
 class SMESHGUI;
 class SMESHGUI_IdValidator;
@@ -56,10 +58,10 @@ class SUIT_SelectionFilter;
 //=================================================================================
 
 class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public QDialog
-{ 
+{
   Q_OBJECT
 
-public:
+ public:
   SMESHGUI_CopyMeshDlg( SMESHGUI* );
   ~SMESHGUI_CopyMeshDlg();
 
@@ -67,10 +69,12 @@ private:
   void                   Init( bool = true );
   void                   enterEvent( QEvent* );           /* mouse enter the QWidget */
   void                   keyPressEvent( QKeyEvent* );
-  int                    GetConstructorId();
   void                   setNewMeshName();
+  QString                getErrorMsg( SMESH::string_array_var invalidEntries,
+                                      QStringList &           entriesToBrowse );
 
   bool                   isValid();
+  bool                   isWithGeomMode();
 
   void                   setIsApplyAndClose( const bool theFlag );
   bool                   isApplyAndClose() const;
@@ -84,11 +88,14 @@ private:
 
   bool                   myBusy;
   SMESH::SMESH_Mesh_var  myMesh;
+  GEOM::GEOM_Object_var  myNewGeometry;
   SMESH_Actor*           myActor;
   SUIT_SelectionFilter*  myIdSourceFilter;
 
   SMESH::SMESH_IDSource_var mySelectedObject;
 
+  QButtonGroup*          GroupConstructors;
+
   QGroupBox*             ConstructorsBox;
   QGroupBox*             GroupArguments;
   QGroupBox*             GroupButtons;
@@ -99,10 +106,14 @@ private:
   QPushButton*           buttonHelp;
 
   QLabel*                myTextLabelElements;
+  QLabel*                myGeomLabel;
   QLineEdit*             myLineEditElements;
   QLineEdit*             myMeshNameEdit;
+  QLineEdit*             myGeomNameEdit;
   QCheckBox*             myIdSourceCheck;
   QCheckBox*             myCopyGroupsCheck;
+  QCheckBox*             myReuseHypCheck;
+  QCheckBox*             myCopyElementsCheck;
   QCheckBox*             myKeepIdsCheck;
 
   QPushButton*           myFilterBtn;
@@ -122,6 +133,7 @@ private slots:
   void                   SelectionIntoArgument();
   void                   DeactivateActiveDialog();
   void                   ActivateThisDialog();
+  void                   onConstructor( int );
   void                   onTextChange( const QString& );
   void                   onSelectIdSource( bool );
   void                   setFilters();
index 5367420060850c3a9f8e3d8bada1c2cdd4261f5d..7a403902d7f775a7b0cf8b0765d4eba813f1eb1e 100644 (file)
@@ -111,6 +111,17 @@ namespace SMESH
     return aMeshShape;
   }
 
+  GEOM::GEOM_Object_var GetGeom( Handle(SALOME_InteractiveObject) io )
+  {
+    GEOM::GEOM_Object_var go;
+    if ( !io.IsNull() && io->hasEntry() )
+    {
+      _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
+      go = GetGeom( so );
+    }
+    return go._retn();
+  }
+
   SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO )
   {
     if (!smeshSO)
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( Handle(SALOME_InteractiveObject) io );
+
   SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO );
 
   SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long );
index 7aff8c6ce1b4b281c333e3d19cadf152d9832d07..255d2f5751554fa993c6a6e571e4c38dd1f64566 100644 (file)
@@ -523,13 +523,15 @@ namespace SMESH
         if(MYDEBUG) MESSAGE("Loading client meshers plugin library ...");
 #ifdef WIN32
 #ifdef UNICODE
-               LPTSTR path = new TCHAR[aClientLibName.length() + 1];
-               path[aClientLibName.toWCharArray(path)] = '\0';
+        LPTSTR path = new TCHAR[aClientLibName.length() + 1];
+        path[aClientLibName.toWCharArray(path)] = '\0';
 #else
-               const char* path = aClientLibName.toUtf8().data();
+        QByteArray baPath = aClientLibName.toUtf8();
+        const char* path = baPath.data();
 #endif
 #else
-               char* path = aClientLibName.toUtf8().data();
+        QByteArray baPath = aClientLibName.toUtf8();
+        char* path = baPath.data();
 #endif
         LibHandle libHandle = LoadLib( path );
         if (!libHandle) {
index 9378e4d402070083339119e6913f0f636c57160e..9c690f3780fc4a172ea3472329cbc02f664b3cc6 100644 (file)
@@ -92,6 +92,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
   myShapeByMeshOp( 0 ),
   myToCreate( theToCreate ),
   myIsMesh( theIsMesh ),
+  myIsInvalidSubMesh( false ),
   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 );
-    if ( myToCreate && !myIsMesh )
+    if (( myToCreate && !myIsMesh ) || myIsInvalidSubMesh )
       aResult = createSubMesh( aMess, anEntryList );
     else if ( !myToCreate )
       aResult = editMeshOrSubMesh( aMess );
@@ -519,6 +520,7 @@ void SMESHGUI_MeshOp::selectionDone()
   try
   {
     myIsOnGeometry = true;
+    myIsInvalidSubMesh = false;
 
     //Check geometry for mesh
     QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
@@ -638,11 +640,21 @@ void SMESHGUI_MeshOp::selectionDone()
           SMESH::SMESH_subMesh_var submeshVar =
             SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
           myIsMesh = submeshVar->_is_nil();
+          myIsInvalidSubMesh = ( !myIsMesh && submeshVar->GetId() < 1 );
           myDlg->setTitile( myToCreate, myIsMesh );
           myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !submeshVar->_is_nil() );
           myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
           myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
-          myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
+          if ( myIsInvalidSubMesh )
+          {
+            // it is necessary to select a new geometry
+            myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->show();
+            myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
+          }
+          else
+          {
+            myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
+          }
           myDlg->updateGeometry();
           myDlg->adjustSize();
           readMesh();
@@ -1877,9 +1889,9 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
 //================================================================================
 /*!
  * \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
  */
@@ -1893,11 +1905,16 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
     return false;
 
   // get mesh object
-  QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
-  _PTR(SObject) pMesh = SMESH::getStudy()->FindObjectID( aMeshEntry.toUtf8().data() );
   SMESH::SMESH_Mesh_var aMeshVar =
-    SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
-  if (aMeshVar->_is_nil())
+    SMESH::EntryToInterface<SMESH::SMESH_Mesh>( myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ));
+  if ( aMeshVar->_is_nil() && myIsInvalidSubMesh )
+  {
+    SMESH::SMESH_subMesh_var aSMVar =
+      SMESH::EntryToInterface<SMESH::SMESH_subMesh>( myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ));
+    if ( !aSMVar->_is_nil() )
+      aMeshVar = aSMVar->GetMesh();
+  }
+  if ( aMeshVar->_is_nil() )
     return false;
 
   // GEOM shape of the main mesh
@@ -1971,8 +1988,14 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
 
   SUIT_OverrideCursor aWaitCursor;
 
+  QString aNameOrID = aName;
+  if ( myIsInvalidSubMesh )
+    // pass a sub-mesh entry to mesh->GetSubMesh() to replace the invalid sub-mesh
+    // by a valid one in an existing SO
+    aNameOrID = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
+
   // create sub-mesh
-  SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toUtf8().data() );
+  SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aNameOrID.toUtf8().data() );
   _PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() );
   if ( aSubMeshSO ) {
     SMESH::SetName( aSubMeshSO, aName.toUtf8().data() );
@@ -2249,10 +2272,13 @@ void SMESHGUI_MeshOp::readMesh()
       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
index 8ba4f8c40b81bbe152d7a6fc51de9d4286904124..48879d0f086d2516f9fbf8e503c672c28223a9c3 100644 (file)
@@ -153,8 +153,11 @@ private:
   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
   bool                           myToCreate;
   bool                           myIsMesh;
-  bool                           myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object
+  bool                           myIsOnGeometry; //!< TRUE if edited mesh is based on geometry
   bool                           myHasConcurrentSubBefore;
+  bool                           myIsInvalidSubMesh; //!< "invalid sub-mesh" is edited
+  // The geometry of "invalid sub-mesh" is not a sub-shape of the main shape;
+  // it is created for the case where a valid sub-shape not found by CopyMeshWithGeom()
 
   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current
index b8e679e67f231d07479a8c303518db022964ae03..5721e5301dea6f61a2a6838b2a1c92d618837a15 100644 (file)
@@ -226,6 +226,12 @@ namespace SMESH
     return app->orb()->string_to_object(theIOR.toLatin1().data());
   }
 
+  CORBA::Object_var EntryToObject( const QString& theEntry )
+  {
+    _PTR(SObject) anObj = getStudy()->FindObjectID( theEntry.toLatin1().data() );
+    return SObjectToObject(anObj);
+  }
+
   int GetNameOfSelectedIObjects(LightApp_SelectionMgr* theMgr, QString& theName)
   {
     if (!theMgr)
index 6ff20e8a2fe2c65c7bade362f1ef5b38285555b7..41d2e674ed3408bcfe02f134fa9d714b6bebb275 100644 (file)
@@ -152,6 +152,18 @@ SMESHGUI_EXPORT
       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& );
 
index 629c0d1073a24ff2e9e8b2b46d4d24dacf23af3a..9605001fb82f2c06be7a3c29ae1e6f69a0415da9 100644 (file)
             <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>
index 75d649a726f19b4b7b69f63efbe1a24faa1a52b6..bd20246ad61471068c6c9fc17b1b4d191f8a446d 100644 (file)
@@ -1938,6 +1938,14 @@ add the exported data to its contents?</translation>
         <source>SMESH_HYPOTHESES</source>
         <translation>Hypotheses</translation>
     </message>
+    <message>
+        <source>SMESH_HYPOTHESIS</source>
+        <translation>Hypothesis</translation>
+    </message>
+    <message>
+        <source>SMESH_ALGORITHM</source>
+        <translation>Algorithm</translation>
+    </message>
     <message>
         <source>SMESH_HYP_1</source>
         <translation>Algorithm misses a hypothesis</translation>
@@ -8070,6 +8078,25 @@ as they are of improper type:
         <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>
index 6c1329704730f8e023c112b2f2f2803367f4da32..cef6517ce435f1c1da81d5ff84e9eda198e69580 100644 (file)
@@ -1006,10 +1006,10 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
     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();
@@ -1027,6 +1027,12 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
       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" )
index c878fe37b97c23833fca7e9d0fda34935823c9a3..1b66bb29fe9d1f5735ae0b2a05d3b7ee92f0aa75 100644 (file)
@@ -81,3 +81,27 @@ SMESH::ListOfHypothesisName* SMESH_Algo_i::GetCompatibleHypothesis()
   }
   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 0d75eb5c2a88d55d22382778755a8f45db125e69..9d4f6bf5641668744a86eac91437183f5d98f1a7 100644 (file)
@@ -53,6 +53,15 @@ public:
   
   // 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
index 75c9d2184ece2e5cde5aec19f65771cdbe4fd314..cd9c86098033368bdc5ae2f1c797362f91ad1fed 100644 (file)
 #include "SMESH_PreMeshInfo.hxx"
 #include "SMESH_PythonDump.hxx"
 #include "SMESH_ControlsDef.hxx"
+
+// to pass CORBA exception through SMESH_TRY
+#define SMY_OWN_CATCH catch( SALOME::SALOME_Exception& se ) { throw se; }
 #include "SMESH_TryCatch.hxx" // to include after OCC headers!
 
 #include CORBA_SERVER_HEADER(SMESH_Group)
 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
 
 
+#include <GEOMImpl_Types.hxx>
 #include <GEOM_Client.hxx>
 
 #include <Basics_Utils.hxx>
 #include <sstream>
 #include <cstdio>
 #include <cstdlib>
+#include <memory>
 
 using namespace std;
 using SMESH::TPythonDump;
@@ -440,17 +445,17 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp
       // load plugin library
       if(MYDEBUG) MESSAGE("Loading server meshers plugin library ...");
 #ifdef WIN32
-  #ifdef UNICODE
-         const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName);
-  #else
-         const char* path = aPlatformLibName.c_str();
-  #endif
+#ifdef UNICODE
+      const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName);
+#else
+      const char* path = aPlatformLibName.c_str();
+#endif
 #else
-         const char* path = aPlatformLibName.c_str();
+      const char* path = aPlatformLibName.c_str();
 #endif
       LibHandle libHandle = LoadLib( path );
 #if defined(WIN32) && defined(UNICODE)
-         delete path;
+      delete path;
 #endif
       if (!libHandle)
       {
@@ -1938,7 +1943,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
 
   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();
@@ -1960,6 +1965,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
       meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
       myLocMesh.GetMeshDS()->Modified();
       UpdateIcons( theMesh );
+      HighLightInvalid( theMesh, /*isInvalid=*/!ok );
       return ok;
     }
   }
@@ -2724,10 +2730,12 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
                                             const char*               meshName,
                                             CORBA::Boolean            toCopyGroups,
                                             CORBA::Boolean            toKeepIDs)
+  throw ( SALOME::SALOME_Exception )
 {
   Unexpect aCatch(SALOME_SalomeException);
 
   TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh()
+  std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
 
   // 1. Get source mesh
 
@@ -2930,7 +2938,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
           << 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();
@@ -2938,6 +2946,868 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
   return newMesh._retn();
 }
 
+
+namespace // utils for CopyMeshWithGeom()
+{
+  typedef std::map< std::string, std::string >             TStr2StrMap;
+  typedef std::map< std::string, std::set< std::string > > TStr2StrSetMap;
+
+  //================================================================================
+  /*!
+   * \brief Return a new sub-shape corresponding to an old one
+   */
+  //================================================================================
+
+  struct ShapeMapper
+  {
+    SMESH_Mesh_i* mySrcMesh_i;
+    SMESH_Mesh_i* myNewMesh_i;
+    SMESH_Gen_i*  myGen_i;
+    bool          myToPublish;
+    bool          myIsSameGeom;
+
+    TStr2StrMap   myOld2NewEntryMap; // map of study entries
+
+    bool                       myGIPMapDone;
+    GEOM::ListOfListOfLong_var myGIPMap; // filled by GetInPlaceMap()
+
+    // not directly relating to shape search
+    TStr2StrSetMap myInvalidMap; // blame shape -> invalid objects
+
+    //================================================================================
+    /*!
+     * \brief Constructor
+     */
+    ShapeMapper( SMESH_Mesh_i* srcMesh_i,
+                 SMESH_Mesh_i* newMesh_i,
+                 SMESH_Gen_i*  smeshGen_i )
+      : mySrcMesh_i( srcMesh_i ),
+        myNewMesh_i( newMesh_i ),
+        myGen_i    ( smeshGen_i ),
+        myToPublish( smeshGen_i->IsEnablePublish() ),
+        myGIPMapDone( false )
+    {
+      // retrieve from the study shape mapping made thanks to
+      // "Set presentation parameters and sub-shapes from arguments" option
+
+      GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
+      GEOM::GEOM_Object_var mainShapeOld = mySrcMesh_i->GetShapeToMesh();
+      SALOMEDS::SObject_wrap oldSO = myGen_i->ObjectToSObject( mainShapeOld );
+      SALOMEDS::SObject_wrap newSO = myGen_i->ObjectToSObject( mainShapeNew );
+      if ( newSO->_is_nil() )
+      {
+        myToPublish = false;
+        return;
+      }
+      if (( myIsSameGeom = mainShapeNew->_is_equivalent( mainShapeOld )))
+        return;
+      CORBA::String_var oldEntry = oldSO->GetID();
+      CORBA::String_var newEntry = newSO->GetID();
+      myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ),
+                                                std::string( newEntry.in() )));
+
+      SALOMEDS::Study_var            study = myGen_i->getStudyServant();
+      GEOM::GEOM_Gen_var           geomGen = myGen_i->GetGeomEngine();
+      GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
+      GEOM::ListOfGO_var         subShapes = op->GetExistingSubObjects( mainShapeNew,
+                                                                        /*groupsOnly=*/false );
+      for ( CORBA::ULong i = 0; i < subShapes->length(); ++i )
+      {
+        newSO = myGen_i->ObjectToSObject( subShapes[ i ]);
+        SALOMEDS::ChildIterator_wrap anIter = study->NewChildIterator( newSO );
+        for ( ; anIter->More(); anIter->Next() )
+        {
+          SALOMEDS::SObject_wrap so = anIter->Value();
+          if ( so->ReferencedObject( oldSO.inout() ))
+          {
+            oldEntry = oldSO->GetID();
+            newEntry = newSO->GetID();
+            myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ),
+                                                      std::string( newEntry.in() )));
+          }
+        }
+      }
+    }
+
+    //================================================================================
+    /*!
+     * \brief Find a new sub-shape corresponding to an old one
+     */
+    GEOM::GEOM_Object_ptr FindNew( GEOM::GEOM_Object_ptr oldShape )
+    {
+      if ( myIsSameGeom )
+        return GEOM::GEOM_Object::_duplicate( oldShape );
+
+      GEOM::GEOM_Object_var newShape;
+
+      if ( CORBA::is_nil( oldShape ))
+        return newShape._retn();
+
+      if ( !isChildOfOld( oldShape ))
+        return GEOM::GEOM_Object::_duplicate( oldShape ); // shape independent of the old shape
+
+      GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
+      GEOM::GEOM_Gen_var         geomGen = myGen_i->GetGeomEngine();
+
+      // try to find by entry
+      if ( myToPublish )
+      {
+        CORBA::String_var  oldEntry = oldShape->GetStudyEntry();
+        TStr2StrMap::iterator o2nID = myOld2NewEntryMap.find( oldEntry.in() );
+        if ( o2nID != myOld2NewEntryMap.end() )
+        {
+          newShape = getShapeByEntry( o2nID->second );
+        }
+      }
+
+      if ( newShape->_is_nil() )
+      {
+        // try to construct a new sub-shape using myGIPMap
+        buildGIPMap();
+        std::vector< int >   newIndices;
+        GEOM::ListOfLong_var oldIndices = oldShape->GetSubShapeIndices();
+        for ( CORBA::ULong i = 0; i < oldIndices->length(); ++i )
+        {
+          findNewIDs( oldIndices[i], newIndices );
+        }
+        if ( !newIndices.empty() )
+        {
+          try
+          {
+            if ( newIndices.size() > 1 || oldShape->GetType() == GEOM_GROUP )
+            {
+              int groupType = getShapeType( myNewMesh_i, newIndices[0] );
+
+              GEOM::GEOM_IGroupOperations_wrap grOp = geomGen->GetIGroupOperations();
+              newShape = grOp->CreateGroup( mainShapeNew, groupType );
+
+              GEOM::ListOfLong_var  newIndicesList = new GEOM::ListOfLong();
+              newIndicesList->length( newIndices.size() );
+              for ( size_t i = 0; i < newIndices.size(); ++i )
+                newIndicesList[ i ] = newIndices[ i ];
+              grOp->UnionIDs( newShape, newIndicesList );
+            }
+            else
+            {
+              GEOM::GEOM_IShapesOperations_wrap shOp = geomGen->GetIShapesOperations();
+              newShape = shOp->GetSubShape( mainShapeNew, newIndices[0] );
+            }
+          }
+          catch (...)
+          {
+          }
+        }
+      }
+
+      if ( !newShape->_is_nil() && myToPublish )
+      {
+        CORBA::String_var oldEntry, newEntry = newShape->GetStudyEntry();
+        if ( !newEntry.in() || !newEntry.in()[0] )
+        {
+          CORBA::String_var    name = oldShape->GetName();
+          SALOMEDS::SObject_wrap so = geomGen->AddInStudy( newShape, name, mainShapeNew );
+          newEntry = newShape->GetStudyEntry();
+          oldEntry = oldShape->GetStudyEntry();
+          myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ),
+                                                    std::string( newEntry.in() )));
+        }
+      }
+
+      return newShape._retn();
+    }
+
+    //================================================================================
+    /*!
+     * \brief Return a study entry of a new shape by study entry of the old one
+     */
+    std::string FindNew( const std::string & oldEntry )
+    {
+      if ( myIsSameGeom )
+        return oldEntry;
+
+      TStr2StrMap::iterator o2nID = myOld2NewEntryMap.find( oldEntry );
+      if ( o2nID != myOld2NewEntryMap.end() )
+        return o2nID->second;
+
+      GEOM::GEOM_Object_var oldShape = getShapeByEntry( oldEntry );
+      if ( oldShape->_is_nil() || !isChildOfOld( oldShape ))
+        return oldEntry;
+
+      GEOM::GEOM_Object_ptr newShape = FindNew( oldShape );
+      if ( newShape->_is_nil() )
+        return std::string();
+
+      CORBA::String_var newEntry = newShape->GetStudyEntry();
+      return newEntry.in();
+    }
+
+    //================================================================================
+    /*!
+     * \brief Return a sub-shape ID of a new shape by a sub-shape ID of the old one.
+     *        Return zero if not found or there are more than one new ID
+     */
+    int FindNew( int oldID )
+    {
+      if ( myIsSameGeom )
+        return oldID;
+
+      buildGIPMap();
+
+      int newID = 0;
+
+      if ( 0 < oldID && oldID < (int)myGIPMap->length() )
+      {
+        if ( myGIPMap[ oldID ].length() == 1 )
+          newID = myGIPMap[ oldID ][ 0 ];
+      }
+      return newID;
+    }
+
+    //================================================================================
+    /*!
+     * \brief Return a sub-shape ID of a new shape by an old sub-mesh.
+     *        Return zero if the old shape is not kept as is in the new shape.
+     */
+    int FindNewNotChanged( SMESH_subMesh* oldSM )
+    {
+      if ( myIsSameGeom )
+        return oldSM->GetId();
+
+      int newID = FindNew( oldSM->GetId() );
+      if ( !newID )
+        return 0;
+
+      SMESH_subMesh* newSM = myNewMesh_i->GetImpl().GetSubMeshContaining( newID );
+      if ( !newSM )
+        return 0;
+
+      // consider a sub-shape as not changed if all its sub-shapes are mapped into
+      // one new sub-shape of the same type.
+
+      if ( oldSM->DependsOn().size() !=
+           newSM->DependsOn().size() )
+        return 0;
+
+      SMESH_subMeshIteratorPtr srcSMIt = oldSM->getDependsOnIterator( /*includeSelf=*/true );
+      while ( srcSMIt->more() )
+      {
+        oldSM = srcSMIt->next();
+        int newSubID = FindNew( oldSM->GetId() );
+        if ( getShapeType( myNewMesh_i, newSubID ) !=
+             getShapeType( mySrcMesh_i, oldSM->GetId() ))
+          return 0;
+      }
+      return newID;
+    }
+
+    //================================================================================
+    /*!
+     * \brief Return shape by study entry
+     */
+    GEOM::GEOM_Object_ptr getShapeByEntry( const std::string & entry )
+    {
+      GEOM::GEOM_Object_var shape;
+      SALOMEDS::SObject_wrap so = myGen_i->getStudyServant()->FindObjectID( entry.c_str() );
+      if ( !so->_is_nil() )
+      {
+        CORBA::Object_var obj = so->GetObject();
+        shape = GEOM::GEOM_Object::_narrow( obj );
+      }
+      return shape._retn();
+    }
+
+    //================================================================================
+    /*!
+     * \brief Fill myGIPMap by calling GetInPlaceMap()
+     */
+    void buildGIPMap()
+    {
+      if ( !myGIPMapDone )
+      {
+        myGIPMapDone = true;
+
+        GEOM::GEOM_Object_var   mainShapeNew = myNewMesh_i->GetShapeToMesh();
+        GEOM::GEOM_Object_var   mainShapeOld = mySrcMesh_i->GetShapeToMesh();
+        GEOM::GEOM_Gen_var           geomGen = myGen_i->GetGeomEngine();
+        GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
+        try
+        {
+          myGIPMap = op->GetInPlaceMap( mainShapeNew, mainShapeOld );
+        }
+        catch( ... )
+        {
+          myGIPMap = new GEOM::ListOfListOfLong();
+        }
+      }
+    }
+
+    //================================================================================
+    /*!
+     * \brief Find a new sub-shape indices by an old one in myGIPMap. Return
+     *        number of found IDs
+     */
+    int findNewIDs( int oldID, std::vector< int >& newIDs  )
+    {
+      size_t prevNbIDs = newIDs.size();
+
+      if ( 0 < oldID && oldID < (int) myGIPMap->length() )
+      {
+        for ( CORBA::ULong i = 0; i < myGIPMap[ oldID ].length(); ++i )
+          newIDs.push_back( myGIPMap[ oldID ][ i ]);
+      }
+      return newIDs.size() - prevNbIDs;
+    }
+
+    //================================================================================
+    /*!
+     * \brief Check if an object relates to the old shape
+     */
+    bool isChildOfOld( GEOM::GEOM_Object_ptr oldShape )
+    {
+      if ( CORBA::is_nil( oldShape ))
+        return false;
+      GEOM::GEOM_Object_var mainShapeOld1 = mySrcMesh_i->GetShapeToMesh();
+      GEOM::GEOM_Object_var mainShapeOld2 = oldShape->GetMainShape();
+      return ( mainShapeOld1->_is_equivalent( mainShapeOld2 ) ||
+               mainShapeOld1->_is_equivalent( oldShape ));
+    }
+
+    //================================================================================
+    /*!
+     * \brief Return shape type by shape ID
+     */
+    TopAbs_ShapeEnum getShapeType( SMESH_Mesh_i* mesh_i, int shapeID )
+    {
+      SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS();
+      const TopoDS_Shape& shape = meshDS->IndexToShape( shapeID );
+      return shape.IsNull() ? TopAbs_SHAPE : shape.ShapeType();
+    }
+
+    //================================================================================
+    /*!
+     * \brief Store a source sub-shape for which a counterpart not found and
+     *        a smesh object invalid due to that
+     */
+    void AddInvalid( GEOM::GEOM_Object_var  srcShape,
+                     SALOMEDS::SObject_wrap smeshSO )
+    {
+      CORBA::String_var geomEntry = srcShape->GetStudyEntry();
+      if ( geomEntry.in()[0] && !smeshSO->_is_nil() )
+      {
+        CORBA::String_var smeshEntry = smeshSO->GetID();
+        myInvalidMap[ geomEntry.in() ].insert( smeshEntry.in() );
+      }
+    }
+
+    //================================================================================
+    /*!
+     * \brief Store a source sub-shape for which a counterpart not found and
+     *        a smesh object invalid due to that
+     */
+    void AddInvalid( std::string            geomEntry,
+                     SALOMEDS::SObject_wrap smeshSO )
+    {
+      if ( !geomEntry.empty() )
+      {
+        CORBA::String_var smeshEntry = smeshSO->GetID();
+        myInvalidMap[ geomEntry ].insert( smeshEntry.in() );
+      }
+    }
+
+    //================================================================================
+    /*!
+     * \brief Store a source sub-shape for which a counterpart not found and
+     *        a smesh object invalid due to that
+     */
+    void AddInvalid( int                    oldGeomID,
+                     SALOMEDS::SObject_wrap smeshSO )
+    {
+      int shapeType = getShapeType( mySrcMesh_i, oldGeomID );
+      if ( shapeType < 0 || shapeType > TopAbs_SHAPE )
+        return;
+
+      const char* typeName[] = { "COMPOUND","COMPSOLID","SOLID","SHELL",
+                                 "FACE","WIRE","EDGE","VERTEX","SHAPE" };
+
+      SMESH_Comment geomName( typeName[ shapeType ]);
+      geomName << " #" << oldGeomID;
+
+      CORBA::String_var smeshEntry = smeshSO->GetID();
+      myInvalidMap[ geomName ].insert( smeshEntry.in() );
+    }
+
+    //================================================================================
+    /*!
+     * \brief Return entries of a source sub-shape for which a counterpart not found and
+     *        of smesh objects invalid due to that
+     */
+    void GetInvalid( SMESH::string_array_out &               theInvalidEntries,
+                     std::vector< SALOMEDS::SObject_wrap > & theInvalidMeshSObjects)
+    {
+      int nbSO = 0;
+      TStr2StrSetMap::iterator entry2entrySet = myInvalidMap.begin();
+      for ( ; entry2entrySet != myInvalidMap.end(); ++entry2entrySet )
+      {
+        nbSO += 1 + entry2entrySet->second.size();
+      }
+      int iSO = theInvalidMeshSObjects.size(), iEntry = 0;
+      theInvalidEntries->length  ( nbSO );
+      theInvalidMeshSObjects.resize( theInvalidMeshSObjects.size() + nbSO - myInvalidMap.size() );
+
+      entry2entrySet = myInvalidMap.begin();
+      for ( ; entry2entrySet != myInvalidMap.end(); ++entry2entrySet )
+      {
+        theInvalidEntries[ iEntry++ ] = entry2entrySet->first.c_str();
+
+        std::set< std::string > & entrySet = entry2entrySet->second;
+        std::set< std::string >::iterator entry = entrySet.begin();
+        for ( ; entry != entrySet.end(); ++entry )
+        {
+          theInvalidEntries[ iEntry++ ] = entry->c_str();
+
+          SALOMEDS::SObject_wrap so = myGen_i->getStudyServant()->FindObjectID( entry->c_str() );
+          if ( !so->_is_nil() )
+            theInvalidMeshSObjects[ iSO++ ] = so;
+        }
+      }
+    }
+
+  }; // struct ShapeMapper
+
+  //================================================================================
+  /*!
+   * \brief Append an item to a CORBA sequence
+   */
+  template < class CORBA_seq, class ITEM >
+  void append( CORBA_seq& seq, ITEM item )
+  {
+    if ( !CORBA::is_nil( item ))
+    {
+      seq->length( 1 + seq->length() );
+      seq[ seq->length() - 1 ] = item;
+    }
+  }
+}
+
+//================================================================================
+/*!
+ * \brief Create a mesh by copying definitions of another mesh to a given geometry
+ *  \param [in] sourceMesh - a mesh to copy
+ *  \param [in] newGeometry - a new geometry
+ *  \param [in] toCopyGroups - to create groups in the new mesh
+ *  \param [in] toReuseHypotheses - if True, existing hypothesis will be used by the new mesh,
+ *         otherwise new hypotheses with the same parameters will be created for the new mesh.
+ *  \param [in] toCopyElements - to copy mesh elements of same sub-shapes of the two geometries
+ *  \param [out] newMesh - return a new mesh
+ *  \param [out] newGroups - return new groups
+ *  \param [out] newSubmeshes - return new sub-meshes
+ *  \param [out] newHypotheses - return new algorithms and hypotheses
+ *  \param [out] invalidEntries - return study entries of objects whose
+ *         counterparts are not found in the newGeometry, followed by entries
+ *         of mesh sub-objects that are invalid because they depend on a not found
+ *         preceeding sub-shape
+ *  \return CORBA::Boolean - is a success
+ */
+//================================================================================
+
+CORBA::Boolean SMESH_Gen_i::CopyMeshWithGeom( SMESH::SMESH_Mesh_ptr       theSourceMesh,
+                                              GEOM::GEOM_Object_ptr       theNewGeometry,
+                                              const char*                 theMeshName,
+                                              CORBA::Boolean              theToCopyGroups,
+                                              CORBA::Boolean              theToReuseHypotheses,
+                                              CORBA::Boolean              theToCopyElements,
+                                              SMESH::SMESH_Mesh_out       theNewMesh,
+                                              SMESH::ListOfGroups_out     theNewGroups,
+                                              SMESH::submesh_array_out    theNewSubmeshes,
+                                              SMESH::ListOfHypothesis_out theNewHypotheses,
+                                              SMESH::string_array_out     theInvalidEntries)
+throw ( SALOME::SALOME_Exception )
+{
+  if ( CORBA::is_nil( theSourceMesh ) ||
+       CORBA::is_nil( theNewGeometry ))
+    THROW_SALOME_CORBA_EXCEPTION( "NULL arguments", SALOME::BAD_PARAM );
+
+  if ( !theSourceMesh->HasShapeToMesh() )
+    THROW_SALOME_CORBA_EXCEPTION( "Source mesh not on geometry", SALOME::BAD_PARAM );
+
+  bool ok = true;
+  SMESH_TRY;
+
+  TPythonDump pyDump; // prevent dump from CreateMesh()
+
+  theNewMesh        = CreateMesh( theNewGeometry );
+  theNewGroups      = new SMESH::ListOfGroups();
+  theNewSubmeshes   = new SMESH::submesh_array();
+  theNewHypotheses  = new SMESH::ListOfHypothesis();
+  theInvalidEntries = new SMESH::string_array();
+
+  std::vector< SALOMEDS::SObject_wrap > invalidSObjects;
+
+  GEOM::GEOM_Object_var srcGeom = theSourceMesh->GetShapeToMesh();
+  GEOM::GEOM_Object_var geom, newGeom;
+  SALOMEDS::SObject_wrap so;
+
+  SMESH_Mesh_i* srcMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSourceMesh );
+  SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theNewMesh );
+
+  ShapeMapper shapeMapper( srcMesh_i, newMesh_i, this );
+
+  // treat hypotheses of mesh and sub-meshes
+  SMESH::submesh_array_var smList = theSourceMesh->GetSubMeshes();
+  for ( CORBA::ULong iSM = 0; iSM <= smList->length(); ++iSM )
+  {
+    bool isSubMesh = ( iSM < smList->length() );
+    if ( isSubMesh )
+    {
+      // create a new sub-mesh
+      SMESH::SMESH_subMesh_var newSM;
+      geom = smList[iSM]->GetSubShape();
+      so   = ObjectToSObject( smList[iSM] );
+      CORBA::String_var name;
+      if ( !so->_is_nil() )
+        name = so->GetName();
+      newGeom = shapeMapper.FindNew( geom );
+      if ( newGeom->_is_nil() )
+      {
+        newSM = createInvalidSubMesh( theNewMesh, geom, name.in() );
+        shapeMapper.AddInvalid( geom, ObjectToSObject( newSM ));
+        ok = false;
+      }
+      else
+      {
+        newSM = theNewMesh->GetSubMesh( newGeom, name.in() );
+      }
+      append( theNewSubmeshes, newSM );
+
+      if ( newGeom->_is_nil() )
+        continue; // don't assign hypotheses
+    }
+    else
+    {
+      newGeom = GEOM::GEOM_Object::_duplicate( theNewGeometry );
+      geom    = srcGeom;
+      so      = ObjectToSObject( theNewMesh );
+      SetName( so, theMeshName, "Mesh" );
+    }
+
+    // assign hypotheses
+    SMESH::ListOfHypothesis_var hypList = theSourceMesh->GetHypothesisList( geom );
+    for ( CORBA::ULong iHyp = 0; iHyp < hypList->length(); ++iHyp )
+    {
+      SMESH::SMESH_Hypothesis_var hyp = hypList[ iHyp ];
+      SMESH_Hypothesis_i*       hyp_i = SMESH::DownCast< SMESH_Hypothesis_i* >( hyp );
+
+      // get geometry hyp depends on
+      std::vector< std::string > entryArray;
+      std::vector< int >         subIDArray;
+      bool dependsOnGeom = hyp_i->getObjectsDependOn( entryArray, subIDArray );
+
+      if ( !theToReuseHypotheses || dependsOnGeom )
+      {
+        // create a new hypothesis
+        CORBA::String_var type = hyp->GetName();
+        CORBA::String_var lib  = hyp->GetLibName();
+        CORBA::String_var data = hyp_i->SaveTo();
+        if ( data.in()[0] )
+        {
+          hyp   = CreateHypothesis( type, lib );
+          hyp_i = SMESH::DownCast< SMESH_Hypothesis_i* >( hyp );
+          hyp_i->LoadFrom( data.in() );
+          append( theNewHypotheses, hyp );
+        }
+      }
+
+      // update geometry hyp depends on
+      if ( dependsOnGeom )
+      {
+        for ( size_t iGeo = 0; iGeo < entryArray.size(); ++iGeo )
+        {
+          if ( !entryArray[ iGeo ].empty() )
+          {
+            std::string newEntry = shapeMapper.FindNew( entryArray[ iGeo ]);
+            if ( newEntry.empty() )
+            {
+              ok = false;
+              shapeMapper.AddInvalid( entryArray[ iGeo ], ObjectToSObject( hyp ));
+              shapeMapper.AddInvalid( entryArray[ iGeo ], so ); // sub-mesh
+            }
+            entryArray[ iGeo ] = newEntry;
+          }
+        }
+        for ( size_t iGeo = 0; iGeo < subIDArray.size(); ++iGeo )
+        {
+          if ( subIDArray[ iGeo ] > 0 )
+          {
+            int newID = shapeMapper.FindNew( subIDArray[ iGeo ]);
+            if ( newID < 1 )
+            {
+              ok = false;
+              shapeMapper.AddInvalid( subIDArray[ iGeo ], ObjectToSObject( hyp ));
+              shapeMapper.AddInvalid( subIDArray[ iGeo ], so ); // sub-mesh
+            }
+            subIDArray[ iGeo ] = newID;
+          }
+        }
+        if ( !hyp_i->setObjectsDependOn( entryArray, subIDArray ))
+          ok = false;
+      }
+
+      CORBA::String_var errorText;
+      theNewMesh->AddHypothesis( newGeom, hyp, errorText.out() );
+      if ( errorText.in()[0] )
+        ok = false;
+
+    } // loop on hypotheses
+  } // loop on sub-meshes and mesh
+
+
+  // copy mesh elements, keeping IDs
+  if ( theToCopyElements && theSourceMesh->NbNodes() > 0 )
+  {
+    SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS();
+    ::SMESH_MeshEditor editor( &newMesh_i->GetImpl() );
+    ::SMESH_MeshEditor::ElemFeatures elemData;
+
+    SMESH_subMesh*         srcMainSM = srcMesh_i->GetImpl().GetSubMeshContaining( 1 );
+    SMESH_subMeshIteratorPtr srcSMIt = srcMainSM->getDependsOnIterator( /*includeSelf=*/true,
+                                                                        /*vertexLast=*/false);
+    while ( srcSMIt->more() )
+    {
+      SMESH_subMesh* srcSM = srcSMIt->next();
+      if ( srcSM->IsEmpty() )
+        continue; // not yet computed
+      int newID = shapeMapper.FindNewNotChanged( srcSM );
+      if ( newID < 1 )
+        continue;
+
+      SMESHDS_SubMesh* srcSMDS = srcSM->GetSubMeshDS();
+      SMDS_NodeIteratorPtr nIt = srcSMDS->GetNodes();
+      while ( nIt->more() )
+      {
+        SMESH_NodeXYZ node( nIt->next() );
+        const SMDS_MeshNode* newNode = newMeshDS->AddNodeWithID( node.X(), node.Y(), node.Z(),
+                                                                 node->GetID() );
+        const SMDS_PositionPtr pos = node->GetPosition();
+        const double*           uv = pos->GetParameters();
+        switch ( pos->GetTypeOfPosition() )
+        {
+        case SMDS_TOP_3DSPACE: newMeshDS->SetNodeInVolume( newNode, newID );               break;
+        case SMDS_TOP_FACE:    newMeshDS->SetNodeOnFace  ( newNode, newID, uv[0], uv[1] ); break;
+        case SMDS_TOP_EDGE:    newMeshDS->SetNodeOnEdge  ( newNode, newID, uv[0] );        break;
+        case SMDS_TOP_VERTEX:  newMeshDS->SetNodeOnVertex( newNode, newID );               break;
+        default: ;
+        }
+      }
+      SMDS_ElemIteratorPtr eIt = srcSMDS->GetElements();
+      while( eIt->more() )
+      {
+        const SMDS_MeshElement* e = eIt->next();
+        elemData.Init( e, /*basicOnly=*/false );
+        elemData.SetID( e->GetID() );
+        elemData.myNodes.resize( e->NbNodes() );
+        SMDS_NodeIteratorPtr nnIt = e->nodeIterator();
+        size_t iN;
+        for ( iN = 0; nnIt->more(); ++iN )
+        {
+          const SMDS_MeshNode* srcNode = nnIt->next();
+          elemData.myNodes[ iN ] = newMeshDS->FindNode( srcNode->GetID() );
+          if ( !elemData.myNodes[ iN ])
+            break;
+        }
+        if ( iN == elemData.myNodes.size() )
+          if ( const SMDS_MeshElement * newElem = editor.AddElement( elemData.myNodes, elemData ))
+            newMeshDS->SetMeshElementOnShape( newElem, newID );
+      }
+      if ( SMESH_subMesh* newSM = newMesh_i->GetImpl().GetSubMeshContaining( newID ))
+        newSM->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+    }
+  }
+
+
+  // treat groups
+
+  TStr2StrMap old2newGroupMap;
+
+  SALOME::GenericObj_wrap< SMESH::FilterManager > filterMgr = CreateFilterManager();
+
+  SMESH::ListOfGroups_var groups = theSourceMesh->GetGroups();
+  CORBA::ULong nbGroups = groups->length(), nbAddedGroups = 0;
+  for ( CORBA::ULong i = 0; i < nbGroups + nbAddedGroups; ++i )
+  {
+    SMESH::SMESH_Group_var         stdlGroup = SMESH::SMESH_Group::_narrow        ( groups[ i ]);
+    SMESH::SMESH_GroupOnGeom_var   geomGroup = SMESH::SMESH_GroupOnGeom::_narrow  ( groups[ i ]);
+    SMESH::SMESH_GroupOnFilter_var fltrGroup = SMESH::SMESH_GroupOnFilter::_narrow( groups[ i ]);
+
+    CORBA::String_var      name = groups[ i ]->GetName();
+    SMESH::ElementType elemType = groups[ i ]->GetType();
+
+    SMESH::SMESH_GroupBase_var newGroup;
+
+    if ( !stdlGroup->_is_nil() )
+    {
+      if ( theToCopyElements )
+      {
+        SMESH::long_array_var elemIDs = stdlGroup->GetIDs();
+        stdlGroup = theNewMesh->CreateGroup( elemType, name );
+        stdlGroup->Add( elemIDs );
+        newGroup = SMESH::SMESH_GroupBase::_narrow( stdlGroup );
+      }
+    }
+    else if ( !geomGroup->_is_nil() )
+    {
+      GEOM::GEOM_Object_var    geom = geomGroup->GetShape();
+      GEOM::GEOM_Object_var newGeom = shapeMapper.FindNew( geom );
+      if ( newGeom->_is_nil() )
+      {
+        newGroup = theNewMesh->CreateGroup( elemType, name ); // just to notify the user
+        shapeMapper.AddInvalid( geom, ObjectToSObject( newGroup ));
+        ok = false;
+      }
+      else
+      {
+        newGroup = theNewMesh->CreateGroupFromGEOM( elemType, name, newGeom );
+      }
+    }
+    else if ( !fltrGroup->_is_nil() )
+    {
+      // replace geometry in a filter
+      SMESH::Filter_var filter = fltrGroup->GetFilter();
+      SMESH::Filter::Criteria_var criteria;
+      filter->GetCriteria( criteria.out() );
+
+      bool isMissingGroup = false;
+      std::vector< std::string > badEntries;
+
+      for ( CORBA::ULong iCr = 0; iCr < criteria->length(); ++iCr )
+      {
+        const char* thresholdID = criteria[ iCr ].ThresholdID.in();
+        switch ( criteria[ iCr ].Type )
+        {
+        case SMESH::FT_BelongToMeshGroup:
+        {
+          SALOME::GenericObj_wrap< SMESH::BelongToMeshGroup > btgg = filterMgr->CreateBelongToMeshGroup();
+          btgg->SetGroupID( thresholdID );
+          SMESH::SMESH_GroupBase_ptr refGroup = btgg->GetGroup();
+          SALOMEDS::SObject_wrap   refGroupSO = ObjectToSObject( refGroup );
+          if ( refGroupSO->_is_nil() )
+            break;
+          CORBA::String_var     refID = refGroupSO->GetID();
+          TStr2StrMap::iterator o2nID = old2newGroupMap.find( refID.in() );
+          if ( o2nID == old2newGroupMap.end() )
+          {
+            isMissingGroup = true; // corresponding new group not yet created
+            break;
+          }
+          criteria[ iCr ].ThresholdID = o2nID->second.c_str();
+
+          if ( o2nID->second.empty() ) // new referred group is invalid
+            badEntries.push_back( refID.in() );
+          break;
+        }
+        case SMESH::FT_BelongToGeom:
+        case SMESH::FT_BelongToPlane:
+        case SMESH::FT_BelongToCylinder:
+        case SMESH::FT_BelongToGenSurface:
+        case SMESH::FT_LyingOnGeom:
+        {
+          std::string newID = shapeMapper.FindNew( thresholdID );
+          criteria[ iCr ].ThresholdID = newID.c_str();
+          if ( newID.empty() )
+            badEntries.push_back( thresholdID );
+          break;
+        }
+        case SMESH::FT_ConnectedElements:
+        {
+          if ( thresholdID && thresholdID[0] )
+          {
+            std::string newID = shapeMapper.FindNew( thresholdID );
+            criteria[ iCr ].ThresholdID = newID.c_str();
+            if ( newID.empty() )
+              badEntries.push_back( thresholdID );
+          }
+          break;
+        }
+        default:;
+        }
+      } // loop on criteria
+
+      if ( isMissingGroup && i < nbGroups )
+      {
+        // to treat the group again
+        append( groups, SMESH::SMESH_GroupBase::_duplicate( groups[ i ]));
+        ++nbAddedGroups;
+        continue;
+      }
+      SMESH::Filter_var newFilter = filterMgr->CreateFilter();
+      newFilter->SetCriteria( criteria );
+
+      newGroup = theNewMesh->CreateGroupFromFilter( elemType, name, newFilter );
+      newFilter->UnRegister();
+
+      SALOMEDS::SObject_wrap newSO = ObjectToSObject( newGroup );
+      for ( size_t iEnt = 0; iEnt < badEntries.size(); ++iEnt )
+        shapeMapper.AddInvalid( badEntries[ iEnt ], newSO );
+
+      if ( isMissingGroup ) // all groups treated but a referred groups still not found
+      {
+        invalidSObjects.push_back( ObjectToSObject( newGroup ));
+        ok = false;
+      }
+      if ( !badEntries.empty() )
+        ok = false;
+
+    } // treat a group on filter
+
+    append( theNewGroups, newGroup );
+
+    // fill old2newGroupMap
+    SALOMEDS::SObject_wrap srcSO = ObjectToSObject( groups[i] );
+    SALOMEDS::SObject_wrap newSO = ObjectToSObject( newGroup );
+    if ( !srcSO->_is_nil() )
+    {
+      CORBA::String_var srcID, newID;
+      srcID = srcSO->GetID();
+      if ( !newSO->_is_nil() )
+        newID = newSO->GetID();
+      old2newGroupMap.insert( std::make_pair( std::string( srcID.in() ),
+                                              std::string( newID.in() )));
+    }
+
+    if ( newGroup->_is_nil() )
+      ok = false;
+
+  } // loop on groups
+
+  // set mesh name
+  SALOMEDS::SObject_wrap soNew = ObjectToSObject( theNewMesh );
+  SALOMEDS::SObject_wrap soOld = ObjectToSObject( theSourceMesh );
+  CORBA::String_var oldName = soOld->GetName();
+  SetName( soNew, oldName.in(), "Mesh" );
+
+  // mark invalid objects
+  shapeMapper.GetInvalid( theInvalidEntries, invalidSObjects );
+
+  for ( size_t i = 0; i < invalidSObjects.size(); ++i )
+    highLightInvalid( invalidSObjects[i].in(), true );
+
+  pyDump << "ok, "
+         << theNewMesh << ", "
+         << theNewGroups << ", "
+         << *theNewSubmeshes.ptr() << ", "
+         << *theNewHypotheses.ptr() << ", "
+         << "invalidEntries = " << this << ".CopyMeshWithGeom( "
+         << theSourceMesh << ", "
+         << theNewGeometry << ", "
+         << "'" << theMeshName << "', "
+         << theToCopyGroups << ", "
+         << theToReuseHypotheses << ", "
+         << theToCopyElements << " )";
+
+  SMESH_CATCH( SMESH::throwCorbaException );
+
+  return ok;
+}
+
 //================================================================================
 /*!
  * \brief Get version of MED format being used.
index 21f55355e872ef23cfced32efb58fe5750dc2458..1209ec7afbb494ff0602a99a0c427cc6fa7dbdfd 100644 (file)
@@ -246,9 +246,24 @@ public:
   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 );
@@ -504,6 +519,7 @@ public:
                                       GEOM::GEOM_Object_ptr  theShapeObject,
                                       const char*            theName = 0);
   void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
+  void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid);
   bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr       theMesh,
                             GEOM::GEOM_Object_ptr       theShapeObject,
                             SMESH::SMESH_Hypothesis_ptr theHyp);
@@ -608,6 +624,14 @@ private:
   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,
index 49e74979e063b731abec74d48216229f69410cdd..69a8f73b0288ff85c195d275d3bc0213627100d9 100644 (file)
@@ -452,6 +452,9 @@ static void addReference (SALOMEDS::SObject_ptr theSObject,
 
     aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
 
+    // make the reference visible (invisible ref is created by createInvalidSubMesh())
+    aStudyBuilder->RemoveAttribute( aReferenceSO, "AttributeDrawable" );
+
     // add reference to the use case tree
     // (to support tree representation customization and drag-n-drop)
     SALOMEDS::UseCaseBuilder_wrap  useCaseBuilder = aStudy->GetUseCaseBuilder();
@@ -689,6 +692,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr    theM
   if ( theMesh->_is_nil() || theSubMesh->_is_nil() || theShapeObject->_is_nil() )
     return SALOMEDS::SObject::_nil();
 
+  std::string newName( theName ? theName : "" );
+
   SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theSubMesh );
   if ( aSubMeshSO->_is_nil() )
   {
@@ -740,15 +745,37 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr    theM
 
     SetName( aRootSO, aRootName );
 
-    // Add new submesh to corresponding sub-tree
+    // Add new sub-mesh to corresponding sub-tree
+    int tag = 0; // to use a new SObject
+    if ( theName && theName[0] == '0' )
+    {
+      // theName can be an entry of an invalid sub-mesh which theSubMesh should replace
+      SALOMEDS::SObject_wrap aSObj = getStudyServant()->FindObjectID( theName );
+      if ( aSObj )
+      {
+        CORBA::String_var oldName = aSObj->GetName();
+        newName = oldName.in();
+        SALOMEDS::SObject_wrap aRootSO2 = aSObj->GetFather();
+        if ( aRootSO->Tag() == aRootSO2->Tag() ) // same parent
+          tag = aSObj->Tag(); // to use the same SObject
+        else
+        {
+          CORBA::Object_var anObj = SObjectToObject( aSObj );
+          SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( anObj );
+          theMesh->RemoveSubMesh( sm );
+        }
+      }
+    }
     SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes();
     const int isEmpty = ( elemTypes->length() == 0 );
     const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" };
-    aSubMeshSO = publish ( theSubMesh, aRootSO, 0, pm[isEmpty] );
+    aSubMeshSO = publish ( theSubMesh, aRootSO, tag, pm[isEmpty] );
     if ( aSubMeshSO->_is_nil() )
       return aSubMeshSO._retn();
+
+    highLightInvalid( aSubMeshSO, false ); // now it is valid
   }
-  SetName( aSubMeshSO, theName, "SubMesh" );
+  SetName( aSubMeshSO, newName.c_str(), "SubMesh" );
 
   // Add reference to theShapeObject
 
@@ -757,7 +784,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr    theM
   // Publish hypothesis
 
   SMESH::ListOfHypothesis_var hypList = theMesh->GetHypothesisList( theShapeObject );
-  for ( CORBA::ULong i = 0; i < hypList->length(); i++ ) {
+  for ( CORBA::ULong i = 0; i < hypList->length(); i++ )
+  {
     SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]);
     SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp );
     AddHypothesisToShape( theMesh, theShapeObject, aHyp );
@@ -965,6 +993,42 @@ void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh )
   }
 }
 
+//=======================================================================
+//function : HighLightInvalid
+//purpose  : change font color of a object in the Object Browser
+//=======================================================================
+
+void SMESH_Gen_i::HighLightInvalid( CORBA::Object_ptr theObject, bool isInvalid )
+{
+  SALOMEDS::SObject_wrap so = ObjectToSObject(theObject);
+  highLightInvalid( so.in(), isInvalid );
+}
+
+//=======================================================================
+//function : highLightInvalid
+//purpose  : change font color of a object in the Object Browser
+//=======================================================================
+
+void SMESH_Gen_i::highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInvalid )
+{
+  if ( !theSObject->_is_nil() )
+  {
+    SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
+    if ( isInvalid )
+    {
+      SALOMEDS::Color red = { 178,34,34 }; // to differ from reference color
+      SALOMEDS::GenericAttribute_wrap attr =
+        studyBuilder->FindOrCreateAttribute( theSObject, "AttributeTextColor" );
+      SALOMEDS::AttributeTextColor_wrap colorAttr = attr;
+      colorAttr->SetTextColor( red );
+    }
+    else
+    {
+      studyBuilder->RemoveAttribute( theSObject, "AttributeTextColor" );
+    }
+  }
+}
+
 //=======================================================================
 //function : GetMeshOrSubmeshByShape
 //purpose  : 
@@ -1339,6 +1403,50 @@ char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject)
   return aResult._retn();
 }
 
+//================================================================================
+/*!
+ * \brief Create a sub-mesh on a geometry that is not a sub-shape of the main shape
+ * for the case where a valid sub-shape not found by CopyMeshWithGeom().
+ * The invalid sub-mesh has GetId() < 0.
+ */
+//================================================================================
+
+SMESH::SMESH_subMesh_ptr
+SMESH_Gen_i::createInvalidSubMesh(SMESH::SMESH_Mesh_ptr theMesh,
+                                  GEOM::GEOM_Object_ptr theStrangerGeom,
+                                  const char*           theName)
+{
+  SMESH::SMESH_subMesh_var subMesh;
+
+  try
+  {
+    SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
+    subMesh = mesh_i->createSubMesh( theStrangerGeom );
+
+    if ( !subMesh->_is_nil() && CanPublishInStudy( subMesh ))
+    {
+      SALOMEDS::SObject_wrap so = PublishSubMesh( theMesh, subMesh, theStrangerGeom, theName );
+
+      // hide a reference to geometry
+      if ( !so->_is_nil() )
+      {
+        SALOMEDS::SObject_wrap refSO;
+        if ( so->FindSubObject( GetRefOnShapeTag(), refSO.inout() ))
+        {
+          SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
+          SALOMEDS::GenericAttribute_wrap attr =
+            studyBuilder->FindOrCreateAttribute( refSO, "AttributeDrawable" );
+          SALOMEDS::AttributeDrawable_wrap ga = attr;
+          ga->SetDrawable( false );
+        }
+      }
+    }
+  }
+  catch (...) {
+  }
+
+  return subMesh._retn();
+}
 
 
 // ==============
index 354a1daf0fbba3a0bbd680fbe2e5d60dddde8cdd..1c8257ddba7ba5135ecc30f96eaa253695a0263a 100644 (file)
@@ -838,7 +838,13 @@ void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter)
     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 f713bfd2dfdb3aed84d9ba012b1aa1fd88b3e5ce..8523c787a807791ee84cc9269cc22b1ce0b0ff2d 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <map>
 #include <string>
+#include <vector>
 
 class TCollection_AsciiString;
 
@@ -97,7 +98,18 @@ public:
   // 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:
 
index 8dc1b25b585e3bb0def9dcdef7cef4d507dc6adc..128dbed1cb010b61251830196d7a439a9541ee17 100644 (file)
@@ -2460,9 +2460,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);
-  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;
@@ -2477,7 +2493,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
-  addGeomGroupData( theSubShapeObject, subMesh );
+  if ( subMeshId > 0 )
+    addGeomGroupData( theSubShapeObject, subMesh );
 
   return subMesh._retn();
 }
@@ -2513,7 +2530,8 @@ bool SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh,
 
   if ( theSubShapeObject->_is_nil() )  // not published shape (IPAL13617)
   {
-    if ( _mapSubMesh.find( subMeshId ) != _mapSubMesh.end())
+    if ( _mapSubMesh.find( subMeshId ) != _mapSubMesh.end() &&
+         _mapSubMesh[ subMeshId ])
     {
       TopoDS_Shape S = _mapSubMesh[ subMeshId ]->GetSubShape();
       if ( !S.IsNull() )
@@ -2735,7 +2753,7 @@ namespace
     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(); }
   };
 }
@@ -2746,13 +2764,30 @@ namespace
  */
 //================================================================================
 
-void SMESH_Mesh_i::onHypothesisModified()
+void SMESH_Mesh_i::onHypothesisModified(int theHypID)
 {
   if ( _preMeshInfo )
     _preMeshInfo->ForgetOrLoad();
 
   SMESH::SMESH_Mesh_var mesh = _this();
   _gen_i->UpdateIcons( mesh );
+
+  // mark a hypothesis as valid after edition
+  SALOMEDS::SComponent_wrap smeshComp = _gen_i->PublishComponent();
+  SALOMEDS::SObject_wrap hypRoot;
+  if ( !smeshComp->_is_nil() && 
+       smeshComp->FindSubObject( _gen_i->GetHypothesisRootTag(), hypRoot.inout() ))
+  {
+    SALOMEDS::ChildIterator_wrap anIter = _gen_i->getStudyServant()->NewChildIterator( hypRoot );
+    for ( ; anIter->More(); anIter->Next() )
+    {
+      SALOMEDS::SObject_wrap    hypSO = anIter->Value();
+      CORBA::Object_var           obj = _gen_i->SObjectToObject( hypSO );
+      SMESH::SMESH_Hypothesis_var hyp = SMESH::SMESH_Hypothesis::_narrow( obj );
+      if ( !hyp->_is_nil() && hyp->GetId() == theHypID )
+        _gen_i->HighLightInvalid( hyp, false );
+    }
+  }
 }
 
 //=============================================================================
index 867949a9d1df28f1f6741a16d6a9e75a96d83ab9..7e612be13d6755f2069401ea649c9f4f6a929da5 100644 (file)
@@ -439,7 +439,7 @@ public:
   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();
index 7ffedf1d4eeed4e0b958bf6f8a7778027a3e1779..76a23315af3c47681c3df076966e431d69faab9a 100644 (file)
@@ -540,6 +540,16 @@ namespace SMESH
     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
index 793e4a4a18071b4fcc431fcdf015280df15908ef..37393b23f72024f62363894f9db40a169e30a4d6 100644 (file)
@@ -227,6 +227,12 @@ namespace SMESH
     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);
 
index 4737a7b0e8eb28a7a8060d80a29beea5b64750e8..92d6034e44a2cc5b3bc0cfcda108b5daa5b1366c 100644 (file)
@@ -96,6 +96,8 @@ typedef list<SMESHDS_SubMesh*> TListOfSubMeshes;
 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,
@@ -582,3 +584,30 @@ SALOMEDS::TMPFile* SMESH_subMesh_i::GetVtkUgStream()
   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 b5a8140807df9662ea4ebdcdf17aa6300f7ede7e..cbdb796e0d3e5f97f16c89b4882871219a189b45 100644 (file)
@@ -130,4 +130,26 @@ protected:
   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
index d0bb913c11682872c1ef060c2bcc26a2d4dfd135..a93d9f7320d98c56cb5445402405658c1b6909a6 100755 (executable)
@@ -782,11 +782,46 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
                 an instance of class :class:`Mesh`
         """
 
-        if (isinstance( meshPart, Mesh )):
+        if isinstance( meshPart, Mesh ):
             meshPart = meshPart.GetMesh()
         mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
         return Mesh(self, self.geompyD, mesh)
 
+    def CopyMeshWithGeom( self, sourceMesh, newGeom, meshName="", toCopyGroups=True,
+                          toReuseHypotheses=True, toCopyElements=True):
+        """
+        Create a mesh by copying a mesh definition (hypotheses and groups) to a new geometry.
+        It is supposed that the new geometry is a modified geometry of *sourceMesh*.
+        To facilitate and speed up the operation, consider using
+        "Set presentation parameters and sub-shapes from arguments" option in
+        a dialog of geometrical operation used to create the new geometry.
+
+        Parameters:
+                sourceMesh: the mesh to copy definition of.
+                newGeom: the new geomtry.
+                meshName: an optional name of the new mesh. If omitted, the mesh name is kept.
+                toCopyGroups: to create groups in the new mesh.
+                toReuseHypotheses: to reuse hypotheses of the *sourceMesh*.
+                toCopyElements: to copy mesh elements present on non-modified sub-shapes of 
+                                *sourceMesh*.
+        Returns:
+                tuple ( ok, newMesh, newGroups, newSubMeshes, newHypotheses, invalidEntries )
+                *invalidEntries* are study entries of objects whose
+                counterparts are not found in the *newGeom*, followed by entries
+                of mesh sub-objects that are invalid because they depend on a not found
+                preceeding sub-shape
+        """
+        if isinstance( sourceMesh, Mesh ):
+            sourceMesh = sourceMesh.GetMesh()
+
+        ok, newMesh, newGroups, newSubMeshes, newHypotheses, invalidEntries = \
+           SMESH._objref_SMESH_Gen.CopyMeshWithGeom( self, sourceMesh, newGeom, meshName,
+                                                     toCopyGroups,
+                                                     toReuseHypotheses,
+                                                     toCopyElements)
+        return ( ok, Mesh(self, self.geompyD, newMesh),
+                 newGroups, newSubMeshes, newHypotheses, invalidEntries )
+
     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
         """
         Return IDs of sub-shapes
@@ -6156,7 +6191,7 @@ class Mesh(metaclass = MeshMeta):
         Fill with 2D elements a hole defined by a SMESH.FreeBorder.
 
         Parameters:
-            FreeBorder: either a SMESH.FreeBorder or a list on node IDs. These nodes
+            holeNodes: either a SMESH.FreeBorder or a list on node IDs. These nodes
                 must describe all sequential nodes of the hole border. The first and the last
                 nodes must be the same. Use :meth:`FindFreeBorders` to get nodes of holes.
             groupName (string): name of a group to add new faces
index 89cea269a479528f6a5ee04bb96db512cb966b3c..18f0da94579a3941486df522c1f0577d367acd50 100644 (file)
@@ -49,7 +49,7 @@ using namespace std;
 //=============================================================================
 
 StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, SMESH_Gen * gen)
-  :SMESH_Hypothesis(hypId, gen)
+  :StdMeshers_Reversible1D(hypId, gen)
 {
   _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();
@@ -165,28 +150,6 @@ istream & StdMeshers_Arithmetic1D::LoadFrom(istream & 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
index e0b9cd9b76bd79889062e82ecfb10a077730370e..eb1a8f43767dcbe5d05e562e54bd1e0a48e03126 100644 (file)
 
 #include "SMESH_StdMeshers.hxx"
 
+#include "StdMeshers_Reversible1D.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
-#include <vector>
-
-class STDMESHERS_EXPORT StdMeshers_Arithmetic1D:
-  public SMESH_Hypothesis
+class STDMESHERS_EXPORT StdMeshers_Arithmetic1D: public StdMeshers_Reversible1D
 {
 public:
   StdMeshers_Arithmetic1D(int hypId, SMESH_Gen* gen);
@@ -48,18 +46,8 @@ public:
 
   double GetLength(bool isStartLength) const;
 
-  void SetReversedEdges( std::vector<int>& ids);
-
-  void SetObjectEntry( const char* entry ) { _objEntry = entry; }
-
-  const char* GetObjectEntry() { return _objEntry.c_str(); }
-
-  const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
-
   virtual std::ostream & SaveTo(std::ostream & save);
   virtual std::istream & LoadFrom(std::istream & load);
-  friend std::ostream& operator << (std::ostream & save, StdMeshers_Arithmetic1D & hyp);
-  friend std::istream& operator >> (std::istream & load, StdMeshers_Arithmetic1D & hyp);
 
   /*!
    * \brief Initialize start and end length by the mesh built on the geometry
@@ -77,8 +65,6 @@ public:
 
 protected:
   double _begLength, _endLength;
-  std::vector<int>   _edgeIDs;
-  std::string        _objEntry;
 };
 
 #endif
index b5934045b4fa19d3558f49faca6e0ac3453548dd..be0917ef26d3a765223910b61646514b94a84232 100644 (file)
@@ -35,9 +35,8 @@ using namespace std;
  */
 //=============================================================================
 
-StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId,
-                                                   SMESH_Gen * gen)
-  :SMESH_Hypothesis(hypId, gen)
+StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, SMESH_Gen * gen)
+  :StdMeshers_Reversible1D(hypId, gen)
 {
   _name = "FixedPoints1D";
   _param_algo_dim = 1;
@@ -81,27 +80,6 @@ void StdMeshers_FixedPoints1D::SetNbSegments(std::vector<int>& listNbSeg)
   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();
index 05f9030135a5c0abf7b5595a2351fb6e97844299..58b9be6443c20ccf086b958c85d759c49e002254 100644 (file)
 
 #include "SMESH_StdMeshers.hxx"
 
+#include "StdMeshers_Reversible1D.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
 #include <vector>
 
-class STDMESHERS_EXPORT StdMeshers_FixedPoints1D:
-  public SMESH_Hypothesis
+class STDMESHERS_EXPORT StdMeshers_FixedPoints1D: public StdMeshers_Reversible1D
 {
 public:
   StdMeshers_FixedPoints1D(int hypId, SMESH_Gen* gen);
@@ -51,14 +51,6 @@ public:
 
   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);
 
@@ -79,8 +71,6 @@ public:
 protected:
   std::vector<double> _params;
   std::vector<int>    _nbsegs;
-  std::vector<int>    _edgeIDs;
-  std::string         _objEntry;
 };
 
 #endif
index 5ba6e47d9d31a3cf1c3baa452f834274455ff0ee..927613048af8a1cb7c933d5db38edfbeb96ae8db 100644 (file)
@@ -60,7 +60,7 @@ const double PRECISION = 1e-7;
 
 StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int         hypId,
                                                          SMESH_Gen * gen)
-  : SMESH_Hypothesis(hypId, gen),
+  : StdMeshers_Reversible1D(hypId, gen),
     _numberOfSegments(15),//issue 19923
     _distrType(DT_Regular),
     _scaleFactor(1.),
@@ -721,19 +721,3 @@ bool StdMeshers_NumberOfSegments::SetParametersByDefaults(const TDefaults&  dflt
 {
   return (_numberOfSegments = dflts._nbSegments );
 }
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-void StdMeshers_NumberOfSegments::SetReversedEdges( std::vector<int>& ids )
-{
-  if ( ids != _edgeIDs ) {
-    _edgeIDs = ids;
-
-    NotifySubMeshesHypothesisModification();
-  }
-}
-
index 6e9e59e3eaefc37347ee35baec1a18a9a6529ff0..3a71f8e0dee24749074daa2771f5739facaeb29d 100644 (file)
 #ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
 #define _SMESH_NUMBEROFSEGMENTS_HXX_
 
-#include "SMESH_StdMeshers.hxx"
-
+#include "StdMeshers_Reversible1D.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
+
 #include <vector>
 
 /*!
@@ -41,8 +41,7 @@
  * It provides parameters for subdivision an edge by various
  * distribution types, considering the given number of resulting segments
  */
-class STDMESHERS_EXPORT StdMeshers_NumberOfSegments:
-  public SMESH_Hypothesis
+class STDMESHERS_EXPORT StdMeshers_NumberOfSegments: public StdMeshers_Reversible1D
 {
 public:
   StdMeshers_NumberOfSegments(int hypId, SMESH_Gen* gen);
@@ -171,14 +170,6 @@ public:
   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
@@ -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<int>    _edgeIDs;          //!< list of reversed edges ids
-  std::string         _objEntry;          //!< Entry of the main object to reverse edges
 };
 
 #endif
index 64247e0b63e89918ccd2fcb15282a7a8f3cda87c..392447eab0e9990fc48066c94fa695781aa40d4d 100644 (file)
@@ -51,7 +51,7 @@ public:
   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; }
index 00d61a1dae6ea95b0497dc929d73f87a89e1ec29..e2651cd41648d86d6959598e3a628d2a63e8d577 100644 (file)
@@ -44,7 +44,7 @@ public:
 
   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; }
 
index a2bf0f7e116cf39607ee72234659af1c60773e4d..b89af167752bf70f29e7c597d6d476d920e554a3 100644 (file)
@@ -47,9 +47,8 @@ using namespace std;
  */
 //=============================================================================
 
-StdMeshers_StartEndLength::StdMeshers_StartEndLength(int         hypId,
-                                                     SMESH_Gen * gen)
-     :SMESH_Hypothesis(hypId, gen)
+StdMeshers_StartEndLength::StdMeshers_StartEndLength( int hypId, SMESH_Gen* gen )
+  :StdMeshers_Reversible1D(hypId, gen)
 {
   _begLength = 1.;
   _endLength = 10.;
@@ -105,21 +104,6 @@ double StdMeshers_StartEndLength::GetLength(bool isStartLength) const
  */
 //=============================================================================
 
-void StdMeshers_StartEndLength::SetReversedEdges( std::vector<int>& ids )
-{
-  if ( ids != _edgeIDs ) {
-    _edgeIDs = ids;
-
-    NotifySubMeshesHypothesisModification();
-  }
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
 ostream & StdMeshers_StartEndLength::SaveTo(ostream & save)
 {
   int listSize = _edgeIDs.size();
@@ -166,28 +150,6 @@ istream & StdMeshers_StartEndLength::LoadFrom(istream & 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
index 576d8e1992ee3ef041386b4392352a03953d4f28..dbe7a501cf7c65e4f73b745ef321660ce30a527e 100644 (file)
 
 #include "SMESH_StdMeshers.hxx"
 
+#include "StdMeshers_Reversible1D.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
 #include <vector>
 
-class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
+class STDMESHERS_EXPORT StdMeshers_StartEndLength: public StdMeshers_Reversible1D
 {
  public:
   StdMeshers_StartEndLength(int hypId, SMESH_Gen * gen);
@@ -44,19 +45,8 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
 
   double GetLength(bool isStartLength) const;
 
-  void SetReversedEdges( std::vector<int>& ids);
-
-  const std::vector<int>& GetReversedEdges() const { return _edgeIDs; }
-
-  void SetObjectEntry( const char* entry ) { _objEntry = entry; }
-
-  const char* GetObjectEntry() { return _objEntry.c_str(); }
-  
   virtual std::ostream & SaveTo(std::ostream & save);
   virtual std::istream & LoadFrom(std::istream & load);
-  friend std::ostream & operator <<(std::ostream & save, StdMeshers_StartEndLength & hyp);
-  friend std::istream & operator >>(std::istream & load, StdMeshers_StartEndLength & hyp);
-
 
   /*!
    * \brief Initialize start and end length by the mesh built on the geometry
@@ -74,8 +64,6 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
 
 protected:
   double _begLength, _endLength;
-  std::vector<int>   _edgeIDs;
-  std::string        _objEntry;
 };
 
 #endif
index 060b8b42af428096df35cce90ebc5c258153566f..b83fc0ba57438e86a2a6fba6ffe73aa4cb0e257e 100644 (file)
@@ -83,6 +83,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 );
+
+  // 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
index 9676549e2a17bae34ace0cdb9915cea624d6dcf3..a7cd08ead31199641e4aec6f37d1096af96ec7e1 100644 (file)
@@ -48,7 +48,8 @@ using namespace std;
 StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr thePOA,
                                                       ::SMESH_Gen*            theGenImpl )
      : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA )
+       SMESH_Hypothesis_i( thePOA ),
+       StdMeshers_Reversible1D_i( this )
 {
   myBaseImpl = new ::StdMeshers_Arithmetic1D( theGenImpl->GetANewId(),
                                               theGenImpl );
@@ -131,98 +132,6 @@ CORBA::Double StdMeshers_Arithmetic1D_i::GetLength( CORBA::Boolean 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
@@ -261,3 +170,30 @@ std::string StdMeshers_Arithmetic1D_i::getMethodOfParameter(const int paramIndex
 {
   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 f159f0c48a496404fa101380a0ec428e5cd2036d..ad191a26a6699f653be1f3c216a333a2de0599e2 100644 (file)
@@ -33,7 +33,7 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
-#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_Reversible1D_i.hxx"
 #include "StdMeshers_Arithmetic1D.hxx"
 
 // ======================================================
@@ -41,7 +41,8 @@
 // ======================================================
 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
@@ -64,24 +65,23 @@ public:
   // Get length
   CORBA::Double GetLength(CORBA::Boolean theIsStart);
 
-  //Set Reversed Edges
-  void SetReversedEdges( const SMESH::long_array& theIDs);
-
-  //Get Reversed Edges
-  SMESH::long_array*  GetReversedEdges();
-  
-  //Set the Entry of the Object
-  void SetObjectEntry( const char* theEntry);
-
-  //Get Object Entry
-  char* GetObjectEntry();
-
   // Get implementation
   ::StdMeshers_Arithmetic1D* GetImpl();
 
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
 
+
+  // Methods for copying mesh definition to other geometry
+
+  // Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+  virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
+                                   std::vector< int >         & subIDArray ) const;
+
+  // Set new geometry instead of that returned by getObjectsDependOn()
+  virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
+                                   std::vector< int >         & subIDArray );
+
  protected:
   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
 };
index a2b4772e614d2ac67c03c11e9a019843d0f2a3ca..e7d4ae4504f2e167a464e9e7e42d471fc3b66a4f 100644 (file)
@@ -66,6 +66,12 @@ public:
   
   // 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
index d9f4d603ab046f60107623980b64f47dd031ac42..4f37edc3a5b1f2a090af04fb7ea6f184a01da0c9 100644 (file)
@@ -141,6 +141,13 @@ class STDMESHERS_I_EXPORT StdMeshers_CartesianParameters3D_i:
 
   // 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
index 9078455c6be5bf7dcf9901e5a3bf0bcbe2ff8917..71277100b5c8d045cbc0389a7e7d75e71caf8912 100644 (file)
@@ -65,6 +65,11 @@ public:
   // 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;
 };
index 08829204e816581f473552e8ede5fd1e98490407..7dc131acfce47b324555f02894916be3a95cd0a8 100644 (file)
@@ -45,8 +45,9 @@ using namespace std;
 
 StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA,
                                                         ::SMESH_Gen*            theGenImpl )
-     : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA )
+  : SALOME::GenericObj_i( thePOA ),
+    SMESH_Hypothesis_i( thePOA ),
+    StdMeshers_Reversible1D_i( this )
 {
   myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
                                               theGenImpl);
@@ -156,98 +157,6 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
   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
@@ -269,9 +178,34 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
  * 
  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
  */
-//================================================================================  
+//================================================================================
 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
 {
   return type == SMESH::DIM_1D;
 }
 
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_FixedPoints1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                std::vector< int >         & subIDArray ) const
+{
+  return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
+}
+
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_FixedPoints1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                std::vector< int >         & subIDArray )
+{
+  return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
+}
index 98d1aff47c442f07ad232406b0f88a00b91c8bff..0a86129ac98b5596835f9f8543150af23395421f 100644 (file)
@@ -30,7 +30,7 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
-#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_Reversible1D_i.hxx"
 #include "StdMeshers_FixedPoints1D.hxx"
 
 // ======================================================
@@ -38,7 +38,8 @@
 // ======================================================
 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
@@ -62,23 +63,22 @@ public:
   // Returns list of numbers of segments
   SMESH::long_array* GetNbSegments();
     
-  //Set Reversed Edges
-  void SetReversedEdges( const SMESH::long_array& theIDs);
-
-  //Get Reversed Edges
-  SMESH::long_array*  GetReversedEdges();
-  
-  //Set the Entry of the Object
-  void SetObjectEntry( const char* theEntry);
-
-  //Get Object Entry
-  char* GetObjectEntry();
-
   // Get implementation
   ::StdMeshers_FixedPoints1D* GetImpl();
 
   // Verify whether hypothesis supports given entity type 
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
+
+
+  // Methods for copying mesh definition to other geometry
+
+  // Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+  virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
+                                   std::vector< int >         & subIDArray ) const;
+
+  // Set new geometry instead of that returned by getObjectsDependOn()
+  virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
+                                   std::vector< int >         & subIDArray );
 };
 
 #endif
index 1d213d975dde2281b5119cdfbd46dbded5533f14..2b5f241bcce8a3e0230b857369cf136fdcef3b3a 100644 (file)
@@ -127,15 +127,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)
  */
-//================================================================================  
+//================================================================================
 
 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 542e88e5e8ee3e47214653ab907ea9e7a0ba6fa6..6ccb5d70a7ccf9fc09c23db206fcdd75a5c9bc46 100644 (file)
@@ -59,6 +59,18 @@ class STDMESHERS_I_EXPORT StdMeshers_Geometric1D_i:
 
   // 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
index 61d62654ee7cf8d200881c69f86028105ea4e83b..ab1e9bb6cc0a80246ab9ca955acaa291319115c6 100644 (file)
@@ -64,6 +64,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ImportSource1D_i:
   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;
index 8b346df678bfe6d81a350d285026fa31036c45a3..f377bceb1257a872fb66299d26449442f6b76c27 100644 (file)
@@ -64,6 +64,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ImportSource2D_i:
   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;
index 2831138b9e78eab0c7f78b2b7bdf585c39615ca2..9b9ba7a52fc557c5b34706746c07e419ad756c99 100644 (file)
@@ -54,6 +54,17 @@ public:
   // 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
index 69050ee700967ac7d3e527c6f2a1d8e5654e5ce1..43942228cf943644b3670920b24579e5c2e08a1b 100644 (file)
@@ -77,6 +77,17 @@ public:
   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);
index 0318fd0e1822a0679cbe50ae03c07960ab550172..17cde7be84209d8dfa07b8b70a14fba7b1af88ab 100644 (file)
@@ -66,6 +66,17 @@ public:
   
   // 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
index 14a01b76d32a0bf2547f0a1a950a5cb342ed15c4..0fcd0d08991fda2f4a090444a88dc830cb738f8d 100644 (file)
@@ -71,6 +71,17 @@ public:
   // 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;
 };
index 7f7fe254f1eb354acf7afc326666fc765e443ed7..0651ac899c2426ab94efa49df181d232812dea69 100644 (file)
@@ -63,6 +63,18 @@ public:
   // 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;
 };
index d40369cb78e6a6db5a3c18291d64509ec30025b0..108b9804c76c5a5e6d45b04c1757b4cae24fafde 100644 (file)
@@ -63,6 +63,17 @@ public:
   // 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;
 };
index b4b63323152b2c9525ded9f5ecda4cf7efb69d2d..bd1ea6334a9f03d53d1c499b79c4227b85b824ee 100644 (file)
@@ -77,6 +77,17 @@ public:
   // 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;
 };
index ee4107f10dac60d84816e76e039a7375dc9a31ce..510d0cf1a79b8c5ea79ce44fe7e5fab005ade21e 100644 (file)
@@ -50,6 +50,17 @@ public:
   // 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;
 };
index 42672b838d9cfed1786b386fb02045af29af9763..4534245a9a4ae5f6af40e96bbc237184d5006b9d 100644 (file)
@@ -52,6 +52,17 @@ public:
   
   // 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
index 77a619883fd69b5296616047c9ec8f5a84203f2f..13649309f41186b98ba5b82152a5331d14371e81 100644 (file)
@@ -68,6 +68,17 @@ public:
   // 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;
 };
index c61aa3785b538b316a445bc773100a9ab58ac2f6..1c51633853f4be1dad9cd206f85495e6c187770b 100644 (file)
@@ -36,7 +36,6 @@
 
 #include <TCollection_AsciiString.hxx>
 
-using namespace std;
 //=============================================================================
 /*!
  *  StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i
@@ -47,8 +46,9 @@ using namespace std;
 
 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA,
                                                               ::SMESH_Gen*            theGenImpl )
-     : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA )
+  : SALOME::GenericObj_i( thePOA ),
+    SMESH_Hypothesis_i( thePOA ),
+    StdMeshers_Reversible1D_i( this )
 {
   myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
                                                   theGenImpl );
@@ -159,100 +159,6 @@ CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
   return this->GetImpl()->GetNumberOfSegments();
 }
 
-//=============================================================================
-/*!
- *  StdMeshers_NumberOfSegments_i::SetReversedEdges
- *
- *  Set edges to reverse
- */
-//=============================================================================
-
-void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds )
-{
-  ASSERT( myBaseImpl );
-  try {
-    std::vector<int> ids( theIds.length() );
-    CORBA::Long iEnd = theIds.length();
-    for ( CORBA::Long i = 0; i < iEnd; i++ )
-      ids[ i ] = theIds[ i ];
-
-    this->GetImpl()->SetReversedEdges( ids );
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-
-  // Update Python script
-  SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_NumberOfSegments_i::SetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* theEntry )
-{
-  ASSERT( myBaseImpl );
-  string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
-  try {
-    this->GetImpl()->SetObjectEntry( entry.c_str() );
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-  // Update Python script
-  SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_NumberOfSegments_i::GetObjectEntry
- *
- *  Set the Entry for the Main Object
- */
-//=============================================================================
-
-char* StdMeshers_NumberOfSegments_i::GetObjectEntry()
-{
-  ASSERT( myBaseImpl );
-
-  const char* entry;
-  try {
-    entry = this->GetImpl()->GetObjectEntry();
-  }
-  catch ( SALOME_Exception& S_ex ) {
-    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
-                                  SALOME::BAD_PARAM );
-  }
-  return CORBA::string_dup( entry );
-}
-
-//=============================================================================
-/*!
- *  StdMeshers_NumberOfSegments_i::GetReversedEdges
- *
- *  Get reversed edges
- */
-//=============================================================================
-
-SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges()
-{
-  ASSERT( myBaseImpl );
-  SMESH::long_array_var anArray = new SMESH::long_array;
-  std::vector<int> ids = this->GetImpl()->GetReversedEdges();
-  anArray->length( ids.size() );
-  for ( size_t i = 0; i < ids.size(); i++)
-    anArray [ i ] = ids [ i ];
-
-  return anArray._retn();
-}
-
 //=============================================================================
 /*!
  */
@@ -497,3 +403,30 @@ std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramI
 {
   return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
 }
+
+
+//================================================================================
+/*!
+ * \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 09301653b4b803aca0389b253fee3d96931f72f2..fc623af130864d02b25d5071285ff0799a755954 100644 (file)
@@ -35,7 +35,7 @@
 #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"
 
 // ======================================================
@@ -43,7 +43,8 @@
 // ======================================================
 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
@@ -104,18 +105,16 @@ public:
   // 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;
 };
index c7e3988b845e69486f2f04bd30f532d488c27a38..f9a2b7837efaa3e5dc87ba60c7ff79a4886ec9b1 100644 (file)
@@ -162,3 +162,21 @@ void StdMeshers_ObjRefUlils::SaveToStream( const std::string& 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::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() );
+    CORBA::Object_var       obj = gen->SObjectToObject( sobj );
+    GEOM::GEOM_Object_var  geom = GEOM::GEOM_Object::_narrow( obj );
+    shape = gen->GeomObjectToShape( geom.in() );
+  }
+  return shape;
+}
index fb2540c65c5331cfdda55ecb49db63e92a9e49f8..757cea4825936a504f486a1a4953f42819b8006e 100644 (file)
@@ -65,6 +65,13 @@ public:
        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
    */
index 7b4048662ec682fe71197117b45b25ab1952af9c..e0243b1878ac4118f5d8d6b210da7742d4504e64 100644 (file)
@@ -298,3 +298,46 @@ void StdMeshers_ProjectionSource1D_i::LoadFrom( const char* theStream )
     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 1b7c6981b386b5ed5a7add6625a455587b683e90..bbd1e5e58ffba6757aa95246e0de134264132cd1 100644 (file)
@@ -109,6 +109,15 @@ public:
   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
index ff036460353ccfe8ef201c736a13fe56b159ae29..5d3706d9f0c513c244cfdbd6c9d64c87befcbdf8 100644 (file)
@@ -311,3 +311,48 @@ void StdMeshers_ProjectionSource2D_i::LoadFrom( const char* theStream )
     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 2ba81dc0a3b8ceb73674f6bc2b02081e68857226..e8352df316d106bb3ecb3b8592200b32453bab75 100644 (file)
@@ -113,6 +113,16 @@ public:
   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
index 062602d89f4f2dce0f7a8db94a482b313f0cb0b8..bbbf9e3cb869f9443bae4019687cc44a0f7399b7 100644 (file)
@@ -312,3 +312,48 @@ void StdMeshers_ProjectionSource3D_i::LoadFrom( const char* theStream )
     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 5a25111cd20d37f04ffc6ebc2ab1059c7dcc9093..003181849fd330516bc146a6c9bb11d410e92bdc 100644 (file)
@@ -114,6 +114,17 @@ public:
   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
@@ -124,4 +135,3 @@ private:
 };
 
 #endif
-
index 961f203d1cc2d83a3f08906a1193044167e35e0b..ae5819c314033963975482f7223990674de70765 100644 (file)
@@ -52,6 +52,12 @@ public:
   
   // 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; }
 };
 
 // ======================================================
@@ -69,6 +75,12 @@ public:
   
   // 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
index 78b2841e1575a4d7a3f56809f3faaa3fe1a0ad2a..aa3f947dd7ad05156c0c36d8c896d91cfdd7feac 100644 (file)
@@ -378,3 +378,54 @@ void StdMeshers_QuadrangleParams_i::LoadFrom( const char* theStream )
 
   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 227dd86af497611380e676cfdaad148e32878931..822b501e5564fbbea1e0a02dba1f5de711405557 100644 (file)
@@ -84,6 +84,16 @@ public:
   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;
index e60f073296e2f573af037c5497c3c71981265064..5e0455ac0359824dbcbe7d78b1138be889173a7e 100644 (file)
@@ -58,6 +58,12 @@ public:
   
   // 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
index 71c17acad2fd90284205f80dd25e9a228c119af5..433b73734493fbbeab1fca336204f47a9381c8a7 100644 (file)
@@ -59,6 +59,12 @@ public:
   
   // 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
index 315f30b15db45ee496f036f0c40014849c8bd000..644aa7075a3ce71e142859c3292eb7d0b91ca0d8 100644 (file)
@@ -139,5 +139,46 @@ SMESH::long_array* StdMeshers_Reversible1D_i::GetReversedEdges()
 
 ::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 8e24f91025bf0e934ff48f84308e61e114f0efde..e80041c88185e88be9fbc4e70d25b91e905b4451 100644 (file)
@@ -36,7 +36,7 @@
 #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
@@ -59,8 +59,17 @@ class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i:
   // Get implementation
   ::StdMeshers_Reversible1D* GetImpl();
 
+
+  // Methods for copying mesh definition to other geometry
+
+  // Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+  virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
+                                   std::vector< int >         & subIDArray ) const;
+
+  // Set new geometry instead of that returned by getObjectsDependOn()
+  virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
+                                   std::vector< int >         & subIDArray );
  private:
   SMESH_Hypothesis_i* myHyp;
 };
-
 #endif
index 30ee53023710b196a88331a50f9d1c89c8bf23d3..c1491a4e1107b41c4c90b39be6cd6deb46aea845 100644 (file)
@@ -63,6 +63,16 @@ public:
   // 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;
 };
index aa38fc2ad01767d2b13a60c1aecbdedf90c69f6f..622474605d868544f29187e022650a69510680e2 100644 (file)
@@ -49,7 +49,8 @@ using namespace std;
 StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i( PortableServer::POA_ptr thePOA,
                                                           ::SMESH_Gen*            theGenImpl )
      : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA )
+       SMESH_Hypothesis_i( thePOA ),
+       StdMeshers_Reversible1D_i( this )
 {
   myBaseImpl = new ::StdMeshers_StartEndLength( theGenImpl->GetANewId(),
                                                 theGenImpl );
@@ -132,97 +133,6 @@ CORBA::Double StdMeshers_StartEndLength_i::GetLength( CORBA::Boolean 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
@@ -261,3 +171,29 @@ std::string StdMeshers_StartEndLength_i::getMethodOfParameter(const int paramInd
 {
   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 50e989105351ac2bf6794f18940f692ce73cc518..24fdb86a7b587357c069d20529c1dd3baa188c83 100644 (file)
@@ -34,7 +34,7 @@
 #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;
@@ -44,7 +44,8 @@ class SMESH_Gen;
 // ======================================================
 class STDMESHERS_I_EXPORT StdMeshers_StartEndLength_i:
   public virtual POA_StdMeshers::StdMeshers_StartEndLength,
-  public virtual SMESH_Hypothesis_i
+  public virtual SMESH_Hypothesis_i,
+  public virtual StdMeshers_Reversible1D_i
 {
 public:
   // Constructor
@@ -73,17 +74,16 @@ public:
   // 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;
index 638d03d9522d378dd9a86f077b3b45b7ec09aac5..c5877c77f63fe81e000633c7d2b08b022688b08c 100644 (file)
@@ -235,13 +235,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)
  */
-//================================================================================  
+//================================================================================
 
 CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type )
 {
@@ -251,7 +251,7 @@ CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension ty
 //================================================================================
 /*!
  * \brief Sets sub-mesh event listeners to clear sub-meshes of edges
- * shrinked by viscous layers
+ *        shrinked by viscous layers
  */
 //================================================================================
 
@@ -259,3 +259,43 @@ void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored()
 {
   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 0b28e8597a42b6f57a7fbbe3673a2a08e5467057..2ca1310f5d3a60a3281d199ca52d02525cd3dcc5 100644 (file)
@@ -73,6 +73,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();
+
+
+  // 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
index 6ae54c6e8cb0852b1709802429ec46cab75ee5ac..914d92260c364cc5621412940418e2d69dfb8c3c 100644 (file)
@@ -295,3 +295,44 @@ std::string StdMeshers_ViscousLayers_i::getMethodOfParameter(const int paramInde
   }
   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 19f5835b0232abdc8d10e1b3000dcef6f6d2db0f..246a9144294f4eef93d201639c66bf8667a7e083 100644 (file)
@@ -73,6 +73,15 @@ class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers_i:
   // 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;
 };