1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2014-2016 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
22 # @package CANRECPluginBuilder
23 # Python API for the CANRECPLUGIN geometry plug-in module.
25 from CANRECPlugin import ICanRecOperations
28 __libraryName__ = "CANRECPluginEngine"
30 ## Get Canonical recognition plugin operations interface
31 # @return an instance of Canonical recognition plugin operations interface
32 def GetCANRECOperations(self):
34 Get Canonical recognition plugin operations interface.
37 An instance of Canonical recognition plugin operations interface
39 anOp = self.GetPluginOperations(self.myStudyId, __libraryName__)
40 return anOp._narrow(ICanRecOperations)
42 ## Perform, if possible, conversion of NURBS (B-Spline, Bezier) geometry to canonical (analytical) form.
43 # @param theObj the input object (solid, compound, compsolid).
44 # @param theMergeSurf the flag to switch on/off merging surfaces in the result shape.
45 # @param theMergeCurves the flag to switch on/off merging curves in the result shape.
46 # @param theTolerance the tolerance of the canonical recognition operation.
47 # @param theName object name when specified, this parameter is used
48 # for result publication in the study. Otherwise, if automatic
49 # publication is switched on, default value is used for result name.
51 # @return New GEOM_Object, containing the canonical recognition of the input object.
52 def MakeCanonicalRecognition(self, theObj, theMergeSurf, theMergeCurves,
53 theTolerance=0.01, theName=None):
55 Perform, if possible, conversion of NURBS (B-Spline, Bezier) geometry to canonical (analytical) form.
58 theObj the input object (solid, compound, compsolid).
59 theMergeSurf the flag to switch on/off merging surfaces in the result shape.
60 theMergeCurves the flag to switch on/off merging curves in the result shape.
61 theTolerance the tolerance of the canonical recognition operation.
62 theName object name when specified, this parameter is used
63 for result publication in the study. Otherwise, if automatic
64 publication is switched on, default value is used for result name.
67 New GEOM_Object, containing the canonical recognition of the input object.
69 from salome.geom.geomBuilder import ParseParameters, RaiseIfFailed
70 anOp = GetCANRECOperations(self)
71 theMergeSurf, theMergeCurves, theTolerance, Parameters = ParseParameters(theMergeSurf, theMergeCurves, theTolerance)
72 (anObj, aStat) = anOp.MakeCanonicalRecognition(theObj, theMergeSurf, theMergeCurves, theTolerance)
73 RaiseIfFailed("MakeCanonicalRecognition", anOp)
74 self._autoPublish(anObj, theName, "canonical")
76 print "Total number of faces in the initial shape: %s" % aStat[0]
77 print "Number of canonical faces in the initial shape: %s" % aStat[1]
78 print "Number of faces converted to the canonical form: %s" % aStat[2]
80 print "Number of merged surfaces: %s" % aStat[3]
82 print "Number of merged curves: %s" % aStat[4]
86 ## Get the number of canonical faces in the shape.
87 # @param theObj the input object (solid, compound, compsolid).
89 # @return the number of canonical faces in the object.
90 def GetNbCanonicalFaces(self, theObj):
92 Get the number of canonical faces in the shape.
95 theObj the input object (solid, compound, compsolid).
98 the number of canonical faces in the object.
100 from salome.geom.geomBuilder import RaiseIfFailed
101 anOp = GetCANRECOperations(self)
102 aNbCanFaces = anOp.GetNbCanonicalFaces(theObj)
103 RaiseIfFailed("GetNbCanonicalFaces", anOp)