1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2022-2022 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 ## @defgroup proximity ShapeProximity - tool to check the proximity distance between two shapes
23 # The tool provides the user a possibility to compute the proximity distance between two shapes:
24 # * a minimal diameter of a tube containing both edges (for edge-edge proximity);
25 # * a minimal thickness of a shell containing both faces (for face-face proximity).
27 # In other words, this tool calculate maximal of all possible distances between pair of objects.
28 # It is supported to compute distance between two edges or between two faces.
29 # Other combinations of shapes are prohibited.
34 \brief ShapeProximity interface
37 ## A class to compute proximity value between two shapes.
38 # Use geompy.ShapeProximity() method to obtain an instance of this class.
40 # @ref tui_proximity_page "Example"
42 class ShapeProximity():
44 ShapeProximity interface.
47 prox = geompy.ShapeProximity()
48 value = prox.proximity(shape1, shape2)
51 def __init__(self, geompyD):
52 self.myCommand = "ShapeProximity"
53 self.myOp = geompyD.GetIMeasureOperations()
56 ## Computes proximity between two shapes of the same type
57 def proximity(self, shape1, shape2):
58 self.setShapes(shape1, shape2)
59 #self.coarseProximity()
60 return self.preciseProximity()
63 ## Customize object with the input shapes
64 def setShapes(self, shape1, shape2):
65 self.myProximityValue = None
66 from salome.geom.geomBuilder import RaiseIfFailed
67 self.myCalc = self.myOp.ShapeProximityCalculator(shape1, shape2)
68 RaiseIfFailed(self.myCommand, self.myOp)
71 ## Define the minimal number of sample points for the given shape,
72 # which should be used for raw computation of proximity value
73 def setSampling(self, shape, nbSamples):
74 self.myOp.SetShapeSampling(self.myCalc, shape, nbSamples)
77 ## Find rough proximity value based on polygon/tessellation representation
78 def coarseProximity(self):
79 from salome.geom.geomBuilder import RaiseIfFailed
80 self.myProximityValue = self.myOp.GetCoarseProximity(self.myCalc)
81 RaiseIfFailed(self.myCommand, self.myOp)
82 return self.myProximityValue
85 ## Find precise proximity value based on exact shapes
86 def preciseProximity(self):
87 from salome.geom.geomBuilder import RaiseIfFailed
88 self.myProximityValue = self.myOp.GetPreciseProximity(self.myCalc)
89 RaiseIfFailed(self.myCommand, self.myOp)
90 return self.myProximityValue