Salome HOME
Copyright update 2020
[modules/smesh.git] / src / Tools / blocFissure / gmu / facesVolumesToriques.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020  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
21 import logging
22 from .geomsmesh import geompy
23 from .geomsmesh import geomPublish
24 from .geomsmesh import geomPublishInFather
25 from . import initLog
26 from .extractionOrientee import extractionOrientee
27 from .getSubshapeIds import getSubshapeIds
28
29 # -----------------------------------------------------------------------------
30 # --- TORE
31 # --- faces toriques  et volumes du tore
32
33 def facesVolumesToriques(tore, plan, facesDefaut):
34   """
35   Extraction des deux faces  et volumes du tore partitionné, qui suivent la génératrice elliptique.
36   @param tore : le tore partitionné et coupé.
37   @param plan : le plan de coupe
38   @return (facetore1,facetore2) les 2 faces selon la génératrice
39   """
40   logging.info("start")
41
42   centre = geompy.MakeVertexOnSurface(plan, 0.5, 0.5)
43   normal = geompy.GetNormal(plan, centre)
44   reference = geompy.MakeTranslationVector(centre, normal)
45
46   [facesInPlan, facesOutPlan, facesOnPlan] = extractionOrientee(plan, tore, reference, "FACE", 1.e-2, "faceTorePlan_")
47   [facesInSide, facesOutSide, facesOnSide] = extractionOrientee(facesDefaut, tore, reference, "FACE", 1.e-2, "faceTorePeau_")
48   facesIdInPlan = getSubshapeIds(tore, facesInPlan)
49   facesIdOutPlan = getSubshapeIds(tore, facesOutPlan)
50   facesIdOnSide = getSubshapeIds(tore, facesOnSide)
51   facesIdInSide = getSubshapeIds(tore, facesInSide)
52   facesIdOutSide = getSubshapeIds(tore, facesOutSide)
53   #facesIdInOutSide = facesIdInSide + facesIdOutSide
54   facetore1 = None
55   faceTore2 = None
56   for i, faceId in enumerate(facesIdInPlan):
57     if faceId not in facesIdOnSide:
58       facetore1 = facesInPlan[i]
59       break
60   for i, faceId in enumerate(facesIdOutPlan):
61     if faceId not in facesIdOnSide:
62       facetore2 = facesOutPlan[i]
63       break
64
65   #[facetore1,facetore2] = geompy.GetShapesOnShape(pipe0, tore, geompy.ShapeType["FACE"], GEOM.ST_ON)
66
67   geomPublishInFather(initLog.debug, tore, facetore1, 'facetore1' )
68   geomPublishInFather(initLog.debug, tore, facetore2, 'facetore2' )
69
70   [volumeTore1, volumeTore2] = geompy.ExtractShapes(tore, geompy.ShapeType["SOLID"], True)
71   geomPublishInFather(initLog.debug, tore, volumeTore1, 'volumeTore1' )
72   geomPublishInFather(initLog.debug, tore, volumeTore2, 'volumeTore2' )
73
74   return facetore1, facetore2, volumeTore1, volumeTore2