]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0022380: EDF 2746 GEOM: Accept compounds of points as an input for "Smoothing surface"
authorskv <skv@opencascade.com>
Mon, 24 Mar 2014 09:13:11 +0000 (13:13 +0400)
committerskv <skv@opencascade.com>
Mon, 24 Mar 2014 09:13:11 +0000 (13:13 +0400)
doc/salome/gui/GEOM/input/creating_smoothingsurface.doc
src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx
src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx
src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx
src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx
src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.h
src/GEOM_SWIG/geomBuilder.py [changed mode: 0644->0755]

index a4b42cee3406fde4320daf2f075de8e3a267b1de..5b102a173ac1659b5d6e9f80f23cb5ef2a5696fe 100644 (file)
@@ -7,6 +7,8 @@ Advanced - > SmoothingSurface </b>
 
 Specify the \b Name of the surface and the list of \b Points, from which it is approximated and press "Apply" or "Apply & Close" button.
 
+\note The dialog accepts compounds of points as well as single nodes.
+
 The result of the operation will be a GEOM_Object(Surface).
 
 <b>TUI Command:</b> <em>geompy.MakeSmoothingSurface(Points)</em>
index f486a63f4fb8f150987ef467a25e42da56bd6d78..6e535e2ac2766eb88bb4866cafeea66e9a05c495 100644 (file)
@@ -3429,7 +3429,7 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedCylinder (double th
 //=============================================================================
 /*!
  *  Create a smoothing surface from a set of points
- *  \param thelPoints list of points
+ *  \param thelPoints list of points or compounds of points
  *  \return New GEOM_Object, containing the created shape.
  */
 //=============================================================================
@@ -3454,12 +3454,12 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::lis
   int ind = 1;
   std::list<Handle(GEOM_Object)>::iterator it = thelPoints.begin();
   for (; it != thelPoints.end(); it++, ind++) {
-    Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
-    if (aRefPnt.IsNull()) {
-      SetErrorCode("NULL point for bSplineFaceShape");
+    Handle(GEOM_Function) aRefObj = (*it)->GetLastFunction();
+    if (aRefObj.IsNull()) {
+      SetErrorCode("NULL point or compound for bSplineFaceShape");
       return NULL;
     }
-    aData.SetPoint(ind, aRefPnt);
+    aData.SetPntOrComp(ind, aRefObj);
   }
 
 
index 412b65bfa528c4756d5627afc19969648563564e..5cd77a502ed33394159f96c17ef29e8a10a76bc6 100644 (file)
@@ -36,8 +36,8 @@ public:
   void SetLength(int theLen) { _func->SetInteger(SMOOTHINGSURFACE_ARG_LENG, theLen); }
   int GetLength() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_LENG); }
 
-  void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); }
-  Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); }
+  void SetPntOrComp(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); }
+  Handle(GEOM_Function) GetPntOrComp(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); }
 
 private:
   Handle(GEOM_Function) _func;
index 61ec99aaa225844fd4898042cb3b9ae7896dad16..662df462347fb29f37ce7af70e18f7685e74e1b5 100644 (file)
@@ -34,6 +34,9 @@
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopoDS.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopExp_Explorer.hxx>
 
 #include <TColgp_SequenceOfPnt.hxx>
 #include <TColgp_Array2OfPnt.hxx>
@@ -167,22 +170,43 @@ Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log
   // cout << "Youhou : " << aType << endl;
 
   GEOMImpl_ISmoothingSurface aData (aFunction);
-  
-  Standard_Integer nbPoints = aData.GetLength();
 
-  Handle(TColgp_HArray1OfPnt) anArrayofPnt = new TColgp_HArray1OfPnt(1,nbPoints);
-  for (int ind=1;ind<=nbPoints;ind++)
-  {
-    Handle(GEOM_Function) aPoint = aData.GetPoint(ind);
-    TopoDS_Shape aShapePnt = aPoint->GetValue();
-    TopoDS_Vertex dsPoint;
-    dsPoint = TopoDS::Vertex( aShapePnt );
-    gp_Pnt aPnt = BRep_Tool::Pnt( dsPoint );
-    anArrayofPnt->SetValue(ind,aPnt);
+  // Fill the map of vertices.
+  Standard_Integer    aNbShapes = aData.GetLength();
+  TopTools_MapOfShape aMapPoints;
+  Standard_Integer    i;
+
+  for (i = 1; i <= aNbShapes; i++) {
+    Handle(GEOM_Function) aFShape = aData.GetPntOrComp(i);
+    TopoDS_Shape aShape = aFShape->GetValue();
+
+    if (aShape.ShapeType() == TopAbs_VERTEX) {
+      aMapPoints.Add(aShape);
+    } else {
+      TopExp_Explorer anExp(aShape, TopAbs_VERTEX);
+
+      for (; anExp.More(); anExp.Next()) {
+        aMapPoints.Add(anExp.Current());
+      }
+    }
+  }
+
+  // Add points to the array of points.
+  const Standard_Integer      aNbPoints    = aMapPoints.Extent();
+  Handle(TColgp_HArray1OfPnt) anArrayofPnt =
+      new TColgp_HArray1OfPnt(1, aNbPoints);
+  TopTools_MapIteratorOfMapOfShape anIter(aMapPoints);
+
+  for (i = 1; anIter.More(); anIter.Next(), i++) {
+    TopoDS_Vertex aPoint = TopoDS::Vertex(anIter.Key());
+    gp_Pnt aPnt = BRep_Tool::Pnt(aPoint);
+
+    anArrayofPnt->SetValue(i, aPnt);
   }
 
-  TopoDS_Shape aShape;
-  aShape = GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt);
+  // Make smoothing surface.
+  TopoDS_Shape aShape =
+    GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt);
 
   if (aShape.IsNull()) return 0;
 
