X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_SWIG%2FgeomBuilder.py;h=ccbad10f6e1362c92019b2635ef515658ecc595d;hb=354aaa03b1034ac7bf4f481ef2f100c57d3c30a9;hp=fd3cecc0eaf6bb8260082f16b434b5b914f846fa;hpb=ed5673f40bde611ab306086e0eacf64ebb764f6c;p=modules%2Fgeom.git diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py old mode 100755 new mode 100644 index fd3cecc0e..ccbad10f6 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -80,7 +80,7 @@ ## # create and publish cylinder ## cyl = geompy.MakeCylinderRH(100, 100, "cylinder") ## # get non blocks from cylinder -## g1, g2 = geompy.GetNonBlocks(cyl, "nonblock") +## g1, g2 = geompy.GetNonBlocks(cyl, theName="nonblock") ## @endcode ## ## Above example will publish both result compounds (first with non-hexa solids and @@ -88,7 +88,7 @@ ## However, if second command is invoked as ## ## @code -## g1, g2 = geompy.GetNonBlocks(cyl, ("nonhexa", "nonquad")) +## g1, g2 = geompy.GetNonBlocks(cyl, theName=("nonhexa", "nonquad")) ## @endcode ## ## ... the first compound will be published with "nonhexa" name, and second will be named "nonquad". @@ -785,6 +785,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self.myUseCaseBuilder = self.myStudy.GetUseCaseBuilder() self.myUseCaseBuilder.SetRootCurrent() self.myUseCaseBuilder.Append(self.father) + + # load data from the study file, if necessary + self.myBuilder.LoadWith(self.father, self) pass def GetPluginOperations(self, studyID, libraryName): @@ -3823,7 +3826,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestAll.py theMinDeg,theMaxDeg,theTol3D,Parameters = ParseParameters(theMinDeg, theMaxDeg, theTol3D) - anObj = self.PrimOp.MakeFilling(theContours, theMinDeg, theMaxDeg, + anObj = self.PrimOp.MakeFilling(ToList(theContours), theMinDeg, theMaxDeg, 0, theTol3D, 0, GEOM.FOM_Default, True) RaiseIfFailed("MakeFillingNew", self.PrimOp) anObj.SetParameters(Parameters) @@ -3866,41 +3869,97 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return anObj ## Create a shape by extrusion of the base shape along - # the path shape. The path shape can be a wire or an edge. + # the path shape. The path shape can be a wire or an edge. It is + # possible to generate groups along with the result by means of + # setting the flag \a IsGenerateGroups.
+ # If \a thePath is a closed edge or wire and \a IsGenerateGroups is + # set, an error is occured. If \a thePath is not closed edge/wire, + # the following groups are returned: + # - If \a theBase is unclosed edge or wire: "Down", "Up", "Side1", + # "Side2"; + # - If \a theBase is closed edge or wire, face or shell: "Down", "Up", + # "Other". + # . + # "Down" and "Up" groups contain: + # - Edges if \a theBase is edge or wire; + # - Faces if \a theBase is face or shell.
+ # . + # "Side1" and "Side2" groups contain edges generated from the first + # and last vertices of \a theBase. The first and last vertices are + # determined taking into account edge/wire orientation.
+ # "Other" group represents faces generated from the bounding edges of + # \a theBase. + # # @param theBase Base shape to be extruded. # @param thePath Path shape to extrude the base shape along it. + # @param IsGenerateGroups flag that tells if it is necessary to + # create groups. It is equal to False by default. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # - # @return New GEOM.GEOM_Object, containing the created pipe. + # @return New GEOM.GEOM_Object, containing the created pipe if + # \a IsGenerateGroups is not set. Otherwise it returns new + # GEOM.ListOfGO. Its first element is the created pipe, the + # remaining ones are created groups. # # @ref tui_creation_pipe "Example" @ManageTransactions("PrimOp") - def MakePipe(self, theBase, thePath, theName=None): + def MakePipe(self, theBase, thePath, + IsGenerateGroups=False, theName=None): """ Create a shape by extrusion of the base shape along - the path shape. The path shape can be a wire or an edge. + the path shape. The path shape can be a wire or an edge. It is + possible to generate groups along with the result by means of + setting the flag IsGenerateGroups. + If thePath is a closed edge or wire and IsGenerateGroups is + set, an error is occured. If thePath is not closed edge/wire, + the following groups are returned: + - If theBase is unclosed edge or wire: "Down", "Up", "Side1", + "Side2"; + - If theBase is closed edge or wire, face or shell: "Down", "Up", + "Other". + "Down" and "Up" groups contain: + - Edges if theBase is edge or wire; + - Faces if theBase is face or shell. + "Side1" and "Side2" groups contain edges generated from the first + and last vertices of theBase. The first and last vertices are + determined taking into account edge/wire orientation. + "Other" group represents faces generated from the bounding edges of + theBase. Parameters: theBase Base shape to be extruded. thePath Path shape to extrude the base shape along it. + IsGenerateGroups flag that tells if it is necessary to + create groups. It is equal to False by default. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created pipe. + New GEOM.GEOM_Object, containing the created pipe if + IsGenerateGroups is not set. Otherwise it returns new + GEOM.ListOfGO. Its first element is the created pipe, the + remaining ones are created groups. """ # Example: see GEOM_TestAll.py - anObj = self.PrimOp.MakePipe(theBase, thePath) + aList = self.PrimOp.MakePipe(theBase, thePath, IsGenerateGroups) RaiseIfFailed("MakePipe", self.PrimOp) - self._autoPublish(anObj, theName, "pipe") - return anObj + + if IsGenerateGroups: + self._autoPublish(aList, theName, "pipe") + return aList + + self._autoPublish(aList[0], theName, "pipe") + return aList[0] ## Create a shape by extrusion of the profile shape along # the path shape. The path shape can be a wire or an edge. # the several profiles can be specified in the several locations of path. + # It is possible to generate groups along with the result by means of + # setting the flag \a IsGenerateGroups. For detailed information on + # groups that can be created please see the method MakePipe(). # @param theSeqBases - list of Bases shape to be extruded. # @param theLocations - list of locations on the path corresponding # specified list of the Bases shapes. Number of locations @@ -3910,21 +3969,30 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # contact with the spine. # @param theWithCorrection - defining that the section is rotated to be # orthogonal to the spine tangent in the correspondent point + # @param IsGenerateGroups - flag that tells if it is necessary to + # create groups. It is equal to False by default. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # - # @return New GEOM.GEOM_Object, containing the created pipe. + # @return New GEOM.GEOM_Object, containing the created pipe if + # \a IsGenerateGroups is not set. Otherwise it returns new + # GEOM.ListOfGO. Its first element is the created pipe, the + # remaining ones are created groups. # # @ref tui_creation_pipe_with_diff_sec "Example" @ManageTransactions("PrimOp") def MakePipeWithDifferentSections(self, theSeqBases, theLocations, thePath, - theWithContact, theWithCorrection, theName=None): + theWithContact, theWithCorrection, + IsGenerateGroups=False, theName=None): """ Create a shape by extrusion of the profile shape along the path shape. The path shape can be a wire or an edge. the several profiles can be specified in the several locations of path. + It is possible to generate groups along with the result by means of + setting the flag IsGenerateGroups. For detailed information on + groups that can be created please see the method geompy.MakePipe(). Parameters: theSeqBases - list of Bases shape to be extruded. @@ -3936,23 +4004,37 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): contact with the spine(0/1) theWithCorrection - defining that the section is rotated to be orthogonal to the spine tangent in the correspondent point (0/1) + IsGenerateGroups - flag that tells if it is necessary to + create groups. It is equal to False by default. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created pipe. + New GEOM.GEOM_Object, containing the created pipe if + IsGenerateGroups is not set. Otherwise it returns new + GEOM.ListOfGO. Its first element is the created pipe, the + remaining ones are created groups. """ - anObj = self.PrimOp.MakePipeWithDifferentSections(theSeqBases, + aList = self.PrimOp.MakePipeWithDifferentSections(theSeqBases, theLocations, thePath, - theWithContact, theWithCorrection) + theWithContact, theWithCorrection, + IsGenerateGroups) RaiseIfFailed("MakePipeWithDifferentSections", self.PrimOp) - self._autoPublish(anObj, theName, "pipe") - return anObj + + if IsGenerateGroups: + self._autoPublish(aList, theName, "pipe") + return aList + + self._autoPublish(aList[0], theName, "pipe") + return aList[0] ## Create a shape by extrusion of the profile shape along - # the path shape. The path shape can be a wire or a edge. + # the path shape. The path shape can be a wire or an edge. # the several profiles can be specified in the several locations of path. + # It is possible to generate groups along with the result by means of + # setting the flag \a IsGenerateGroups. For detailed information on + # groups that can be created please see the method MakePipe(). # @param theSeqBases - list of Bases shape to be extruded. Base shape must be # shell or face. If number of faces in neighbour sections # aren't coincided result solid between such sections will @@ -3971,21 +4053,30 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # contact with the spine. # @param theWithCorrection - defining that the section is rotated to be # orthogonal to the spine tangent in the correspondent point + # @param IsGenerateGroups - flag that tells if it is necessary to + # create groups. It is equal to False by default. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # - # @return New GEOM.GEOM_Object, containing the created solids. + # @return New GEOM.GEOM_Object, containing the created solids if + # \a IsGenerateGroups is not set. Otherwise it returns new + # GEOM.ListOfGO. Its first element is the created solids, the + # remaining ones are created groups. # # @ref tui_creation_pipe_with_shell_sec "Example" @ManageTransactions("PrimOp") def MakePipeWithShellSections(self, theSeqBases, theSeqSubBases, theLocations, thePath, - theWithContact, theWithCorrection, theName=None): + theWithContact, theWithCorrection, + IsGenerateGroups=False, theName=None): """ Create a shape by extrusion of the profile shape along - the path shape. The path shape can be a wire or a edge. + the path shape. The path shape can be a wire or an edge. the several profiles can be specified in the several locations of path. + It is possible to generate groups along with the result by means of + setting the flag IsGenerateGroups. For detailed information on + groups that can be created please see the method geompy.MakePipe(). Parameters: theSeqBases - list of Bases shape to be extruded. Base shape must be @@ -4006,19 +4097,30 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): contact with the spine (0/1) theWithCorrection - defining that the section is rotated to be orthogonal to the spine tangent in the correspondent point (0/1) + IsGenerateGroups - flag that tells if it is necessary to + create groups. It is equal to False by default. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created solids. + New GEOM.GEOM_Object, containing the created solids if + IsGenerateGroups is not set. Otherwise it returns new + GEOM.ListOfGO. Its first element is the created solids, the + remaining ones are created groups. """ - anObj = self.PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases, + aList = self.PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases, theLocations, thePath, - theWithContact, theWithCorrection) + theWithContact, theWithCorrection, + IsGenerateGroups) RaiseIfFailed("MakePipeWithShellSections", self.PrimOp) - self._autoPublish(anObj, theName, "pipe") - return anObj + + if IsGenerateGroups: + self._autoPublish(aList, theName, "pipe") + return aList + + self._autoPublish(aList[0], theName, "pipe") + return aList[0] ## Create a shape by extrusion of the profile shape along # the path shape. This function is used only for debug pipe @@ -4028,7 +4130,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): @ManageTransactions("PrimOp") def MakePipeWithShellSectionsBySteps(self, theSeqBases, theSeqSubBases, theLocations, thePath, - theWithContact, theWithCorrection, theName=None): + theWithContact, theWithCorrection, + IsGenerateGroups=False, theName=None): """ Create a shape by extrusion of the profile shape along the path shape. This function is used only for debug pipe @@ -4047,16 +4150,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): tmpLocations = [ theLocations[i-1], theLocations[i] ] tmpSeqSubBases = [] if nbsubsect>0: tmpSeqSubBases = [ theSeqSubBases[i-1], theSeqSubBases[i] ] - anObj = self.PrimOp.MakePipeWithShellSections(tmpSeqBases, tmpSeqSubBases, + aList = self.PrimOp.MakePipeWithShellSections(tmpSeqBases, tmpSeqSubBases, tmpLocations, thePath, - theWithContact, theWithCorrection) + theWithContact, theWithCorrection, + IsGenerateGroups) if self.PrimOp.IsDone() == 0: print "Problems with pipe creation between ",i," and ",i+1," sections" RaiseIfFailed("MakePipeWithShellSections", self.PrimOp) break else: print "Pipe between ",i," and ",i+1," sections is OK" - res.append(anObj) + res.append(aList[0]) pass pass @@ -4066,57 +4170,92 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(resc, theName, "pipe") return resc - ## Create solids between given sections + ## Create solids between given sections. + # It is possible to generate groups along with the result by means of + # setting the flag \a IsGenerateGroups. For detailed information on + # groups that can be created please see the method MakePipe(). # @param theSeqBases - list of sections (shell or face). # @param theLocations - list of corresponding vertexes + # @param IsGenerateGroups - flag that tells if it is necessary to + # create groups. It is equal to False by default. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # - # @return New GEOM.GEOM_Object, containing the created solids. + # @return New GEOM.GEOM_Object, containing the created solids if + # \a IsGenerateGroups is not set. Otherwise it returns new + # GEOM.ListOfGO. Its first element is the created solids, the + # remaining ones are created groups. # # @ref tui_creation_pipe_without_path "Example" @ManageTransactions("PrimOp") - def MakePipeShellsWithoutPath(self, theSeqBases, theLocations, theName=None): + def MakePipeShellsWithoutPath(self, theSeqBases, theLocations, + IsGenerateGroups=False, theName=None): """ - Create solids between given sections + Create solids between given sections. + It is possible to generate groups along with the result by means of + setting the flag IsGenerateGroups. For detailed information on + groups that can be created please see the method geompy.MakePipe(). Parameters: theSeqBases - list of sections (shell or face). theLocations - list of corresponding vertexes + IsGenerateGroups - flag that tells if it is necessary to + create groups. It is equal to False by default. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created solids. + New GEOM.GEOM_Object, containing the created solids if + IsGenerateGroups is not set. Otherwise it returns new + GEOM.ListOfGO. Its first element is the created solids, the + remaining ones are created groups. """ - anObj = self.PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations) + aList = self.PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations, + IsGenerateGroups) RaiseIfFailed("MakePipeShellsWithoutPath", self.PrimOp) - self._autoPublish(anObj, theName, "pipe") - return anObj + + if IsGenerateGroups: + self._autoPublish(aList, theName, "pipe") + return aList + + self._autoPublish(aList[0], theName, "pipe") + return aList[0] ## Create a shape by extrusion of the base shape along # the path shape with constant bi-normal direction along the given vector. # The path shape can be a wire or an edge. + # It is possible to generate groups along with the result by means of + # setting the flag \a IsGenerateGroups. For detailed information on + # groups that can be created please see the method MakePipe(). # @param theBase Base shape to be extruded. # @param thePath Path shape to extrude the base shape along it. # @param theVec Vector defines a constant binormal direction to keep the # same angle beetween the direction and the sections # along the sweep surface. + # @param IsGenerateGroups flag that tells if it is necessary to + # create groups. It is equal to False by default. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # - # @return New GEOM.GEOM_Object, containing the created pipe. + # @return New GEOM.GEOM_Object, containing the created pipe if + # \a IsGenerateGroups is not set. Otherwise it returns new + # GEOM.ListOfGO. Its first element is the created pipe, the + # remaining ones are created groups. # # @ref tui_creation_pipe "Example" @ManageTransactions("PrimOp") - def MakePipeBiNormalAlongVector(self, theBase, thePath, theVec, theName=None): + def MakePipeBiNormalAlongVector(self, theBase, thePath, theVec, + IsGenerateGroups=False, theName=None): """ Create a shape by extrusion of the base shape along the path shape with constant bi-normal direction along the given vector. The path shape can be a wire or an edge. + It is possible to generate groups along with the result by means of + setting the flag IsGenerateGroups. For detailed information on + groups that can be created please see the method geompy.MakePipe(). Parameters: theBase Base shape to be extruded. @@ -4124,74 +4263,120 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theVec Vector defines a constant binormal direction to keep the same angle beetween the direction and the sections along the sweep surface. + IsGenerateGroups flag that tells if it is necessary to + create groups. It is equal to False by default. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created pipe. + New GEOM.GEOM_Object, containing the created pipe if + IsGenerateGroups is not set. Otherwise it returns new + GEOM.ListOfGO. Its first element is the created pipe, the + remaining ones are created groups. """ # Example: see GEOM_TestAll.py - anObj = self.PrimOp.MakePipeBiNormalAlongVector(theBase, thePath, theVec) + aList = self.PrimOp.MakePipeBiNormalAlongVector(theBase, thePath, + theVec, IsGenerateGroups) RaiseIfFailed("MakePipeBiNormalAlongVector", self.PrimOp) - self._autoPublish(anObj, theName, "pipe") - return anObj - ## Makes a thick solid from a face or a shell - # @param theShape Face or Shell to be thicken + if IsGenerateGroups: + self._autoPublish(aList, theName, "pipe") + return aList + + self._autoPublish(aList[0], theName, "pipe") + return aList[0] + + ## Makes a thick solid from a shape. If the input is a surface shape + # (face or shell) the result is a thick solid. If an input shape is + # a solid the result is a hollowed solid with removed faces. + # @param theShape Face or Shell to get thick solid or solid to get + # hollowed solid. # @param theThickness Thickness of the resulting solid + # @param theFacesIDs the list of face IDs to be removed from the + # result. It is ignored if \a theShape is a face or a shell. + # It is empty by default. + # @param theInside If true the thickness is applied towards inside # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # # @return New GEOM.GEOM_Object, containing the created solid # + # @ref tui_creation_thickness "Example" @ManageTransactions("PrimOp") - def MakeThickSolid(self, theShape, theThickness, theName=None): + def MakeThickSolid(self, theShape, theThickness, + theFacesIDs=[], theInside=False, theName=None): """ - Make a thick solid from a face or a shell + Make a thick solid from a shape. If the input is a surface shape + (face or shell) the result is a thick solid. If an input shape is + a solid the result is a hollowed solid with removed faces. Parameters: - theShape Face or Shell to be thicken + theShape Face or Shell to get thick solid or solid to get + hollowed solid. theThickness Thickness of the resulting solid + theFacesIDs the list of face IDs to be removed from the + result. It is ignored if theShape is a face or a + shell. It is empty by default. + theInside If true the thickness is applied towards inside theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created solid """ # Example: see GEOM_TestAll.py - anObj = self.PrimOp.MakeThickening(theShape, theThickness, True) - RaiseIfFailed("MakeThickening", self.PrimOp) - self._autoPublish(anObj, theName, "pipe") + theThickness,Parameters = ParseParameters(theThickness) + anObj = self.PrimOp.MakeThickening(theShape, theFacesIDs, + theThickness, True, theInside) + RaiseIfFailed("MakeThickSolid", self.PrimOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "thickSolid") return anObj - ## Modifies a face or a shell to make it a thick solid - # @param theShape Face or Shell to be thicken + ## Modifies a shape to make it a thick solid. If the input is a surface + # shape (face or shell) the result is a thick solid. If an input shape + # is a solid the result is a hollowed solid with removed faces. + # @param theShape Face or Shell to get thick solid or solid to get + # hollowed solid. # @param theThickness Thickness of the resulting solid + # @param theFacesIDs the list of face IDs to be removed from the + # result. It is ignored if \a theShape is a face or a shell. + # It is empty by default. + # @param theInside If true the thickness is applied towards inside # # @return The modified shape # + # @ref tui_creation_thickness "Example" @ManageTransactions("PrimOp") - def Thicken(self, theShape, theThickness): + def Thicken(self, theShape, theThickness, theFacesIDs=[], theInside=False): """ - Modifies a face or a shell to make it a thick solid + Modifies a shape to make it a thick solid. If the input is a + surface shape (face or shell) the result is a thick solid. If + an input shape is a solid the result is a hollowed solid with + removed faces. Parameters: - theBase Base shape to be extruded. - thePath Path shape to extrude the base shape along it. - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. + theShape Face or Shell to get thick solid or solid to get + hollowed solid. + theThickness Thickness of the resulting solid + theFacesIDs the list of face IDs to be removed from the + result. It is ignored if \a theShape is a face or + a shell. It is empty by default. + theInside If true the thickness is applied towards inside Returns: The modified shape """ # Example: see GEOM_TestAll.py - anObj = self.PrimOp.MakeThickening(theShape, theThickness, False) - RaiseIfFailed("MakeThickening", self.PrimOp) + theThickness,Parameters = ParseParameters(theThickness) + anObj = self.PrimOp.MakeThickening(theShape, theFacesIDs, + theThickness, False, theInside) + RaiseIfFailed("Thicken", self.PrimOp) + anObj.SetParameters(Parameters) return anObj ## Build a middle path of a pipe-like shape. @@ -4287,7 +4472,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # end of l3_complex ## @} - ## @addtogroup l3_advanced + ## @addtogroup l3_basic_go ## @{ ## Create a linear edge with specified ends. @@ -4719,7 +4904,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "solid") return anObj - # end of l3_advanced + # end of l3_basic_go ## @} ## @addtogroup l2_measure @@ -4920,33 +5105,49 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(aList, theName, "shared") return aList - ## Get all sub-shapes, shared by all shapes in the list theShapes. + ## Get sub-shapes, shared by input shapes. # @param theShapes Either a list or compound of shapes to find common sub-shapes of. - # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) + # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()). + # @param theMultiShare Specifies what type of shares should be checked: + # - @c True (default): search sub-shapes from 1st input shape shared with all other input shapes; + # - @c False: causes to search sub-shapes shared between couples of input shapes. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # - # @return List of objects, that are sub-shapes of all given shapes. + # @note If @a theShapes contains single compound, the shares between all possible couples of + # its top-level shapes are returned; otherwise, only shares between 1st input shape + # and all rest input shapes are returned. # - # @ref swig_GetSharedShapes "Example" + # @return List of all found sub-shapes. + # + # Examples: + # - @ref tui_shared_shapes "Example 1" + # - @ref swig_GetSharedShapes "Example 2" @ManageTransactions("ShapesOp") - def GetSharedShapesMulti(self, theShapes, theShapeType, theName=None): + def GetSharedShapesMulti(self, theShapes, theShapeType, theMultiShare=True, theName=None): """ - Get all sub-shapes, shared by all shapes in the list theShapes. + Get sub-shapes, shared by input shapes. Parameters: theShapes Either a list or compound of shapes to find common sub-shapes of. - theShapeType Type of sub-shapes to be retrieved (see geompy.ShapeType) + theShapeType Type of sub-shapes to be retrieved (see geompy.ShapeType). + theMultiShare Specifies what type of shares should be checked: + - True (default): search sub-shapes from 1st input shape shared with all other input shapes; + - False: causes to search sub-shapes shared between couples of input shapes. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. + Note: if theShapes contains single compound, the shares between all possible couples of + its top-level shapes are returned; otherwise, only shares between 1st input shape + and all rest input shapes are returned. + Returns: - List of GEOM.GEOM_Object, that are sub-shapes of all given shapes. + List of all found sub-shapes. """ # Example: see GEOM_TestOthers.py - aList = self.ShapesOp.GetSharedShapesMulti(ToList(theShapes), theShapeType) + aList = self.ShapesOp.GetSharedShapesMulti(ToList(theShapes), theShapeType, theMultiShare) RaiseIfFailed("GetSharedShapesMulti", self.ShapesOp) self._autoPublish(aList, theName, "shared") return aList @@ -5789,8 +5990,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Returns: New GEOM.GEOM_Object, containing the created edge. """ + theMin, theMax, Parameters = ParseParameters(theMin, theMax) anObj = self.ShapesOp.ExtendEdge(theEdge, theMin, theMax) RaiseIfFailed("ExtendEdge", self.ShapesOp) + anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "edge") return anObj @@ -5837,9 +6040,11 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Returns: New GEOM.GEOM_Object, containing the created face. """ + theUMin, theUMax, theVMin, theVMax, Parameters = ParseParameters(theUMin, theUMax, theVMin, theVMax) anObj = self.ShapesOp.ExtendFace(theFace, theUMin, theUMax, theVMin, theVMax) RaiseIfFailed("ExtendFace", self.ShapesOp) + anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "face") return anObj @@ -6280,6 +6485,38 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(ListObj, theName, "subshape") return ListObj + ## Explode a shape into edges sorted in a row from a starting point. + # @param theShape the shape to be exploded on edges. + # @param theStartPoint the starting point. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # @return List of GEOM.GEOM_Object that is actually an ordered list + # of edges sorted in a row from a starting point. + # + # @ref swig_GetSubShapeEdgeSorted "Example" + @ManageTransactions("ShapesOp") + def GetSubShapeEdgeSorted(self, theShape, theStartPoint, theName=None): + """ + Explode a shape into edges sorted in a row from a starting point. + + Parameters: + theShape the shape to be exploded on edges. + theStartPoint the starting point. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + List of GEOM.GEOM_Object that is actually an ordered list + of edges sorted in a row from a starting point. + """ + # Example: see GEOM_TestAll.py + ListObj = self.ShapesOp.GetSubShapeEdgeSorted(theShape, theStartPoint) + RaiseIfFailed("GetSubShapeEdgeSorted", self.ShapesOp) + self._autoPublish(ListObj, theName, "SortedEdges") + return ListObj + ## Check if the object is a sub-object of another GEOM object. # @param aSubObject Checked sub-object (or its parent object, in case if # \a theSubObjectIndex is non-zero). @@ -7138,7 +7375,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Returns: New GEOM.GEOM_Object, containing copies of theShapes without coincident faces. """ - anObj = self.ShapesOp.MakeGlueFacesByList(ToList(theShapes), theTolerance, theFaces, + anObj = self.ShapesOp.MakeGlueFacesByList(ToList(theShapes), theTolerance, ToList(theFaces), doKeepNonSolids, doGlueAllEdges) if anObj is None: raise RuntimeError, "MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode() @@ -7874,6 +8111,23 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @return New GEOM.GEOM_Object, containing the result shape. # + # @note This operation is a shortcut to the more general @ref MakePartition + # operation, where @a theShape specifies single "object" (shape being partitioned) + # and @a thePlane specifies single "tool" (intersector shape). Other parameters of + # @ref MakePartition operation have default values: + # - @a Limit: GEOM::SHAPE (shape limit corresponds to the type of @a theShape) + # - @a KeepNonlimitShapes: 0 + # - @a KeepInside, @a RemoveInside, @a RemoveWebs, + # @a Materials (obsolete parameters): empty + # + # @note I.e. the following two operations are equivalent: + # @code + # Result = geompy.MakeHalfPartition(Object, Plane) + # Result = geompy.MakePartition([Object], [Plane]) + # @endcode + # + # @sa MakePartition, MakePartitionNonSelfIntersectedShape + # # @ref tui_partition "Example" @ManageTransactions("BoolOp") def MakeHalfPartition(self, theShape, thePlane, theName=None): @@ -7889,6 +8143,18 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Returns: New GEOM.GEOM_Object, containing the result shape. + + Note: This operation is a shortcut to the more general MakePartition + operation, where theShape specifies single "object" (shape being partitioned) + and thePlane specifies single "tool" (intersector shape). Other parameters of + MakePartition operation have default values: + - Limit: GEOM::SHAPE (shape limit corresponds to the type of theShape) + - KeepNonlimitShapes: 0 + - KeepInside, RemoveInside, RemoveWebs, Materials (obsolete parameters): empty + + I.e. the following two operations are equivalent: + Result = geompy.MakeHalfPartition(Object, Plane) + Result = geompy.MakePartition([Object], [Plane]) """ # Example: see GEOM_TestAll.py anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane) @@ -8895,7 +9161,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "projection") return anObj - ## Create a projection projection of the given point on a wire or an edge. + ## Create a projection of the given point on a wire or an edge. # If there are no solutions or there are 2 or more solutions It throws an # exception. # @param thePoint the point to be projected. @@ -8913,7 +9179,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): @ManageTransactions("TrsfOp") def MakeProjectionOnWire(self, thePoint, theWire, theName=None): """ - Create a projection projection of the given point on a wire or an edge. + Create a projection of the given point on a wire or an edge. If there are no solutions or there are 2 or more solutions It throws an exception. @@ -9296,6 +9562,77 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): anObj = self.MultiRotate2DByStep(aShape, aVec, anAngle, nbtimes1, aStep, nbtimes2, theName) return anObj + ## + # Compute a wire or a face that represents a projection of the source + # shape onto cylinder. The cylinder's coordinate system is the same + # as the global coordinate system. + # + # @param theObject The object to be projected. It can be either + # a planar wire or a face. + # @param theRadius The radius of the cylinder. + # @param theStartAngle The starting angle in radians from + # the cylinder's X axis around Z axis. The angle from which + # the projection is started. + # @param theAngleLength The projection length angle in radians. + # The angle in which to project the total length of the wire. + # If it is negative the projection is not scaled and natural + # wire length is kept for the projection. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM.GEOM_Object, containing the result shape. The result + # represents a wire or a face that represents a projection of + # the source shape onto a cylinder. + # + # @ref tui_projection "Example" + def MakeProjectionOnCylinder (self, theObject, theRadius, + theStartAngle=0.0, theAngleLength=-1.0, + theName=None): + """ + Compute a wire or a face that represents a projection of the source + shape onto cylinder. The cylinder's coordinate system is the same + as the global coordinate system. + + Parameters: + theObject The object to be projected. It can be either + a planar wire or a face. + theRadius The radius of the cylinder. + theStartAngle The starting angle in radians from the cylinder's X axis + around Z axis. The angle from which the projection is started. + theAngleLength The projection length angle in radians. The angle in which + to project the total length of the wire. If it is negative the + projection is not scaled and natural wire length is kept for + the projection. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the result shape. The result + represents a wire or a face that represents a projection of + the source shape onto a cylinder. + """ + # Example: see GEOM_TestAll.py + flagStartAngle = False + if isinstance(theStartAngle,str): + flagStartAngle = True + flagAngleLength = False + if isinstance(theAngleLength,str): + flagAngleLength = True + theRadius, theStartAngle, theAngleLength, Parameters = ParseParameters( + theRadius, theStartAngle, theAngleLength) + if flagStartAngle: + theStartAngle = theStartAngle*math.pi/180. + if flagAngleLength: + theAngleLength = theAngleLength*math.pi/180. + anObj = self.TrsfOp.MakeProjectionOnCylinder(theObject, theRadius, + theStartAngle, theAngleLength) + RaiseIfFailed("MakeProjectionOnCylinder", self.TrsfOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "projection") + return anObj + # end of l3_transform ## @} @@ -9881,6 +10218,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theBase Closed edge or wire defining the base shape to be extruded. # @param theH Prism dimension along the normal to theBase # @param theAngle Draft angle in degrees. + # @param theInvert If true material changes the direction # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -9889,7 +10227,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_creation_prism "Example" @ManageTransactions("PrimOp") - def MakeExtrudedCut(self, theInit, theBase, theH, theAngle, theName=None): + def MakeExtrudedCut(self, theInit, theBase, theH, theAngle, theInvert=False, theName=None): """ Add material to a solid by extrusion of the base shape on the given distance. @@ -9898,6 +10236,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theBase Closed edge or wire defining the base shape to be extruded. theH Prism dimension along the normal to theBase theAngle Draft angle in degrees. + theInvert If true material changes the direction. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. @@ -9906,10 +10245,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the initial shape with removed material. """ # Example: see GEOM_TestAll.py - #theH,Parameters = ParseParameters(theH) - anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, False) + theH,theAngle,Parameters = ParseParameters(theH,theAngle) + anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, False, theInvert) RaiseIfFailed("MakeExtrudedBoss", self.PrimOp) - #anObj.SetParameters(Parameters) + anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "extrudedCut") return anObj @@ -9919,6 +10258,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theBase Closed edge or wire defining the base shape to be extruded. # @param theH Prism dimension along the normal to theBase # @param theAngle Draft angle in degrees. + # @param theInvert If true material changes the direction # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -9927,7 +10267,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_creation_prism "Example" @ManageTransactions("PrimOp") - def MakeExtrudedBoss(self, theInit, theBase, theH, theAngle, theName=None): + def MakeExtrudedBoss(self, theInit, theBase, theH, theAngle, theInvert=False, theName=None): """ Add material to a solid by extrusion of the base shape on the given distance. @@ -9936,6 +10276,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theBase Closed edge or wire defining the base shape to be extruded. theH Prism dimension along the normal to theBase theAngle Draft angle in degrees. + theInvert If true material changes the direction. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. @@ -9944,10 +10285,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the initial shape with added material. """ # Example: see GEOM_TestAll.py - #theH,Parameters = ParseParameters(theH) - anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, True) + theH,theAngle,Parameters = ParseParameters(theH,theAngle) + anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, True, theInvert) RaiseIfFailed("MakeExtrudedBoss", self.PrimOp) - #anObj.SetParameters(Parameters) + anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "extrudedBoss") return anObj @@ -10625,14 +10966,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return aDict def GetCreationInformation(self, theShape): - info = theShape.GetCreationInformation() - # operationName - opName = info.operationName - if not opName: opName = "no info available" - res = "Operation: " + opName - # parameters - for parVal in info.params: - res += " \n %s = %s" % ( parVal.name, parVal.value ) + res = '' + infos = theShape.GetCreationInformation() + for info in infos: + # operationName + opName = info.operationName + if not opName: opName = "no info available" + if res: res += "\n" + res += "Operation: " + opName + # parameters + for parVal in info.params: + res += "\n \t%s = %s" % ( parVal.name, parVal.value ) return res ## Get a point, situated at the centre of mass of theShape. @@ -11739,36 +12083,62 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Check, if the compound of blocks is given. # To be considered as a compound of blocks, the # given shape must satisfy the following conditions: - # - Each element of the compound should be a Block (6 faces and 12 edges). + # - Each element of the compound should be a Block (6 faces). + # - Each face should be a quadrangle, i.e. it should have only 1 wire + # with 4 edges. If theIsUseC1 is set to True and + # there are more than 4 edges in the only wire of a face, + # this face is considered to be quadrangle if it has 4 bounds + # (1 or more edge) of C1 continuity. # - A connection between two Blocks should be an entire quadrangle face or an entire edge. # - The compound should be connexe. # - The glue between two quadrangle faces should be applied. # @param theCompound The compound to check. + # @param theIsUseC1 Flag to check if there are 4 bounds on a face + # taking into account C1 continuity. + # @param theAngTolerance the angular tolerance to check if two neighbor + # edges are codirectional in the common vertex with this + # tolerance. This parameter is used only if + # theIsUseC1 is set to True. # @return TRUE, if the given shape is a compound of blocks. # If theCompound is not valid, prints all discovered errors. # # @ref tui_check_compound_of_blocks_page "Example 1" # \n @ref swig_CheckCompoundOfBlocks "Example 2" @ManageTransactions("BlocksOp") - def CheckCompoundOfBlocks(self,theCompound): + def CheckCompoundOfBlocks(self,theCompound, theIsUseC1 = False, + theAngTolerance = 1.e-12): """ Check, if the compound of blocks is given. To be considered as a compound of blocks, the given shape must satisfy the following conditions: - - Each element of the compound should be a Block (6 faces and 12 edges). + - Each element of the compound should be a Block (6 faces). + - Each face should be a quadrangle, i.e. it should have only 1 wire + with 4 edges. If theIsUseC1 is set to True and + there are more than 4 edges in the only wire of a face, + this face is considered to be quadrangle if it has 4 bounds + (1 or more edge) of C1 continuity. - A connection between two Blocks should be an entire quadrangle face or an entire edge. - The compound should be connexe. - The glue between two quadrangle faces should be applied. Parameters: theCompound The compound to check. + theIsUseC1 Flag to check if there are 4 bounds on a face + taking into account C1 continuity. + theAngTolerance the angular tolerance to check if two neighbor + edges are codirectional in the common vertex with this + tolerance. This parameter is used only if + theIsUseC1 is set to True. Returns: TRUE, if the given shape is a compound of blocks. If theCompound is not valid, prints all discovered errors. """ # Example: see GEOM_Spanner.py - (IsValid, BCErrors) = self.BlocksOp.CheckCompoundOfBlocks(theCompound) + aTolerance = -1.0 + if theIsUseC1: + aTolerance = theAngTolerance + (IsValid, BCErrors) = self.BlocksOp.CheckCompoundOfBlocks(theCompound, aTolerance) RaiseIfFailed("CheckCompoundOfBlocks", self.BlocksOp) if IsValid == 0: Descr = self.BlocksOp.PrintBCErrors(theCompound, BCErrors) @@ -11777,6 +12147,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Retrieve all non blocks solids and faces from \a theShape. # @param theShape The shape to explore. + # @param theIsUseC1 Flag to check if there are 4 bounds on a face + # taking into account C1 continuity. + # @param theAngTolerance the angular tolerance to check if two neighbor + # edges are codirectional in the common vertex with this + # tolerance. This parameter is used only if + # theIsUseC1 is set to True. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -11784,17 +12160,27 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return A tuple of two GEOM_Objects. The first object is a group of all # non block solids (= not 6 faces, or with 6 faces, but with the # presence of non-quadrangular faces). The second object is a - # group of all non quadrangular faces. + # group of all non quadrangular faces (= faces with more then + # 1 wire or, if theIsUseC1 is set to True, faces + # with 1 wire with not 4 edges that do not form 4 bounds of + # C1 continuity). # # @ref tui_get_non_blocks_page "Example 1" # \n @ref swig_GetNonBlocks "Example 2" @ManageTransactions("BlocksOp") - def GetNonBlocks (self, theShape, theName=None): + def GetNonBlocks (self, theShape, theIsUseC1 = False, + theAngTolerance = 1.e-12, theName=None): """ Retrieve all non blocks solids and faces from theShape. Parameters: theShape The shape to explore. + theIsUseC1 Flag to check if there are 4 bounds on a face + taking into account C1 continuity. + theAngTolerance the angular tolerance to check if two neighbor + edges are codirectional in the common vertex with this + tolerance. This parameter is used only if + theIsUseC1 is set to True. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. @@ -11803,13 +12189,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): A tuple of two GEOM_Objects. The first object is a group of all non block solids (= not 6 faces, or with 6 faces, but with the presence of non-quadrangular faces). The second object is a - group of all non quadrangular faces. + group of all non quadrangular faces (= faces with more then + 1 wire or, if theIsUseC1 is set to True, faces + with 1 wire with not 4 edges that do not form 4 bounds of + C1 continuity). Usage: (res_sols, res_faces) = geompy.GetNonBlocks(myShape1) """ # Example: see GEOM_Spanner.py - aTuple = self.BlocksOp.GetNonBlocks(theShape) + aTolerance = -1.0 + if theIsUseC1: + aTolerance = theAngTolerance + aTuple = self.BlocksOp.GetNonBlocks(theShape, aTolerance) RaiseIfFailed("GetNonBlocks", self.BlocksOp) self._autoPublish(aTuple, theName, ("groupNonHexas", "groupNonQuads")) return aTuple