Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / Tools / blocFissure / gmu / facesVolumesToriques.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2022  EDF R&D
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 """Tore : aces toriques et volumes du tore"""
21
22 import logging
23
24 from . import initLog
25
26 from .geomsmesh import geompy
27 from .geomsmesh import geomPublishInFather
28
29 from .extractionOrientee import extractionOrientee
30 from .getSubshapeIds import getSubshapeIds
31
32 def facesVolumesToriques(tore, plan, facesDefaut):
33   """
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
38   """
39   logging.info("start")
40
41   centre = geompy.MakeVertexOnSurface(plan, 0.5, 0.5)
42   normal = geompy.GetNormal(plan, centre)
43   reference = geompy.MakeTranslationVector(centre, normal)
44
45   [facesInPlan, facesOutPlan, _] = extractionOrientee(plan, tore, reference, "FACE", 1.e-2, "faceTorePlan_")
46   facesIdInPlan = getSubshapeIds(tore, facesInPlan)
47   facesIdOutPlan = getSubshapeIds(tore, facesOutPlan)
48
49   [_, _, facesOnSide] = extractionOrientee(facesDefaut, tore, reference, "FACE", 1.e-2, "faceTorePeau_")
50   facesIdOnSide = getSubshapeIds(tore, facesOnSide)
51
52   facetore1 = None
53   for i_aux, faceId in enumerate(facesIdInPlan):
54     if faceId not in facesIdOnSide:
55       facetore1 = facesInPlan[i_aux]
56       break
57   geomPublishInFather(initLog.debug, tore, facetore1, 'facetore1' )
58
59   facetore2 = None
60   for i_aux, faceId in enumerate(facesIdOutPlan):
61     if faceId not in facesIdOnSide:
62       facetore2 = facesOutPlan[i_aux]
63       break
64   geomPublishInFather(initLog.debug, tore, facetore2, 'facetore2' )
65
66   [volumeTore1, volumeTore2] = geompy.ExtractShapes(tore, geompy.ShapeType["SOLID"], True)
67   geomPublishInFather(initLog.debug, tore, volumeTore1, 'volumeTore1' )
68   geomPublishInFather(initLog.debug, tore, volumeTore2, 'volumeTore2' )
69
70   return facetore1, facetore2, volumeTore1, volumeTore2