Salome HOME
Integration of new pipe algorithm (MakePipeWithoutPath).
[modules/geom.git] / src / GEOM_SWIG / geompy.py
index d2c3df8d9451a52e50cd3c9f6b665c33ea5dcc55..61228920c6f7c4ab4750bde6d3972eb4eaf25456 100644 (file)
@@ -747,7 +747,9 @@ def MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithConta
 #  @param theSeqSubBases - list of corresponding subshapes of section shapes.
 #  @param theLocations - list of locations on the path corresponding
 #                        specified list of the Bases shapes. Number of locations
-#                        should be equal to number of bases.
+#                        should be equal to number of bases. First and last
+#                        locations must be coincided with first and last vertexes
+#                        of path correspondingly.
 #  @param thePath - Path shape to extrude the base shape along it.
 #  @param theWithContact - the mode defining that the section is translated to be in
 #                          contact with the spine.
@@ -766,6 +768,51 @@ def MakePipeWithShellSections(theSeqBases, theSeqSubBases,
       print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
     return anObj
 
+def MakePipeWithShellSectionsBySteps(theSeqBases, theSeqSubBases,
+                                     theLocations, thePath,
+                                     theWithContact, theWithCorrection):
+    res = []
+    nbsect = len(theSeqBases)
+    nbsubsect = len(theSeqSubBases)
+    #print "nbsect = ",nbsect
+    for i in range(1,nbsect):
+        #print "  i = ",i
+        tmpSeqBases = [ theSeqBases[i-1], theSeqBases[i] ]
+        tmpLocations = [ theLocations[i-1], theLocations[i] ]
+        tmpSeqSubBases = []
+        if nbsubsect>0: tmpSeqSubBases = [ theSeqSubBases[i-1], theSeqSubBases[i] ]
+        anObj = PrimOp.MakePipeWithShellSections(tmpSeqBases, tmpSeqSubBases,
+                                                 tmpLocations, thePath,
+                                                 theWithContact, theWithCorrection)
+        if PrimOp.IsDone() == 0:
+            print "Problems with pipe creation between ",i," and ",i+1," sections"
+            print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
+            break
+        else:
+            print "Pipe between ",i," and ",i+1," sections is OK"
+            res.append(anObj)
+            pass
+        pass
+
+    resc = MakeCompound(res)
+    #resc = MakeSewing(res, 0.001)
+    #print "resc: ",resc
+    return resc
+
+
+## Create solids between given sections
+#  @param theSeqBases - list of sections (shell or face).
+#  @param theLocations - list of corresponding vertexes
+#  @return New GEOM_Object, containing the created solids.
+#
+#  Example: see GEOM_TestAll.py
+def MakePipeShellsWithoutPath(theSeqBases, theLocations):
+    anObj = PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations)
+    if PrimOp.IsDone() == 0:
+      print "MakePipeShellsWithoutPath : ", PrimOp.GetErrorCode()
+    return anObj
+
+
 # -----------------------------------------------------------------------------
 # Create base shapes
 # -----------------------------------------------------------------------------
@@ -1084,7 +1131,8 @@ def GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState):
 ## Get sub-shape(s) of theShapeWhere, which are
 #  coincident with \a theShapeWhat or could be a part of it.
 #  @param theShapeWhere Shape to find sub-shapes of.
-#  @param theShapeWhat Shape, specifying what to find.
+#  @param theShapeWhat Shape, specifying what to find (must be in the
+#                      building history of the ShapeWhere).
 #  @return Group of all found sub-shapes or a single found sub-shape.
 #
 #  Example: see GEOM_TestOthers.py
@@ -1094,10 +1142,32 @@ def GetInPlace(theShapeWhere, theShapeWhat):
       print "GetInPlace : ", ShapesOp.GetErrorCode()
     return anObj
 
+## Get sub-shape(s) of \a theShapeWhere, which are
+#  coincident with \a theShapeWhat or could be a part of it.
+#
+#  Implementation of this method is based on a saved history of an operation,
+#  produced \a theShapeWhere. The \a theShapeWhat must be among this operation's
+#  arguments (an argument shape or a sub-shape of an argument shape).
+#  The operation could be the Partition or one of boolean operations,
+#  performed on simple shapes (not on compounds).
+#
+#  @param theShapeWhere Shape to find sub-shapes of.
+#  @param theShapeWhat Shape, specifying what to find (must be in the
+#                      building history of the ShapeWhere).
+#  @return Group of all found sub-shapes or a single found sub-shape.
+#
+#  Example: see GEOM_TestOthers.py
+def GetInPlaceByHistory(theShapeWhere, theShapeWhat):
+    anObj = ShapesOp.GetInPlaceByHistory(theShapeWhere, theShapeWhat)
+    if ShapesOp.IsDone() == 0:
+      print "GetInPlace : ", ShapesOp.GetErrorCode()
+    return anObj
+
 ## Get sub-shape of theShapeWhere, which is
 #  equal to \a theShapeWhat.
 #  @param theShapeWhere Shape to find sub-shape of.
-#  @param theShapeWhat Shape, specifying what to find.
+#  @param theShapeWhat Shape, specifying what to find
+#                      (must be usual shape).
 #  @return New GEOM_Object for found sub-shape.
 #
 def GetSame(theShapeWhere, theShapeWhat):
@@ -1378,11 +1448,12 @@ def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
 ## Replace coincident faces in theShape by one face.
 #  @param theShape Initial shape.
 #  @param theTolerance Maximum distance between faces, which can be considered as coincident.
+#  @param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
 #  @return New GEOM_Object, containing a copy of theShape without coincident faces.
 #
 #  Example: see GEOM_Spanner.py
-def MakeGlueFaces(theShape, theTolerance):
-    anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
+def MakeGlueFaces(theShape, theTolerance, doKeepNonSolids=True):
+    anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance, doKeepNonSolids)
     if ShapesOp.IsDone() == 0:
       print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
     return anObj
@@ -1408,12 +1479,13 @@ def GetGlueFaces(theShape, theTolerance):
 #  @param theTolerance Maximum distance between faces,
 #                      which can be considered as coincident.
 #  @param theFaces List of faces for gluing.
+#  @param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
 #  @return New GEOM_Object, containing a copy of theShape
 #          without some faces.
 #
 #  Example: see GEOM_Spanner.py
-def MakeGlueFacesByList(theShape, theTolerance, theFaces):
-    anObj = ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces)
+def MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids=True):
+    anObj = ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids)
     if ShapesOp.IsDone() == 0:
       print "MakeGlueFacesByList : ", ShapesOp.GetErrorCode()
     return anObj