Salome HOME
Ménage dans les imports
[modules/smesh.git] / src / Tools / blocFissure / gmu / partitionVolumeSain.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021  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 """Partition volume sain et bloc, face du bloc recevant la fissure"""
21
22 import logging
23
24 import GEOM
25
26 from .geomsmesh import geompy
27 from .geomsmesh import geomPublish
28 from .geomsmesh import geomPublishInFather
29
30 from . import initLog
31
32 def partitionVolumeSain(volumeSain,boiteDefaut):
33   """
34   Partition du volume complet sur lequel porte le calcul par le cube qui contiendra le defaut
35   @param volumeSain : volume complet (geomObject)
36   @param boiteDefaut : cube qui contiendra le defaut, positionné dans l'espace (son centre doit être au voisinage
37   immediat de la peau de l'objet sain: le tore elliptique debouche de paroi)
38   @return (volumeSainPart, partieSaine, volDefaut, faceBloc) : volume complet partionné par le cube, partie saine,
39   bloc du defaut (solide commun au cube et au volume complet), face du bloc defaut correspondant à la paroi.
40   """
41   logging.info("start")
42
43   volumeSainPart = geompy.MakePartition([volumeSain], [boiteDefaut], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
44   [a,b] = geompy.ExtractShapes(volumeSainPart, geompy.ShapeType["SOLID"], True)
45   volDefaut = geompy.GetInPlaceByHistory(volumeSainPart, boiteDefaut)
46   if geompy.GetSubShapeID(volumeSainPart,b) == geompy.GetSubShapeID(volumeSainPart,volDefaut):
47     partieSaine = a
48   else:
49     partieSaine = b
50   faceBloc = geompy.GetShapesOnShapeAsCompound(volumeSain, volDefaut, geompy.ShapeType["FACE"], GEOM.ST_ON)
51
52   geomPublish(initLog.debug,  volumeSainPart, 'volumeSainPart' )
53   geomPublishInFather(initLog.debug, volumeSainPart, partieSaine, 'partieSaine' )
54   geomPublishInFather(initLog.debug, volumeSainPart, volDefaut, 'volDefaut' )
55   geomPublishInFather(initLog.debug, volDefaut, faceBloc, 'faceBloc' )
56   return volumeSainPart, partieSaine, volDefaut, faceBloc