Salome HOME
8c19f1c2f83d94c74b6e0034c744c8be046cacaf
[modules/geom.git] / src / GEOM_SWIG / canonicalrecognition.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 #  File   : GEOM_CanonicalRecognition.py
21 #  Author : Vitaly SMETANNIKOV, Open CASCADE S.A.S.
22 #  Module : GEOM_SWIG
23
24 def setVectorSize(theVec):
25     "We have to set the vector size because we need to have output values in this vector"
26     if len(theVec) != 3:
27         theVec = [0,0,0]
28     return theVec
29
30 class CanonicalRecognition:
31     "The class provides recognition of canonical shapes"
32
33     def __init__(self, geompyD):
34         self.CR = geompyD.GetICanonicalRecognition()
35         
36     def isPlane(self, shape, tolerance, normal = [], origin = []):
37         """
38         Check if shape is planar
39         Usage:
40         > CR.isPlane(shape, tolerance, normal, origin)
41         """
42         return self.CR.isPlane(shape, tolerance, setVectorSize(normal), setVectorSize(origin))
43
44     def isSphere(self, shape, tolerance, origin = [], radius = 0.0):
45         """
46         Check if shape is spherical
47         Usage:
48         > CR.isSphere(shape, tolerance, origin, radius)
49         """
50         return self.CR.isSphere(shape, tolerance, setVectorSize(origin), radius)
51
52     def isCone(self, shape, tolerance, axis = [], apex = [], halfAngle = 0.0):
53         """
54         Check if shape is conical
55         Usage:
56         > CR.isCone(shape, tolerance, axis, apex, halfAngle)
57         """
58         return self.CR.isCone(shape, tolerance, setVectorSize(axis), setVectorSize(apex), halfAngle)
59
60     def isCylinder(self, shape, tolerance, axis = [], origin = [], radius = 0.0):
61         """
62         Check if shape is cylinder
63         Usage:
64         > CR.isCylinder(shape, tolerance, axis, origin, radius)
65         """
66         return self.CR.isCylinder(shape, tolerance, setVectorSize(axis), setVectorSize(origin), radius)
67
68     def isLine(self, edge, tolerance, direction = [], origin = []):
69         """
70         Check if edge/wire is line
71         Usage:
72         > CR.isLine(edge, tolerance, direction, origin)
73         """
74         return self.CR.isLine(edge, tolerance, setVectorSize(direction), setVectorSize(origin))
75
76     def isCircle(self, edge, tolerance, normal = [], origin = [], radius = 0.0):
77         """
78         Check if edge/wire is circle
79         Usage:
80         > CR.isCircle(edge, tolerance, normal, origin, radius)
81         """
82         return self.CR.isCircle(edge, tolerance, setVectorSize(normal), setVectorSize(origin), radius)
83
84     def isEllipse(self, edge, tolerance, normal = [], dirX = [], origin = [], majorRadius = 0.0, minorRadius = 0.0):
85         """
86         Check if edge/wire is ellipse
87         Usage:
88         > CR.isEllipse(edge, tolerance, normal, dirX, origin, majorRadius, minorRadius)
89         """
90         return self.CR.isEllipse(edge, tolerance, setVectorSize(normal), setVectorSize(dirX), setVectorSize(origin), majorRadius, minorRadius)