Salome HOME
IPAL54401: Offset dialog bug
authoreap <eap@opencascade.com>
Tue, 19 Jun 2018 11:00:57 +0000 (14:00 +0300)
committereap <eap@opencascade.com>
Tue, 19 Jun 2018 11:00:57 +0000 (14:00 +0300)
doc/salome/gui/SMESH/input/radial_prism_algo.rst
idl/SMESH_MeshEditor.idl
src/SMESH/SMESH_MeshEditor.cxx
src/SMESH/SMESH_MeshEditor.hxx
src/SMESHGUI/SMESHGUI_OffsetDlg.cxx
src/SMESHUtils/SMESH_Offset.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx
src/SMESH_SWIG/StdMeshersBuilder.py

index c81d77cdb1d9b2add75ccb4b10962df53737cd14..7e2c1483921123cac3bb05db5b6bef7b1281ce95 100644 (file)
@@ -36,7 +36,7 @@ This information can be defined using either of two hypotheses:
 .. centered::
        *"Distribution of layers"* hypothesis
 
-*Distribution of layers* hypothesis allows using any of 
+*Distribution of layers* hypothesis allows using most of 
 :ref:`1D Hypotheses <a1d_meshing_hypo_page>` to define
 the distribution of mesh layers.
 
index d0748bac7657f670f5d8838b01a0a2abb13d0d2f..62dd62c91295ae2febe6af297052e0d449dfa72b 100644 (file)
@@ -691,6 +691,7 @@ module SMESH
     SMESH_Mesh Offset(in SMESH_IDSource theObject,
                       in double         Value,
                       in boolean        CopyGroups,
+                      in boolean        CopyElements,
                       in string         MeshName,
                       out ListOfGroups  Groups)
       raises (SALOME::SALOME_Exception);
