# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
## @}
## @defgroup l2_measure Using measurement tools
## @defgroup l2_field Field on Geometry
+## @defgroup l2_testing Testing
## @}
import functools
from salome.geom.gsketcher import Sketcher3D, Sketcher2D, Polyline2D
+from salome.geom.canonicalrecognition import CanonicalRecognition
+from salome.geom.conformity import CheckConformity
+from salome.geom.proximity import ShapeProximity
# In case the omniORBpy EnumItem class does not fully support Python 3
# (for instance in version 4.2.1-2), the comparison ordering methods must be
if not Operation.IsDone() and Operation.GetErrorCode() != "NOT_FOUND_ANY":
raise RuntimeError(Method_name + " : " + Operation.GetErrorCode())
+def PrintOrRaise(message, raiseException=False):
+ if raiseException:
+ raise RuntimeError(message)
+ else:
+ print(message)
+
## Return list of variables value from salome notebook
## @ingroup l1_geomBuilder_auxiliary
def ParseParameters(*parameters):
#
# - CIRCLE: [xc yc zc dx dy dz R]
# - ARC_CIRCLE: [xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2]
- # - ELLIPSE: [xc yc zc dx dy dz R_1 R_2]
- # - ARC_ELLIPSE: [xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2]
+ # - ELLIPSE: [xc yc zc dx dy dz R_1 R_2 v1x v1y v1z v2x v2y v2z]
+ # - ARC_ELLIPSE: [xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2 v1x v1y v1z v2x v2y v2z]
# - LINE: [xo yo zo dx dy dz]
# - SEGMENT: [x1 y1 z1 x2 y2 z2]
+ # - CRV_BSPLINE: [periodicity degree nb_poles nb_knots nb_weights nb_multiplicities xi yi zi ki wi mi]
+ # - CRV_BEZIER: [nb_poles nb_weights xi yi zi wi]
+ # - HYPERBOLA: [xc yc zc dx dy dz R_1 R_2 v1x v1y v1z v2x v2y v2z]
+ # - PARABOLA: [xc yc zc dx dy dz F v1x v1y v1z v2x v2y v2z]
# - EDGE: [nb_vertices]
#
# - VERTEX: [x y z]
GEOM._objref_GEOM_Gen.__init__(self, *args)
self.myMaxNbSubShapesAllowed = 0 # auto-publishing is disabled by default
self.myBuilder = None
- self.father = None
-
self.BasicOp = None
self.CurvesOp = None
self.PrimOp = None
self.BlocksOp = None
self.GroupOp = None
self.FieldOp = None
+ self.TestOp = None
pass
## Process object publication in the study, as follows:
def init_geom(self):
self.myStudy = salome.myStudy
self.myBuilder = self.myStudy.NewBuilder()
- self.father = self.myStudy.FindComponent("GEOM")
- notebook.myStudy = salome.myStudy
- if self.father is None:
- self.father = self.myBuilder.NewComponent("GEOM")
- A1 = self.myBuilder.FindOrCreateAttribute(self.father, "AttributeName")
- FName = A1._narrow(SALOMEDS.AttributeName)
- FName.SetValue("Geometry")
- A2 = self.myBuilder.FindOrCreateAttribute(self.father, "AttributePixMap")
- aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
- aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
- self.myBuilder.DefineComponentInstance(self.father,self)
- pass
+
+ # load data from the study file, if necessary
+ component = self.myStudy.FindComponent("GEOM")
+ if component:
+ self.myBuilder.LoadWith(component, self)
+
self.BasicOp = self.GetIBasicOperations ()
self.CurvesOp = self.GetICurvesOperations ()
self.PrimOp = self.GetI3DPrimOperations ()
self.BlocksOp = self.GetIBlocksOperations ()
self.GroupOp = self.GetIGroupOperations ()
self.FieldOp = self.GetIFieldOperations ()
+ self.TestOp = self.GetITestOperations ()
- # set GEOM as root in the use case tree
- 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)
+ notebook.myStudy = self.myStudy
pass
def GetPluginOperations(self, libraryName):
#
# @ref swig_MakeVertexInsideFace "Example"
@ManageTransactions("BasicOp")
- def MakeVertexInsideFace (self, theFace, theName=None):
+ def MakeVertexInsideFace (self, theFace, theNumberOfPnts=1, theName=None):
"""
Create a point, which lays on the given face.
The point will lay in arbitrary place of the face.
Parameters:
theFace The referenced face.
+ theNumberOfPnts The number of points we want to get, 1 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.
p_on_face = geompy.MakeVertexInsideFace(Face)
"""
# Example: see GEOM_TestAll.py
- anObj = self.BasicOp.MakePointOnFace(theFace)
+ anObj = self.BasicOp.MakePointOnFace(theFace, theNumberOfPnts)
RaiseIfFailed("MakeVertexInsideFace", self.BasicOp)
self._autoPublish(anObj, theName, "vertex")
return anObj
#
# @ref tui_creation_face "Example"
@ManageTransactions("ShapesOp")
- def MakeFace(self, theWire, isPlanarWanted, theName=None):
+ def MakeFace(self, theWire, isPlanarWanted, theName=None, raiseException=False):
"""
Create a face on the given wire.
# Example: see GEOM_TestAll.py
anObj = self.ShapesOp.MakeFace(theWire, isPlanarWanted)
if isPlanarWanted and anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG":
- print("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.")
+ PrintOrRaise("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.",raiseException)
else:
RaiseIfFailed("MakeFace", self.ShapesOp)
self._autoPublish(anObj, theName, "face")
#
# @ref tui_creation_face "Example"
@ManageTransactions("ShapesOp")
- def MakeFaceWires(self, theWires, isPlanarWanted, theName=None):
+ def MakeFaceWires(self, theWires, isPlanarWanted, theName=None, raiseException=False):
"""
Create a face on the given wires set.
# Example: see GEOM_TestAll.py
anObj = self.ShapesOp.MakeFaceWires(ToList(theWires), isPlanarWanted)
if isPlanarWanted and anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG":
- print("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.")
+ PrintOrRaise("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.",raiseException)
else:
RaiseIfFailed("MakeFaceWires", self.ShapesOp)
self._autoPublish(anObj, theName, "face")
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the boolean
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the boolean operation.
#
# @note This algorithm doesn't find all types of self-intersections.
# It is tuned to detect vertex/vertex, vertex/edge, edge/edge,
#
# @ref tui_fuse "Example"
@ManageTransactions("BoolOp")
- def MakeBoolean(self, theShape1, theShape2, theOperation, checkSelfInte=False, theName=None):
+ def MakeBoolean(self, theShape1, theShape2, theOperation, checkSelfInte=False, theName=None, theFuzzyParam=-1):
"""
Perform one of boolean operations on two given 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.
+ theFuzzyParam The fuzzy parameter to be used for the boolean operation.
+ If the value is not positive, no fuzzy tolerance will be
+ considered for the boolean operation.
Note:
This algorithm doesn't find all types of self-intersections.
New GEOM.GEOM_Object, containing the result shape.
"""
# Example: see GEOM_TestAll.py
- anObj = self.BoolOp.MakeBoolean(theShape1, theShape2, theOperation, checkSelfInte)
+ anObj = self.BoolOp.MakeBooleanWithFuzzy(theShape1, theShape2, theOperation, checkSelfInte, theFuzzyParam)
RaiseIfFailed("MakeBoolean", self.BoolOp)
def_names = { 1: "common", 2: "cut", 3: "fuse", 4: "section" }
self._autoPublish(anObj, theName, def_names[theOperation])
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the boolean
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the boolean operation.
#
# @note This algorithm doesn't find all types of self-intersections.
# It is tuned to detect vertex/vertex, vertex/edge, edge/edge,
#
# @ref tui_common "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeCommon(self, theShape1, theShape2, checkSelfInte=False, theName=None):
+ def MakeCommon(self, theShape1, theShape2, checkSelfInte=False, theName=None, theFuzzyParam=-1):
"""
Perform Common boolean operation on two given 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.
+ theFuzzyParam The fuzzy parameter to be used for the boolean operation.
+ If the value is not positive, no fuzzy tolerance will be
+ considered for the boolean operation.
Note:
This algorithm doesn't find all types of self-intersections.
"""
# Example: see GEOM_TestOthers.py
# note: auto-publishing is done in self.MakeBoolean()
- return self.MakeBoolean(theShape1, theShape2, 1, checkSelfInte, theName)
+ return self.MakeBoolean(theShape1, theShape2, 1, checkSelfInte, theName, theFuzzyParam)
## Perform Cut boolean operation on two given shapes.
# @param theShape1 First argument for boolean operation.
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the boolean
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the boolean operation.
#
# @note This algorithm doesn't find all types of self-intersections.
# It is tuned to detect vertex/vertex, vertex/edge, edge/edge,
#
# @ref tui_cut "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeCut(self, theShape1, theShape2, checkSelfInte=False, theName=None):
+ def MakeCut(self, theShape1, theShape2, checkSelfInte=False, theName=None, theFuzzyParam=-1):
"""
Perform Cut boolean operation on two given 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.
+ theFuzzyParam The fuzzy parameter to be used for the boolean operation.
+ If the value is not positive, no fuzzy tolerance will be
+ considered for the boolean operation.
Note:
This algorithm doesn't find all types of self-intersections.
"""
# Example: see GEOM_TestOthers.py
# note: auto-publishing is done in self.MakeBoolean()
- return self.MakeBoolean(theShape1, theShape2, 2, checkSelfInte, theName)
+ return self.MakeBoolean(theShape1, theShape2, 2, checkSelfInte, theName, theFuzzyParam)
## Perform Fuse boolean operation on two given shapes.
# @param theShape1 First argument for boolean operation.
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the boolean
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the boolean operation.
#
# @note This algorithm doesn't find all types of self-intersections.
# It is tuned to detect vertex/vertex, vertex/edge, edge/edge,
# \n @ref swig_MakeCommon "Example 2"
@ManageTransactions("BoolOp")
def MakeFuse(self, theShape1, theShape2, checkSelfInte=False,
- rmExtraEdges=False, theName=None):
+ rmExtraEdges=False, theName=None, theFuzzyParam=-1):
"""
Perform Fuse boolean operation on two given 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.
+ theFuzzyParam The fuzzy parameter to be used for the boolean operation.
+ If the value is not positive, no fuzzy tolerance will be
+ considered for the boolean operation.
Note:
This algorithm doesn't find all types of self-intersections.
"""
# Example: see GEOM_TestOthers.py
- anObj = self.BoolOp.MakeFuse(theShape1, theShape2,
- checkSelfInte, rmExtraEdges)
+ anObj = self.BoolOp.MakeFuseWithFuzzy(theShape1, theShape2, checkSelfInte,
+ rmExtraEdges, theFuzzyParam)
RaiseIfFailed("MakeFuse", self.BoolOp)
self._autoPublish(anObj, theName, "fuse")
return anObj
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the boolean
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the boolean operation.
# @return New GEOM.GEOM_Object, containing the result shape.
#
# @ref tui_section "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeSection(self, theShape1, theShape2, checkSelfInte=False, theName=None):
+ def MakeSection(self, theShape1, theShape2, checkSelfInte=False, theName=None, theFuzzyParam=-1):
"""
Perform Section boolean operation on two given 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.
+ theFuzzyParam The fuzzy parameter to be used for the boolean operation.
+ If the value is not positive, no fuzzy tolerance will be
+ considered for the boolean operation.
Returns:
New GEOM.GEOM_Object, containing the result shape.
"""
# Example: see GEOM_TestOthers.py
# note: auto-publishing is done in self.MakeBoolean()
- return self.MakeBoolean(theShape1, theShape2, 4, checkSelfInte, theName)
+ return self.MakeBoolean(theShape1, theShape2, 4, checkSelfInte, theName, theFuzzyParam)
## Perform Fuse boolean operation on the list of shapes.
# @param theShapesList Shapes to be fused.
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the boolean
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the boolean operation.
#
# @note This algorithm doesn't find all types of self-intersections.
# It is tuned to detect vertex/vertex, vertex/edge, edge/edge,
# \n @ref swig_MakeCommon "Example 2"
@ManageTransactions("BoolOp")
def MakeFuseList(self, theShapesList, checkSelfInte=False,
- rmExtraEdges=False, theName=None):
+ rmExtraEdges=False, theName=None, theFuzzyParam=-1):
"""
Perform Fuse boolean operation on the list of 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.
+ theFuzzyParam The fuzzy parameter to be used for the boolean operation.
+ If the value is not positive, no fuzzy tolerance will be
+ considered for the boolean operation.
Note:
This algorithm doesn't find all types of self-intersections.
"""
# Example: see GEOM_TestOthers.py
- anObj = self.BoolOp.MakeFuseList(theShapesList, checkSelfInte,
- rmExtraEdges)
+ anObj = self.BoolOp.MakeFuseListWithFuzzy(theShapesList, checkSelfInte,
+ rmExtraEdges, theFuzzyParam)
RaiseIfFailed("MakeFuseList", self.BoolOp)
self._autoPublish(anObj, theName, "fuse")
return anObj
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the boolean
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the boolean operation.
#
# @note This algorithm doesn't find all types of self-intersections.
# It is tuned to detect vertex/vertex, vertex/edge, edge/edge,
# @ref tui_common "Example 1"
# \n @ref swig_MakeCommon "Example 2"
@ManageTransactions("BoolOp")
- def MakeCommonList(self, theShapesList, checkSelfInte=False, theName=None):
+ def MakeCommonList(self, theShapesList, checkSelfInte=False, theName=None, theFuzzyParam=-1):
"""
Perform Common boolean operation on the list of 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.
+ theFuzzyParam The fuzzy parameter to be used for the boolean operation.
+ If the value is not positive, no fuzzy tolerance will be
+ considered for the boolean operation.
Note:
This algorithm doesn't find all types of self-intersections.
"""
# Example: see GEOM_TestOthers.py
- anObj = self.BoolOp.MakeCommonList(theShapesList, checkSelfInte)
+ anObj = self.BoolOp.MakeCommonListWithFuzzy(theShapesList, checkSelfInte, theFuzzyParam)
RaiseIfFailed("MakeCommonList", self.BoolOp)
self._autoPublish(anObj, theName, "common")
return anObj
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the boolean
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the boolean operation.
#
# @note This algorithm doesn't find all types of self-intersections.
# It is tuned to detect vertex/vertex, vertex/edge, edge/edge,
# @ref tui_cut "Example 1"
# \n @ref swig_MakeCommon "Example 2"
@ManageTransactions("BoolOp")
- def MakeCutList(self, theMainShape, theShapesList, checkSelfInte=False, theName=None):
+ def MakeCutList(self, theMainShape, theShapesList, checkSelfInte=False, theName=None, theFuzzyParam=-1):
"""
Perform Cut boolean operation on one object and the list of tools.
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.
+ theFuzzyParam The fuzzy parameter to be used for the boolean operation.
+ If the value is not positive, no fuzzy tolerance will be
+ considered for the boolean operation.
Note:
This algorithm doesn't find all types of self-intersections.
"""
# Example: see GEOM_TestOthers.py
- anObj = self.BoolOp.MakeCutList(theMainShape, theShapesList, checkSelfInte)
+ anObj = self.BoolOp.MakeCutListWithFuzzy(theMainShape, theShapesList, checkSelfInte, theFuzzyParam)
RaiseIfFailed("MakeCutList", self.BoolOp)
self._autoPublish(anObj, theName, "cut")
return anObj
# target type (equal to Limit) are kept in the result,
# else standalone shapes of lower dimension
# are kept also (if they exist).
- #
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the partition
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the partition operation.
#
# @note Each compound from ListShapes and ListTools will be exploded
# in order to avoid possible intersection between shapes from this compound.
@ManageTransactions("BoolOp")
def MakePartition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[],
- KeepNonlimitShapes=0, theName=None):
+ KeepNonlimitShapes=0, theName=None, theFuzzyParam=-1):
"""
Perform partition operation.
for s in ListShapes: lim = min(lim, s.GetMaxShapeType())
Limit = EnumToLong(lim)
pass
- anObj = self.BoolOp.MakePartition(ListShapes, ListTools,
- ListKeepInside, ListRemoveInside,
- Limit, RemoveWebs, ListMaterials,
- KeepNonlimitShapes);
+ anObj = self.BoolOp.MakePartitionWithFuzzy(ListShapes, ListTools,
+ ListKeepInside, ListRemoveInside,
+ Limit, RemoveWebs, ListMaterials,
+ KeepNonlimitShapes, theFuzzyParam)
RaiseIfFailed("MakePartition", self.BoolOp)
self._autoPublish(anObj, theName, "partition")
return anObj
# One additional parameter is provided:
# @param checkSelfInte The flag that tells if the arguments should
# be checked for self-intersection prior to the operation.
+ # @param theFuzzyParam The fuzzy parameter to be used for the partition
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the partition operation.
#
# @note This algorithm doesn't find all types of self-intersections.
# It is tuned to detect vertex/vertex, vertex/edge, edge/edge,
ListKeepInside=[], ListRemoveInside=[],
Limit=ShapeType["AUTO"], RemoveWebs=0,
ListMaterials=[], KeepNonlimitShapes=0,
- checkSelfInte=False, theName=None):
+ checkSelfInte=False, theName=None,
+ theFuzzyParam=-1):
"""
Perform partition operation.
This method may be useful if it is needed to make a partition for
for s in ListShapes: lim = min(lim, s.GetMaxShapeType())
Limit = EnumToLong(lim)
pass
- anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
- ListKeepInside, ListRemoveInside,
- Limit, RemoveWebs, ListMaterials,
- KeepNonlimitShapes, checkSelfInte);
+ anObj = self.BoolOp.MakePartitionNonSelfIntersectedShapeWithFuzzy(ListShapes, ListTools,
+ ListKeepInside, ListRemoveInside,
+ Limit, RemoveWebs, ListMaterials,
+ KeepNonlimitShapes, checkSelfInte,
+ theFuzzyParam)
RaiseIfFailed("MakePartitionNonSelfIntersectedShape", self.BoolOp)
self._autoPublish(anObj, theName, "partition")
return anObj
# \n @ref swig_Partition "Example 2"
def Partition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[],
- KeepNonlimitShapes=0, theName=None):
+ KeepNonlimitShapes=0, theName=None, theFuzzyParam=-1):
"""
See method geompy.MakePartition for more information.
"""
anObj = self.MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
Limit, RemoveWebs, ListMaterials,
- KeepNonlimitShapes, theName);
+ KeepNonlimitShapes, theName, theFuzzyParam)
return anObj
## Perform partition of the Shape with the Plane
# @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.
+ # @param theFuzzyParam The fuzzy parameter to be used for the partition
+ # operation. If the value is not positive, no fuzzy tolerance will
+ # be considered for the partition operation.
#
# @return New GEOM.GEOM_Object, containing the result shape.
#
#
# @ref tui_partition "Example"
@ManageTransactions("BoolOp")
- def MakeHalfPartition(self, theShape, thePlane, theName=None):
+ def MakeHalfPartition(self, theShape, thePlane, theName=None, theFuzzyParam=-1):
"""
Perform partition of the Shape with the Plane
Result = geompy.MakePartition([Object], [Plane])
"""
# Example: see GEOM_TestAll.py
- anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane)
+ anObj = self.BoolOp.MakeHalfPartitionWithFuzzy(theShape, thePlane, theFuzzyParam)
RaiseIfFailed("MakeHalfPartition", self.BoolOp)
self._autoPublish(anObj, theName, "partition")
return anObj
return aSurf
## @}
+ ## Measure curvature radius of surface in the given point along the given direction.
+ # @param theSurf the given face.
+ # @param thePoint given point.
+ # @param theDirection given 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.
+ #
+ # @return New GEOM.GEOM_Object, containing vector of curvature of theSurf.
+ # The returned vector is codirectional with the normal to the face
+ # in the given point in case of positive curvature value
+ # and opposite to the normal in case of negative curvature.
+ # The normal of the returned vector is equal to the
+ # absolute value of the curvature radius.
+ # Null shape is returned in case of infinite radius
+ # (zero curvature), for example, in case of flat face.
+ #
+ ## @ref swig_CurvatureOnFace "Example"
+ @ManageTransactions("MeasuOp")
+ def CurvatureOnFace(self, theSurf, thePoint, theDirection, theName=None):
+ """
+ Measure curvature radius of surface in the given point along the given direction.
+
+ Parameters:
+ theSurf the given face.
+ thePoint given point.
+ theDirection given 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.
+
+ Returns:
+ New GEOM.GEOM_Object, containing vector of curvature of theSurf.
+ The returned vector is codirectional with the normal to the face
+ in the given point in case of positive curvature value
+ and opposite to the normal in case of negative curvature.
+ The normal of the returned vector is equal to the
+ absolute value of the curvature radius.
+ Null shape is returned in case of infinite radius
+ (zero curvature), for example, in case of flat face.
+
+ Example of usage:
+ curvature_1 = geompy.CurvatureOnFace(Face_1, Vertex_1, OX)
+ """
+ aVec = self.MeasuOp.SurfaceCurvatureByPointAndDirection(theSurf,thePoint,theDirection)
+ if self.MeasuOp.GetErrorCode() != "ZERO_CURVATURE":
+ RaiseIfFailed("CurvatureOnFace", self.MeasuOp)
+ self._autoPublish(aVec, theName, "curvature")
+ return aVec
+
+ ## Convert X,Y,Z points coordinates to UV parameters on the given surface.
+ # @param theSurf the given face. It can be also a shell or a compound with one face.
+ # @param theXYZlist float list of size 3*N where N is the number of points
+ # for which we want their U,V coordinates.
+ # If the user enters a list of size not divisible by 3
+ # an exception will be thrown.
+ # @param theIsNormalized if True, the returned parameters will be in range [0, 1].
+ #
+ # @return list of float of size 2*N.
+ #
+ # @ref tui_xyz_to_uv_page "Example"
+ @ManageTransactions("MeasuOp")
+ def XYZtoUV(self, theSurf, theXYZlist, theIsNormalized = True):
+ """
+ Convert X,Y,Z points coordinates to UV parameters on the given surface.
+
+ Parameters:
+ theSurf the given face. It can be also a shell or a compound with one face.
+ theXYZlist float list of size 3*N where N is the number of points
+ for which we want their U,V coordinates.
+ If the user enters a list of size not divisible by 3
+ an exception will be thrown.
+ theIsNormalized if True, the returned parameters will be in range [0, 1].
+
+ Returns:
+ list of float of size 2*N.
+
+ Example of usage:
+ [u1,v1, u2,v2] = geompy.XYZtoUV(Face_1, [0,0,0, 0,10,10])
+ """
+ aUVlist = self.MeasuOp.XYZtoUV(theSurf, theXYZlist, theIsNormalized)
+ RaiseIfFailed("XYZtoUV", self.MeasuOp)
+ return aUVlist
+
+ ## Convert UV parameters on the given surface to 3D points coordinates.
+ # @param theSurf the given face. It can be also a shell or a compound with one face.
+ # @param theUVlist float list of size 2*N where N is the number of points
+ # for which we want their X,Y,Z coordinates.
+ # If the user enters a list of non-even size
+ # an exception will be thrown.
+ # @param theIsNormalized if True, the input parameters are expected to be in range [0, 1].
+ #
+ # @return list of float of size 3*N.
+ #
+ # @ref tui_xyz_to_uv_page "Example"
+ @ManageTransactions("MeasuOp")
+ def UVtoXYZ(self, theSurf, theUVlist, theIsNormalized = True):
+ """
+ Convert UV parameters on the given surface to 3D points coordinates.
+
+ Parameters:
+ theSurf the given face. It can be also a shell or a compound with one face.
+ theUVlist float list of size 2*N where N is the number of points
+ for which we want their X,Y,Z coordinates.
+ If the user enters a list of non-even size
+ an exception will be thrown.
+ theIsNormalized if True, the input parameters are expected to be in range [0, 1].
+
+ Returns:
+ list of float of size 3*N.
+
+ Example of usage:
+ [x1,y1,z1, x2,y2,z2] = geompy.UVtoXYZ(Face_1, [0,0, 10,10])
+ """
+ aXYZlist = self.MeasuOp.UVtoXYZ(theSurf, theUVlist, theIsNormalized)
+ RaiseIfFailed("UVtoXYZ", self.MeasuOp)
+ return aXYZlist
+
## Get min and max tolerances of sub-shapes of theShape
# @param theShape Shape, to get tolerances of.
# @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]\n
self._autoPublish(anObj, theName, "centerOfMass")
return anObj
- ## Get a vertex sub-shape by index depended with orientation.
+ ## Get a vertex sub-shape by index.
# @param theShape Shape to find sub-shape.
# @param theIndex Index to find vertex by this index (starting from zero)
+ # @param theUseOri To consider edge/wire orientation or not
# @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.
#
# @ref tui_measurement_tools_page "Example"
@ManageTransactions("MeasuOp")
- def GetVertexByIndex(self, theShape, theIndex, theName=None):
+ def GetVertexByIndex(self, theShape, theIndex, theUseOri=True, theName=None):
"""
- Get a vertex sub-shape by index depended with orientation.
+ Get a vertex sub-shape by index.
Parameters:
theShape Shape to find sub-shape.
theIndex Index to find vertex by this index (starting from zero)
+ theUseOri To consider edge/wire orientation or not
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.
New GEOM.GEOM_Object, containing the created vertex.
"""
# Example: see GEOM_TestMeasures.py
- anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex)
+ if isinstance( theUseOri, str ): # theUseOri was inserted before theName
+ theUseOri, theName = True, theUseOri
+ anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex, theUseOri)
RaiseIfFailed("GetVertexByIndex", self.MeasuOp)
self._autoPublish(anObj, theName, "vertex")
return anObj
"""
# Example: see GEOM_TestMeasures.py
# note: auto-publishing is done in self.GetVertexByIndex()
- return self.GetVertexByIndex(theShape, 0, theName)
+ return self.GetVertexByIndex(theShape, 0, True, theName)
## Get the last vertex of wire/edge depended orientation.
# @param theShape Shape to find last vertex.
# Example: see GEOM_TestMeasures.py
nb_vert = self.NumberOfSubShapes(theShape, self.ShapeType["VERTEX"])
# note: auto-publishing is done in self.GetVertexByIndex()
- return self.GetVertexByIndex(theShape, (nb_vert-1), theName)
+ return self.GetVertexByIndex(theShape, (nb_vert-1), True, theName)
## Get a normale to the given face. If the point is not given,
# the normale is calculated at the center of mass.
#if aKind == kind.SOME_KIND:
# # SOME_KIND int int double int double double
# aKindTuple = [aKind, anInts[0], anInts[1], aDbls[0], anInts[2], aDbls[1], aDbls[2]]
+ if aKind == self.kind.CRV_BSPLINE:
+ aKindTuple = [aKind] + anInts[:6] + aDbls + anInts[6:]
+ elif aKind == self.kind.CRV_BEZIER:
+ aKindTuple = [aKind] + anInts[:2] + aDbls + anInts[2:]
return aKindTuple
+ ## The function takes a single face with holes and returns a list of faces,
+ # first of them is the original face without holes, and the other faces are placed
+ # on the same surface as the original face but bounded by each hole wire.
+ # If the original face has no holes, it will be returned as an output
+ # @param theShape Face to perform operation on.
+ #
+ # @return GEOM.ListOfGO, list created faces, where first of them is the original face without holes
+ @ManageTransactions("MeasuOp")
+ def PatchFace(self, theShape):
+ """
+ The function takes a single face with holes and returns a list of faces,
+ first of them is the original face without holes, and the other faces are placed
+ on the same surface as the original face but bounded by each hole wire.
+ If the original face has no holes, it will be returned as an output
+
+ Parameters:
+ theShape Face to perform operation on.
+
+ Returns:
+ GEOM.ListOfGO, list created faces, where first of them is the original face without holes
+
+ Example of usage:
+ Circle_1 = geompy.MakeCircle(None, None, 190)
+ Circle_2 = geompy.MakeCircle(None, None, 100)
+ Face_1 = geompy.MakeFaceWires([Circle_1], 1)
+ Face_2 = geompy.MakeFaceWires([Circle_2], 1)
+ Cut_1 = geompy.MakeCutList(Face_1, [Face_2], True)
+ faces = geompy.PatchFace(Cut_1)
+ """
+ aList = self.MeasuOp.PatchFace(theShape)
+ RaiseIfFailed("PatchFace", self.MeasuOp)
+ return aList
+
## Returns the string that describes if the shell is good for solid.
# This is a support method for MakeSolid.
#
aDescr = self.MeasuOp.IsGoodForSolid(theShell)
return aDescr
+ ## Obtain a canonical recognition interface.
+ # @return An instance of
+ # @ref canonicalrecognition.CanonicalRecognition "CanonicalRecognition" interface
+ #
+ # @ref tui_3dsketcher_page "Example"
+ def CanonicalRecognition (self):
+ """
+ Obtain a canonical recognition interface.
+
+ Example of usage:
+ cr = geompy.CanonicalRecognition()
+ cr.isLine(aLine, tolerance)
+ """
+ cr = CanonicalRecognition (self)
+ return cr
+
# end of l2_measure
## @}
Returns:
a new created folder
"""
- if not Father: Father = self.father
return self.CreateFolder(Name, Father)
## Move object to the specified folder
# end of l2_field
## @}
+ ## @addtogroup l2_testing
+ ## @{
+
+ ## Build a mesh on the given shape.
+ # @param shape the source shape
+ # @param linear_deflection linear deflection coefficient
+ # @param is_relative says if given value of deflection is relative to shape's bounding box
+ # @param angular_deflection angular deflection for edges in degrees
+ # @return True in case of success; otherwise False.
+ @ManageTransactions("TestOp")
+ def Tesselate(self, shape, linear_deflection=0, is_relative=True, angular_deflection=0):
+ """Build a mesh on the given shape.
+
+ Parameters:
+ shape the source shape
+ linear_deflection linear deflection coefficient
+ is_relative says if given value of deflection is relative to shape's bounding box
+ angular_deflection angular deflection for edges in degrees
+
+ Returns:
+ True in case of success; otherwise False.
+ """
+ if angular_deflection > 0:
+ angular_deflection = angular_deflection * math.pi / 180.
+ r = self.TestOp.Tesselate(shape, linear_deflection, is_relative, angular_deflection)
+ RaiseIfFailed("Tesselate", self.TestOp)
+ return r
+
+ ## Obtain a shape checker
+ # @return An instance of @ref conformity.CheckConformity "CheckConformity" interface
+ #
+ # @ref tui_conformity_page "Example"
+ def CheckConformity (self, shape):
+ """
+ Obtain a shape checker.
+
+ Example of usage:
+ conf = geompy.CheckConformity(shape)
+ valid = conf.isValid()
+ si2d = conf.selfIntersected2D()
+ dist = conf.distantShapes()
+ small = conf.smallEdges()
+ interfer = cc.interferingSubshapes()
+ """
+ conf = CheckConformity (shape, self)
+ return conf
+
+ ## Obtain a shape proximity calculator
+ # @return An instance of @ref proximity.ShapeProximity "ShapeProximity" interface
+ #
+ # @ref tui_proximity_page "Example"
+ def ShapeProximity (self):
+ """
+ Obtain a shape proximity calculator.
+
+ Example of usage:
+ prox = geompy.ShapeProximity()
+ value = prox.proximity(shape1, shape2)
+ """
+ prox = ShapeProximity (self)
+ return prox
+
+ # end of l2_testing
+ ## @}
+
# Register the new proxy for GEOM_Gen
omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geomBuilder)