1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2023 EDF
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 """Tore : aces toriques et volumes du tore"""
26 from .geomsmesh import geompy
27 from .geomsmesh import geomPublishInFather
29 from .extractionOrientee import extractionOrientee
30 from .getSubshapeIds import getSubshapeIds
32 def facesVolumesToriques(tore, plan, facesDefaut):
34 Extraction des deux faces et volumes du tore partitionné, qui suivent la génératrice elliptique.
35 @param tore : le tore partitionné et coupé.
36 @param plan : le plan de coupe
37 @return (facetore1,facetore2) les 2 faces selon la génératrice
41 centre = geompy.MakeVertexOnSurface(plan, 0.5, 0.5)
42 normal = geompy.GetNormal(plan, centre)
43 reference = geompy.MakeTranslationVector(centre, normal)
45 [facesInPlan, facesOutPlan, _] = extractionOrientee(plan, tore, reference, "FACE", 1.e-2, "faceTorePlan_")
46 facesIdInPlan = getSubshapeIds(tore, facesInPlan)
47 facesIdOutPlan = getSubshapeIds(tore, facesOutPlan)
49 [_, _, facesOnSide] = extractionOrientee(facesDefaut, tore, reference, "FACE", 1.e-2, "faceTorePeau_")
50 facesIdOnSide = getSubshapeIds(tore, facesOnSide)
53 for i_aux, faceId in enumerate(facesIdInPlan):
54 if faceId not in facesIdOnSide:
55 facetore1 = facesInPlan[i_aux]
57 geomPublishInFather(initLog.debug, tore, facetore1, 'facetore1' )
60 for i_aux, faceId in enumerate(facesIdOutPlan):
61 if faceId not in facesIdOnSide:
62 facetore2 = facesOutPlan[i_aux]
64 geomPublishInFather(initLog.debug, tore, facetore2, 'facetore2' )
66 [volumeTore1, volumeTore2] = geompy.ExtractShapes(tore, geompy.ShapeType["SOLID"], True)
67 geomPublishInFather(initLog.debug, tore, volumeTore1, 'volumeTore1' )
68 geomPublishInFather(initLog.debug, tore, volumeTore2, 'volumeTore2' )
70 return facetore1, facetore2, volumeTore1, volumeTore2