2012-08-09 16:03:55 +06:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2019-02-14 16:55:47 +05:00
|
|
|
# Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
|
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.
|
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.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
|
|
#
|
2009-02-17 10:27:49 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
# ====================================================================
|
|
|
|
#
|
2009-02-17 10:27:49 +05:00
|
|
|
import os
|
|
|
|
|
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()
|
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()
|
2009-02-17 10:27:49 +05:00
|
|
|
|
|
|
|
# Parameters
|
|
|
|
# ----------
|
|
|
|
|
|
|
|
results = "/tmp/ZZ"
|
|
|
|
|
|
|
|
radius = 50
|
|
|
|
height = 200
|
|
|
|
|
|
|
|
# Build a cylinder
|
|
|
|
# ----------------
|
|
|
|
|
|
|
|
base = geompy.MakeVertex(0, 0, 0)
|
|
|
|
direction = geompy.MakeVectorDXDYDZ(0, 0, 1)
|
|
|
|
|
|
|
|
cylinder = geompy.MakeCylinder(base, direction, radius, height)
|
|
|
|
|
|
|
|
geompy.addToStudy(cylinder, "Cylinder")
|
|
|
|
|
|
|
|
# Define a mesh on a geometry
|
|
|
|
# ---------------------------
|
|
|
|
|
2017-06-13 15:01:10 +05:00
|
|
|
smesh.UpdateStudy()
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
m = smesh.Mesh(cylinder)
|
|
|
|
|
|
|
|
# 2D mesh with BLSURF
|
|
|
|
# -------------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
algo2d = m.Triangle(smeshBuilder.BLSURF)
|
2009-02-17 10:27:49 +05:00
|
|
|
|
|
|
|
algo2d.SetPhysicalMesh(1)
|
|
|
|
algo2d.SetPhySize(5)
|
|
|
|
|
|
|
|
algo2d.SetGeometricMesh(0)
|
|
|
|
|
|
|
|
# 3D mesh with tepal
|
|
|
|
# ------------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
algo3d = m.Tetrahedron(smeshBuilder.GHS3DPRL)
|
2009-02-17 10:27:49 +05:00
|
|
|
|
|
|
|
algo3d.SetMEDName(results)
|
|
|
|
algo3d.SetNbPart(4)
|
|
|
|
algo3d.SetBackground(False)
|
|
|
|
algo3d.SetKeepFiles(False)
|
|
|
|
|
|
|
|
# Launch meshers
|
|
|
|
# --------------
|
|
|
|
|
|
|
|
status = m.Compute()
|
|
|
|
|
|
|
|
# Test if ok
|
|
|
|
# ----------
|
|
|
|
|
|
|
|
if os.access(results+".xml", os.F_OK):
|
2017-03-20 17:27:30 +05:00
|
|
|
print("Ok: tepal")
|
2009-02-17 10:27:49 +05:00
|
|
|
else:
|
2017-03-20 17:27:30 +05:00
|
|
|
print("KO: tepal")
|
2015-02-20 12:08:10 +05:00
|
|
|
|
|
|
|
# Update object browser
|
|
|
|
# ---------------------
|
|
|
|
|
2017-06-13 15:01:10 +05:00
|
|
|
salome.sg.updateObjBrowser()
|