index d06ce73062e66f972b1c4fb3220c5b04e0fb1362..06e3133e33b34383ae7feef9d855b8fc597a5f63 100644 (file)
@@ -6741,6 +6741,7 @@ SMESH_MeshEditor::PGroupIDs SMESH_MeshEditor::Offset( TIDSortedElemSet & theElem
                                                       const double       theValue,
                                                       SMESH_Mesh*        theTgtMesh,
                                                       const bool         theMakeGroups,
+                                                      const bool         theCopyElements,
                                                       const bool         theFixSelfIntersection)
 {
   SMESHDS_Mesh*    meshDS = GetMeshDS();
@@ -6757,6 +6758,18 @@ SMESH_MeshEditor::PGroupIDs SMESH_MeshEditor::Offset( TIDSortedElemSet & theElem
     ( SMESH_MeshAlgos::MakeOffset( eIt, *meshDS, theValue,
                                    theFixSelfIntersection,
                                    new2OldFaces, new2OldNodes ));
+  if ( offsetMesh->NbElements() == 0 )
+    return PGroupIDs(); // MakeOffset() failed
+
+
+  if ( theTgtMesh == myMesh && !theCopyElements )
+  {
+    // clear the source elements
+    if ( theElements.empty() ) eIt = meshDS->elementsIterator( SMDSAbs_Face );
+    else                       eIt = SMESHUtils::elemSetIterator( theElements );
+    while ( eIt->more() )
+      meshDS->RemoveFreeElement( eIt->next(), 0 );
+  }
 
   offsetMesh->Modified();
   offsetMesh->CompactMesh(); // make IDs start from 1
@@ -12883,7 +12896,7 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements,
         tgtNodes.resize( srcNodes.size() );
         for ( inode = 0; inode < srcNodes.size(); ++inode )
           tgtNodes[inode] = getNodeWithSameID( tgtMeshDS, srcNodes[inode] );
-        if ( aroundElements && tgtEditor.GetMeshDS()->FindElement( tgtNodes,
+        if ( /*aroundElements && */tgtEditor.GetMeshDS()->FindElement( tgtNodes,
                                                                    missType,
                                                                    /*noMedium=*/false))
           continue;
@@ -12894,7 +12907,7 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements,
       for ( size_t i = 0; i < missingBndElems.size(); ++i )
       {
         TConnectivity& nodes = missingBndElems[ i ];
-        if ( aroundElements && tgtEditor.GetMeshDS()->FindElement( nodes,
+        if ( /*aroundElements && */tgtEditor.GetMeshDS()->FindElement( nodes,
                                                                    missType,
                                                                    /*noMedium=*/false))
           continue;
index a864e4d233e47cb6a248c009145cdaa8e6df99b4..b6c404a156c3d5942ff50d0fbca6854a5df67284 100644 (file)
@@ -469,6 +469,7 @@ public:
                     const double       theValue,
                     SMESH_Mesh*        theTgtMesh,
                     const bool         theMakeGroups,
+                    const bool         theCopyElements,
                     const bool         theFixSelfIntersection);
   // Make an offset mesh from a source 2D mesh
 
index 111a8410f431a6572a11d3179ad90e8e5a312235..28a095bae052691ac040d6b29bc59cabf1cd1454 100644 (file)
@@ -350,8 +350,9 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
     QStringList aParameters;
     aParameters << SpinBox->text();
 
-    int actionButton = ActionGroup->checkedId();
-    bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
+    int  actionButton = ActionGroup->checkedId();
+    bool copyElements = ( actionButton == COPY_ELEMS_BUTTON );
+    bool   makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
     SMESH::ListOfGroups_var groups;
     SMESH::SMESH_Mesh_var mesh;
     QStringList anEntryList;
@@ -360,17 +361,20 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
       switch ( actionButton ) {
 
       case MOVE_ELEMS_BUTTON:
+        makeGroups = true;
         if ( CheckBoxMesh->isChecked() )
           for ( int i = 0; i < myObjects.count(); i++ ) {
             SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
             myMeshes[i]->SetParameters( aParameters.join( ":" ).toLatin1().constData() );
-            mesh = aMeshEditor->Offset( myObjects[i], offsetValue, true, "", groups.out() );
+            mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups,
+                                        copyElements, "", groups.out() );
           }
         else {
           SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
           SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE);
           myMeshes[0]->SetParameters( aParameters.join( ":" ).toLatin1().constData() );
-          mesh = aMeshEditor->Offset( src, offsetValue, true, "", groups.out() );
+          mesh = aMeshEditor->Offset( src, offsetValue, makeGroups,
+                                      copyElements, "", groups.out() );
         }
         break;
 
@@ -379,13 +383,15 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
           for ( int i = 0; i < myObjects.count(); i++ ) {
             SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
             myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
-            mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups, "", groups.out() );
+            mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups,
+                                        copyElements, "", groups.out() );
           }
         else {
           SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
           SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE );
           myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
-          mesh = aMeshEditor->Offset( src, offsetValue, makeGroups, "", groups.out() );
+          mesh = aMeshEditor->Offset( src, offsetValue, makeGroups,
+                                      copyElements, "", groups.out() );
         }
         break;
 
@@ -397,7 +403,7 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
               SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ));
             SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
             myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
-            mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups,
+            mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups, copyElements,
                                         aName.toLatin1().data(), groups.out() );
             if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ))
               anEntryList.append( aSObject->GetID().c_str() );
@@ -407,7 +413,7 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
           SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
           myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
           SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE );
-          mesh = aMeshEditor->Offset( src, offsetValue, makeGroups,
+          mesh = aMeshEditor->Offset( src, offsetValue, makeGroups, copyElements,
                                       LineEditNewMesh->text().toLatin1().data(), groups.out() );
           if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
             anEntryList.append( aSObject->GetID().c_str() );
@@ -907,7 +913,7 @@ void SMESHGUI_OffsetDlg::onDisplaySimulation( bool toDisplayPreview )
           for ( int i = 0; i < myObjects.count(); i++ )
           {
             SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer();
-            mesh = aMeshEditor->Offset( myObjects[i], offsetValue, false, "", groups.out() );
+            mesh = aMeshEditor->Offset( myObjects[i], offsetValue, false, false, "", groups.out() );
             aMeshPreviewStruct << aMeshEditor->GetPreviewData();
           }
         else
@@ -920,7 +926,7 @@ void SMESHGUI_OffsetDlg::onDisplaySimulation( bool toDisplayPreview )
 
           SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer();
           SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE);
