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