2012-08-09 13:58:02 +06:00
# -*- coding: iso-8859-1 -*-
2016-03-15 17:26:56 +05:00
# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2009-02-13 17:16:39 +05:00
#
2012-08-09 13:58:02 +06:00
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2006-05-06 14:44:32 +06:00
#
2012-08-09 13:58:02 +06:00
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
2014-02-18 12:44:41 +06:00
# version 2.1 of the License, or (at your option) any later version.
2006-05-06 14:44:32 +06:00
#
2012-08-09 13:58:02 +06:00
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
2006-05-06 14:44:32 +06:00
#
2012-08-09 13:58:02 +06:00
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2006-05-06 14:44:32 +06:00
#
2012-08-09 13:58:02 +06:00
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2006-05-06 14:44:32 +06:00
#
2012-08-09 13:58:02 +06:00
2004-12-17 16:18:33 +05:00
#==============================================================================
# Info.
# Bug (from script, bug) : cyl2complementary_modified.py, PAL6700
# Modified : 25/11/2004
# Author : Kovaltchuk Alexey
# Project : PAL/SALOME
#==============================================================================
# Import
# ------
2009-02-13 17:16:39 +05:00
#
2004-12-17 16:18:33 +05:00
import salome
2013-04-04 13:06:43 +06:00
salome . salome_init ( )
import GEOM
from salome . geom import geomBuilder
geompy = geomBuilder . New ( salome . myStudy )
2004-12-17 16:18:33 +05:00
geomgui = salome . ImportComponentGUI ( " GEOM " )
2006-05-06 14:44:32 +06:00
import salome_ComponentGUI
2004-12-17 16:18:33 +05:00
def addToStudy ( shape , name ) :
i = geompy . addToStudy ( shape , name )
2016-10-06 12:55:17 +05:00
salome . sg . updateObjBrowser ( False )
2006-05-06 14:44:32 +06:00
if not isinstance ( geomgui , type ( salome_ComponentGUI ) ) :
geomgui . createAndDisplayGO ( i )
2004-12-17 16:18:33 +05:00
return i
# Piece
# -----
# Creer la geometrie en bloc hexahedrique d'un parallelepipede troue d'une piece en forme de T composee de 2 cylindres de diametre different dont les axes se coupent orthogonalement,
# puis mailler en hexahedrique.
gx = 0
gy = 0
gz = 0
g_dx = 250
g_dy = 200
g_dz = 150
g_rayonGrand = 70
g_rayonPetit = 50
# Geometrie
# =========
# Le parallelepipede
# ------------------
p_boite = geompy . MakeBox ( gx - g_dx , gy - g_dy , gz - g_dz , gx + g_dx , gy + g_dy , gz + g_dz )
# Le grand cylindre
# -----------------
g_base = geompy . MakeVertex ( gx - g_dx , gy , gz )
g_dir = geompy . MakeVectorDXDYDZ ( 1 , 0 , 0 )
g_cyl = geompy . MakeCylinder ( g_base , g_dir , g_rayonGrand , g_dx * 2 )
# Le petit cylindre
# -----------------
c_base = geompy . MakeVertex ( gx , gy , gz )
c_dir = geompy . MakeVectorDXDYDZ ( 0 , 0 , 1 )
c_cyl = geompy . MakeCylinder ( c_base , c_dir , g_rayonPetit , g_dz )
# Le parallelepipede troue
# ------------------------
t_boite1 = geompy . MakeBoolean ( p_boite , g_cyl , 2 )
t_boite = geompy . MakeBoolean ( t_boite1 , c_cyl , 2 )
# Partitionner
# ------------
p_tools = [ ]
p_tools . append ( geompy . MakePlane ( c_base , geompy . MakeVectorDXDYDZ ( 0 , g_dz , g_dy ) , 10 ) )
p_tools . append ( geompy . MakePlane ( c_base , geompy . MakeVectorDXDYDZ ( 0 , - g_dz , g_dy ) , 10 ) )
p_tools . append ( geompy . MakePlane ( geompy . MakeVertex ( gx - g_rayonPetit , 0 , 0 ) , geompy . MakeVectorDXDYDZ ( 1 , 0 , 0 ) , 10 ) )
p_tools . append ( geompy . MakePlane ( geompy . MakeVertex ( gx + g_rayonPetit , 0 , 0 ) , geompy . MakeVectorDXDYDZ ( 1 , 0 , 0 ) , 10 ) )
addToStudy ( t_boite , " t_boite " )
2008-03-07 12:45:34 +05:00
p_element = geompy . MakePartition ( [ t_boite ] , p_tools , [ ] , [ ] , 4 , 0 , [ ] , 0 )
2004-12-17 16:18:33 +05:00
# Compound
# --------
# Ajouter la piece dans l'etude
# -----------------------------
idpiece = addToStudy ( p_element , " BoxHoled2Cylinders " )