@@ -217,7 +241,7 @@ GetCreationInformation(std::string&             theOperationName,
     if ( aCI.GetLength() > 1 )
       theParams[0] << aCI.GetLength() << " points: ";
     for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i )
-      theParams[0] << aCI.GetPoint( i ) << " ";
+      theParams[0] << aCI.GetPntOrComp( i ) << " ";
     break;
   default:
     return false;
index 8a93ce3de2238e9c7bdc2ac231376085e152bf38..d8fe398095e43bbe8ee5f25fa2a3808d4361b25e 100644 (file)
@@ -31,6 +31,7 @@
 // OCCT Includes
 #include <TopoDS_Shape.hxx>
 #include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
 #include <TopExp.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
@@ -208,16 +209,80 @@ bool AdvancedGUI_SmoothingSurfaceDlg::execute (ObjectList& objects)
   return res;
 }
 
+//=================================================================================
+// function : getNbPoints()
+// purpose  : Returns the number of points in myPoints list.
+//=================================================================================
+int AdvancedGUI_SmoothingSurfaceDlg::getNbPoints() const
+{
+  TopTools_IndexedMapOfShape aMap;
+
+  foreach (GEOM::GeomObjPtr anObj, myPoints) {
+    TopoDS_Shape aShape;
+
+    if(anObj && GEOMBase::GetShape(anObj.get(), aShape) && !aShape.IsNull()) {
+      if (aShape.ShapeType() == TopAbs_VERTEX) {
+        aMap.Add(aShape);
+      } else {
+        // Compound.
+        TopExp::MapShapes(aShape, TopAbs_VERTEX, aMap);
+      }
+    }
+  }
+
+  const int aNbPoints = aMap.Extent();
+
+  return aNbPoints;
+}
+
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection as changed or other case
 //=================================================================================
 void AdvancedGUI_SmoothingSurfaceDlg::SelectionIntoArgument()
 {
-  QList<GEOM::GeomObjPtr> points = getSelected( TopAbs_VERTEX, -1 );
+  QList<TopAbs_ShapeEnum> aTypes;
+
+  aTypes << TopAbs_VERTEX << TopAbs_COMPOUND;
+
+  QList<GEOM::GeomObjPtr> points = getSelected( aTypes, -1 );
+
+  // Check the selected compounds if they consist of points only.
+  foreach (GEOM::GeomObjPtr anObj, points) {
+    TopoDS_Shape aShape;
+
+    if(anObj && GEOMBase::GetShape(anObj.get(), aShape) && !aShape.IsNull()) {
+      if (aShape.ShapeType() == TopAbs_COMPOUND) {
+        // Check if the compound contains vertices only.
+        TopoDS_Iterator anIter(aShape);
+        Standard_Boolean isValid = Standard_False;
+
+        for (; anIter.More(); anIter.Next()) {
+          const TopoDS_Shape &aSubShape = anIter.Value();
+
+          if (aSubShape.ShapeType() == TopAbs_VERTEX) {
+            isValid = Standard_True;
+          } else {
+            isValid = Standard_False;
+            break;
+          }
+        }
+
+        if (!isValid) {
+          points.clear();
+          break;
+        }
+      }
+    } else {
+      // NEVERREACHED
+      points.clear();
+      break;
+    }
+  }
+
   GEOMBase::Synchronize( myPoints, points );
   if ( !myPoints.isEmpty()  )
-    GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
+    GroupPoints->LineEdit1->setText( QString::number( getNbPoints() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
   else
     GroupPoints->LineEdit1->setText( "" );
   processPreview();
index 3a8a053d8b1586136ff79f29660ee56a66951768..c12ab517341c276edcad5baa0d1eb8d29474477f 100644 (file)
@@ -48,6 +48,7 @@ protected:
 private:
   void                               Init();
   void                               enterEvent( QEvent* );
+  int                                getNbPoints() const;
 
 private:
   DlgRef_1Sel*                 GroupPoints;
old mode 100644 (file)
new mode 100755 (executable)
index 8f2afc1..34fe54d
@@ -12629,7 +12629,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             return anObj
 
         ## Create a surface from a cloud of points
-        #  @param thelPoints list of points
+        #  @param thelPoints list of points. Compounds of points are
+        #         accepted as well.
         #  @return New GEOM_Object, containing the created shape.
         #
         #  @ref tui_creation_smoothingsurface "Example"