-          mesh = aMeshEditor->Offset( src, offsetValue, false, "", groups.out() );
+          mesh = aMeshEditor->Offset( src, offsetValue, false, false, "", groups.out() );
           aMeshPreviewStruct << aMeshEditor->GetPreviewData();
         }
         setSimulationPreview(aMeshPreviewStruct);
index efd648a74092eb22624f7e6410f2eff4a8f11324..564a09f69d598112ead34121ae574f0edfbfd9f7 100644 (file)
@@ -682,10 +682,9 @@ namespace
           dot *= -1;
         if ( dot * theSign < 0 )
         {
-          useOneNormal = true;
-          // gp_XYZ p1 = oldXYZ + faces[ i ].Norm()     * theOffset;
-          // gp_XYZ p2 = oldXYZ + faces[ iPrev ].Norm() * theOffset;
-          // useOneNormal = ( p1 - p2 ).SquareModulus() > theTol * theTol;
+          gp_XYZ p1 = oldXYZ + faces[ i ].Norm()     * theOffset;
+          gp_XYZ p2 = oldXYZ + faces[ iPrev ].Norm() * theOffset;
+          useOneNormal = ( p1 - p2 ).SquareModulus() > 1e-12;
         }
       }
       if ( useOneNormal && theNewNode->isMarked() )
index 9007b1b95ea9a575ce3e66558e3ae09058278e50..e49fa3e5d4695e8c9a64159f6358d4912485127d 100644 (file)
@@ -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,39 @@ 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
+      SMESH_Gen_i*        smesh = SMESH_Gen_i::GetSMESHGen();
+      SALOMEDS::Study_var study = smesh->GetCurrentStudy();
+      SALOMEDS::StudyBuilder_var builder = study->NewBuilder();
+      SALOMEDS::SObject_wrap      meshSO = smesh->ObjectToSObject( study, 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<< "')";
   }
 
index 72a5c31c24420448868d0fa324545933fa43cc77..320c002b4dc1fe757046321f904e1ae0932de6c0 100644 (file)
@@ -482,6 +482,7 @@ public:
   SMESH::SMESH_Mesh_ptr Offset( SMESH::SMESH_IDSource_ptr theObject,
                                 CORBA::Double             Value,
                                 CORBA::Boolean            CopyGroups,
+                                CORBA::Boolean            CopyElements,
                                 const char*               MeshName,
                                 SMESH::ListOfGroups_out   Groups)
     throw (SALOME::SALOME_Exception);
index 48356cac7ee00d4773c136cd5cf1ba085b0a08e3..a7d0a908dc0b0a7f95b3553ac577274497c9c32f 100644 (file)
@@ -1156,7 +1156,7 @@ class StdMeshersBuilder_Projection3D(Mesh_Algorithm):
 
 class StdMeshersBuilder_Prism3D(Mesh_Algorithm):
     """
-    Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" depending on geometry
+    Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" depending on geometry.
     It is created by calling smeshBuilder.Mesh.Prism(geom=0)
     """
     
@@ -1367,10 +1367,11 @@ class StdMeshersBuilder_Prism3D(Mesh_Algorithm):
 
 class StdMeshersBuilder_RadialPrism3D(StdMeshersBuilder_Prism3D):
     """
-    Defines Radial Prism 3D algorithm
-    It is created by calling smeshBuilder.Mesh.Prism(geom=0)
+    Defines Radial Prism 3D algorithm.
+    It is created by calling smeshBuilder.Mesh.Prism(geom=0).
+    See :class:`StdMeshersBuilder_Prism3D` for methods defining distribution of mesh layers
+    build between the inner and outer shells.
     """
-    
 
     meshMethod = "Prism"
     """