2012-08-09 16:03:55 +06:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2023-06-17 00:28:19 +05:00
|
|
|
# Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE
|
2009-02-17 10:27:49 +05:00
|
|
|
#
|
2012-08-09 16:03:55 +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:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +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-20 18:25:37 +06:00
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2006-05-06 14:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +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:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +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:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2006-05-06 14:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# =======================================
|
2009-02-17 10:27:49 +05:00
|
|
|
#
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
|
|
|
salome.salome_init()
|
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
2017-06-13 15:01:10 +05:00
|
|
|
geompy = geomBuilder.New()
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import SMESH, SALOMEDS
|
|
|
|
from salome.smesh import smeshBuilder
|
2017-06-13 15:01:10 +05:00
|
|
|
smesh = smeshBuilder.New()
|
2005-03-21 13:38:22 +05:00
|
|
|
|
|
|
|
# Geometry
|
|
|
|
# ========
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Create the hexahedrical block geometry of a holed parallelepipede.
|
|
|
|
# The hole has a T form composed by 2 cylinders with different radius, and their axis are normal.
|
|
|
|
# This piece is meshed in hexahedrical.
|
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# Values
|
|
|
|
# ------
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
gx = 0
|
|
|
|
gy = 0
|
|
|
|
gz = 0
|
|
|
|
|
|
|
|
g_dx = 250
|
|
|
|
g_dy = 200
|
|
|
|
g_dz = 150
|
|
|
|
|
|
|
|
g_rayonGrand = 70
|
|
|
|
g_rayonPetit = 50
|
|
|
|
|
|
|
|
g_trim = 1000
|
|
|
|
|
|
|
|
# The parallelepipede
|
|
|
|
# -------------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
p_boite = geompy.MakeBox(gx-g_dx, gy-g_dy, gz-g_dz, gx+g_dx, gy+g_dy, gz+g_dz)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# The great cylinder
|
|
|
|
# ------------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
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)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# The first hole
|
|
|
|
# --------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
b_boite = geompy.MakeCut(p_boite , g_cyl)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Partitioning
|
|
|
|
# ------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
p_base = geompy.MakeVertex(gx, gy, gz)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
p_tools = []
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, 1 , 0 ), g_trim))
|
|
|
|
p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, g_dz, g_dy), g_trim))
|
|
|
|
p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim))
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim))
|
|
|
|
p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim))
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
p_piece = geompy.MakePartition([b_boite], p_tools, [], [], geompy.ShapeType["SOLID"])
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# The small cylinder
|
|
|
|
# ------------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
c_cyl = geompy.MakeCylinder(p_base, geompy.MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# The second hole
|
|
|
|
# ---------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
d_element = geompy.SubShapeAllSorted(p_piece, geompy.ShapeType["SOLID"])
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
d_element[ 8] = geompy.MakeCut(d_element[ 8], c_cyl)
|
|
|
|
d_element[10] = geompy.MakeCut(d_element[10], c_cyl)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Compound
|
|
|
|
# --------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
piece = geompy.RemoveExtraEdges(geompy.MakeCompound(d_element))
|
|
|
|
piece = geompy.MakeGlueFaces(piece, 1e-07)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Add piece in study
|
|
|
|
# ------------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
piece_id = geompy.addToStudy(piece, "ex16_cyl2complementary")
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Meshing
|
|
|
|
# =======
|
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# Create a hexahedral mesh
|
|
|
|
# ------------------------
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
hexa = smesh.Mesh(piece, "ex16_cyl2complementary:hexa")
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
algo = hexa.Segment()
|
|
|
|
algo.NumberOfSegments(12)
|
|
|
|
|
|
|
|
hexa.Quadrangle()
|
|
|
|
|
|
|
|
hexa.Hexahedron()
|
|
|
|
|
|
|
|
# Define local hypothesis
|
|
|
|
# -----------------------
|
|
|
|
|
|
|
|
def local(x, y, z, d):
|
2013-04-04 13:08:19 +06:00
|
|
|
edge = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(x, y, z))
|
2005-03-21 13:38:22 +05:00
|
|
|
algo = hexa.Segment(edge)
|
|
|
|
algo.NumberOfSegments(d)
|
|
|
|
algo.Propagation()
|
|
|
|
|
|
|
|
local(gx , gy+g_dy, gz+g_dz, 7)
|
|
|
|
local(gx+g_dx, gy+g_dy, gz , 21)
|
|
|
|
local(gx+g_dx, gy-g_dy, gz , 21)
|
|
|
|
|
|
|
|
# Mesh calculus
|
|
|
|
# -------------
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2023-02-21 18:59:44 +05:00
|
|
|
isDone = hexa.Compute()
|
|
|
|
if not isDone:
|
|
|
|
raise Exception("Error when computing Mesh")
|
2015-02-20 12:08:10 +05:00
|
|
|
|
|
|
|
# Update object browser
|
|
|
|
# ---------------------
|
|
|
|
|
2017-06-13 15:01:10 +05:00
|
|
|
salome.sg.updateObjBrowser()
|