1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2024 CEA, EDF, 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 # File : GEOM_CanonicalRecognition.py
21 # Author : Vitaly SMETANNIKOV, Open CASCADE S.A.S.
24 def setVectorSize(theVec):
25 "We have to set the vector size because we need to have output values in this vector"
30 class CanonicalRecognition:
31 "The class provides recognition of canonical shapes"
33 def __init__(self, geompyD):
34 self.CR = geompyD.GetICanonicalRecognition()
36 def isPlane(self, shape, tolerance, normal = [], origin = []):
38 Check if shape is planar
40 > CR.isPlane(shape, tolerance, normal, origin)
42 return self.CR.isPlane(shape, tolerance, setVectorSize(normal), setVectorSize(origin))
44 def isSphere(self, shape, tolerance, origin = [], radius = 0.0):
46 Check if shape is spherical
48 > CR.isSphere(shape, tolerance, origin, radius)
50 return self.CR.isSphere(shape, tolerance, setVectorSize(origin), radius)
52 def isCone(self, shape, tolerance, axis = [], apex = [], halfAngle = 0.0):
54 Check if shape is conical
56 > CR.isCone(shape, tolerance, axis, apex, halfAngle)
58 return self.CR.isCone(shape, tolerance, setVectorSize(axis), setVectorSize(apex), halfAngle)
60 def isCylinder(self, shape, tolerance, axis = [], origin = [], radius = 0.0):
62 Check if shape is cylinder
64 > CR.isCylinder(shape, tolerance, axis, origin, radius)
66 return self.CR.isCylinder(shape, tolerance, setVectorSize(axis), setVectorSize(origin), radius)
68 def isLine(self, edge, tolerance, direction = [], origin = []):
70 Check if edge/wire is line
72 > CR.isLine(edge, tolerance, direction, origin)
74 return self.CR.isLine(edge, tolerance, setVectorSize(direction), setVectorSize(origin))
76 def isCircle(self, edge, tolerance, normal = [], origin = [], radius = 0.0):
78 Check if edge/wire is circle
80 > CR.isCircle(edge, tolerance, normal, origin, radius)
82 return self.CR.isCircle(edge, tolerance, setVectorSize(normal), setVectorSize(origin), radius)
84 def isEllipse(self, edge, tolerance, normal = [], dirX = [], origin = [], majorRadius = 0.0, minorRadius = 0.0):
86 Check if edge/wire is ellipse
88 > CR.isEllipse(edge, tolerance, normal, dirX, origin, majorRadius, minorRadius)
90 return self.CR.isEllipse(edge, tolerance, setVectorSize(normal), setVectorSize(dirX), setVectorSize(origin), majorRadius, minorRadius)