2012-08-09 16:03:55 +06:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2024-01-20 19:16:41 +05:00
|
|
|
# Copyright (C) 2007-2024 CEA, EDF, 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()
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Geometry
|
2005-03-21 13:38:22 +05:00
|
|
|
# ========
|
|
|
|
|
|
|
|
# Element of a grid compound by a square with a cylinder on each vertex build by using partition
|
|
|
|
|
|
|
|
# Values
|
|
|
|
# ------
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
ox = 0
|
|
|
|
oy = 0
|
|
|
|
oz = 0
|
|
|
|
|
|
|
|
arete = 50
|
|
|
|
hauteur = 100
|
|
|
|
rayon = 10
|
|
|
|
|
|
|
|
g_trim = 1000
|
|
|
|
|
|
|
|
# Box
|
|
|
|
# ---
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
piecePoint = geompy.MakeVertex(ox, oy, oz)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
pieceBox = geompy.MakeBoxTwoPnt(piecePoint, geompy.MakeVertex(ox+arete, oy+hauteur, oz+arete))
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Cut by cylinders
|
|
|
|
# ----------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
dirUp = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
pieceCut1 = geompy.MakeCut(pieceBox , geompy.MakeCylinder(piecePoint , dirUp, rayon, hauteur))
|
|
|
|
pieceCut2 = geompy.MakeCut(pieceCut1, geompy.MakeCylinder(geompy.MakeVertex(ox+arete, oy, oz ), dirUp, rayon, hauteur))
|
|
|
|
pieceCut3 = geompy.MakeCut(pieceCut2, geompy.MakeCylinder(geompy.MakeVertex(ox , oy, oz+arete), dirUp, rayon, hauteur))
|
|
|
|
pieceCut4 = geompy.MakeCut(pieceCut3, geompy.MakeCylinder(geompy.MakeVertex(ox+arete, oy, oz+arete), dirUp, rayon, hauteur))
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Compound by make a partition of a solid
|
|
|
|
# ---------------------------------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
dir = geompy.MakeVectorDXDYDZ(-1, 0, 1)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
tools = []
|
2013-04-04 13:08:19 +06:00
|
|
|
tools.append(geompy.MakePlane(geompy.MakeVertex(ox+rayon, oy, oz ), dir, g_trim))
|
|
|
|
tools.append(geompy.MakePlane(geompy.MakeVertex(ox , oy, oz+rayon), dir, g_trim))
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
piece = geompy.MakePartition([pieceCut4], tools, [], [], geompy.ShapeType["SOLID"])
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Add in study
|
|
|
|
# ------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
piece_id = geompy.addToStudy(piece, "ex10_grid4geometry")
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Meshing
|
|
|
|
# =======
|
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# Create a hexahedral mesh
|
|
|
|
# ------------------------
|
|
|
|
|
|
|
|
hexa = smesh.Mesh(piece, "ex10_grid4geometry:hexa")
|
|
|
|
|
|
|
|
algo = hexa.Segment()
|
|
|
|
algo.NumberOfSegments(10)
|
|
|
|
|
|
|
|
hexa.Quadrangle()
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
hexa.Hexahedron()
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# 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()
|