Salome HOME
Typo-fix by Kunda + fix user doc generation
[modules/smesh.git] / src / SMESH_I / SMESH_MeshEditor_i.cxx
index 9007b1b95ea9a575ce3e66558e3ae09058278e50..3d1a120a8758adee646ae2a8be25b8966974759a 100644 (file)
@@ -2597,7 +2597,7 @@ namespace MeshEditor_I
  *  \param [in] nbOfSteps - number of elements to generate from one element
  *  \param [in] toMakeGroups - if true, new elements will be included into new groups
  *              corresponding to groups the input elements included in.
- *  \return ListOfGroups - new groups craeted if \a toMakeGroups is true
+ *  \return ListOfGroups - new groups created if \a toMakeGroups is true
  */
 //=======================================================================
 
@@ -4034,6 +4034,7 @@ SMESH_MeshEditor_i::ScaleMakeMesh(SMESH::SMESH_IDSource_ptr  theObject,
 SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theObject,
                                                   CORBA::Double             theValue,
                                                   CORBA::Boolean            theCopyGroups,
+                                                  CORBA::Boolean            theCopyElements,
                                                   const char*               theMeshName,
                                                   SMESH::ListOfGroups_out   theGroups)
   throw (SALOME::SALOME_Exception)
@@ -4059,7 +4060,9 @@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theO
       TPreviewMesh * tmpMesh = getPreviewMesh();
       tgtMesh = tmpMesh;
       tmpMesh->Copy( elements, copyElements );
+      elements.swap( copyElements );
       theCopyGroups = false;
+      theCopyElements = false;
     }
     else
     {
@@ -4068,26 +4071,38 @@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theO
       SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var );
       tgtMesh = & mesh_i->GetImpl();
     }
-    groupIds = getEditor().Offset( elements, theValue, tgtMesh, theCopyGroups, !myIsPreviewMode );
+    groupIds = getEditor().Offset( elements, theValue, tgtMesh,
+                                   theCopyGroups, theCopyElements, !myIsPreviewMode );
 
     tgtMesh->GetMeshDS()->Modified();
   }
 
   if ( myIsPreviewMode )
   {
-    getPreviewMesh()->Remove( SMESHUtils::elemSetIterator( copyElements ));
+    //getPreviewMesh()->Remove( SMESHUtils::elemSetIterator( copyElements ));
   }
   else
   {
     theGroups = theCopyGroups ? getGroups( groupIds.get() ) : new SMESH::ListOfGroups;
 
+    if ( *theMeshName && mesh_var->NbFaces() == 0 )
+    {
+      // new mesh empty, remove it
+      SALOMEDS::Study_var          study = SMESH_Gen_i::getStudyServant();
+      SALOMEDS::StudyBuilder_var builder = study->NewBuilder();
+      SALOMEDS::SObject_wrap      meshSO = SMESH_Gen_i::ObjectToSObject( mesh_var );
+      builder->RemoveObjectWithChildren( meshSO );
+      THROW_SALOME_CORBA_EXCEPTION("Offset failed", SALOME::INTERNAL_ERROR);
+    }
+
     // result of Offset() is a tuple (mesh, groups)
     if ( mesh_var->_is_nil() ) pyDump << myMesh_i->_this() << ", ";
     else                       pyDump << mesh_var          << ", ";
-    pyDump << theGroups << " = "
-           << this << ".Offset( "
+    pyDump << theGroups << " = " << this << ".Offset( "
+           << theObject << ", "
            << theValue << ", "
            << theCopyGroups << ", "
+           << theCopyElements << ", "
            << "'" << theMeshName<< "')";
   }