1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2016-2022 CEA/DEN, EDF R&D
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
21 """Obtention des surfaces médianes à partir d'une CAO contenue dans un fichier
23 On sait traiter les faces :
30 Author: Gérald NICOLAS
32 __revision__ = "V02.04"
36 from salome.shaper import model
40 from macros.midSurface.surfaceMediane import SurfaceMediane
42 class midSurface(model.Feature):
43 """Création des fibres neutres"""
45 # Feature initializations
48 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
49 model.Feature.__init__(self)
53 """Return Id of the Feature."""
58 """Returns ID of the CAD file."""
62 """Override Feature.getKind()"""
63 return midSurface.ID()
66 #====================================================================================
67 # Initialization of the dialog panel
69 def initAttributes(self):
70 """Override Feature.initAttributes()"""
71 # Creating the input argument of the feature
72 self.data().addAttribute(self.FILE_ID(), ModelAPI.ModelAPI_AttributeString_typeId())
74 #====================================================================================
78 """F.execute() -- execute the Feature"""
79 # Retrieving the user input
80 apath = self.string(self.FILE_ID())
82 filepath = apath.value()
83 #print("filepath : '{}'".format(filepath))
85 if os.path.isfile(filepath):
86 # Lancement du script de création des fibres neutres
88 #l_options.append("-v")
89 l_options.append("-vmax")
90 #l_options.append("-export_step")
91 print("l_options : '{}'".format(l_options))
92 s_med = SurfaceMediane(l_options)
93 with open("/tmp/grr_1", "w") as fic :
94 fic.write("{}\n".format(dir(s_med)))
95 fic.write("\nFichier : {}".format(filepath))
96 erreur, message = s_med.surf_fic_cao (filepath)
97 with open("/tmp/grr_2", "w") as fic :
98 fic.write("erreur = {}, message = '{}'".format(erreur, message))
101 self.setError(message)
103 self.setError("The file '{}' does not exist".format(filepath))
108 """Override Feature.initAttributes().
111 midSurface feature is macro: removes itself on the creation transaction