mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-11 16:19:17 +05:00
Merge from V6_main 11/02/2013
This commit is contained in:
parent
eb33929a62
commit
465e84c52e
@ -26,7 +26,6 @@
|
||||
# Author : Marc Tajchman - CEA
|
||||
# Date : 10/10/2002
|
||||
# Modified by : Alexander BORODIN (OCN) - autotools usage
|
||||
# $Header$
|
||||
# 13/03/2007: Alexander BORODIN - OCN
|
||||
# Reorganization for usage of autotools
|
||||
#
|
||||
|
@ -476,6 +476,7 @@ AC_OUTPUT([ \
|
||||
doc/docutils/Makefile \
|
||||
doc/docutils/conf.py \
|
||||
doc/salome/Makefile \
|
||||
doc/salome/examples/Makefile \
|
||||
doc/salome/gui/Makefile \
|
||||
doc/salome/gui/GEOM/Makefile \
|
||||
doc/salome/gui/GEOM/doxyfile \
|
||||
@ -499,12 +500,14 @@ AC_OUTPUT([ \
|
||||
src/DlgRef/Makefile \
|
||||
src/EntityGUI/Makefile \
|
||||
src/GEOM/Makefile \
|
||||
src/BlockFix/Makefile \
|
||||
src/GEOMAlgo/Makefile \
|
||||
src/GEOMBase/Makefile \
|
||||
src/GEOMClient/Makefile \
|
||||
src/GEOMFiltersSelection/Makefile \
|
||||
src/Material/Makefile \
|
||||
src/GEOMGUI/Makefile \
|
||||
src/GEOMUtils/Makefile \
|
||||
src/GEOMImpl/Makefile \
|
||||
src/GEOMToolsGUI/Makefile \
|
||||
src/GEOM_I/Makefile \
|
||||
|
@ -20,10 +20,9 @@
|
||||
# -* Makefile *-
|
||||
# Author : Patrick GOLDBRONN (CEA)
|
||||
# Date : 30/11/2001
|
||||
# Modified by : Alexander BORODIN (OCN) - autotools usage
|
||||
# $Header:
|
||||
# Modified by : Alexander BORODIN (OCN) - autotools usage
|
||||
#
|
||||
SUBDIRS = tui gui
|
||||
SUBDIRS = tui gui examples
|
||||
SUBDIRSTUI = tui
|
||||
SUBDIRSGUI = gui
|
||||
|
||||
|
43
doc/salome/examples/3dsketcher.py
Normal file
43
doc/salome/examples/3dsketcher.py
Normal file
@ -0,0 +1,43 @@
|
||||
# 3D Sketcher
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# Create a 3D sketcher (wire) on the given points coordinates
|
||||
sketcher1 = geompy.Make3DSketcher([ 0,0,0, 50,50,50, 0,50,0, 50,0,50, 10,20,100, 0,0,0 ])
|
||||
|
||||
# add object in the study
|
||||
id_sketcher1 = geompy.addToStudy(sketcher1, "Sketcher1")
|
||||
|
||||
# display the sketcher
|
||||
gg.createAndDisplayGO(id_sketcher1)
|
||||
|
||||
# Create a 3D sketcher (wire) with Sketcher3D interface
|
||||
|
||||
# get the interface instance
|
||||
sk = geompy.Sketcher3D()
|
||||
|
||||
# add three points with absolute coordinates
|
||||
# the first point will be the start point of sketcher
|
||||
# two segments will be added by this command
|
||||
sk.addPointsAbsolute(1,2,3, 7,0,0, 10,-3.5,-11)
|
||||
|
||||
# add one segment, defined by two angles in "OXY" coordinate system and length
|
||||
sk.addPointAnglesLength("OXY", 45, 0, 100)
|
||||
|
||||
# add three points with relative coordinates
|
||||
# three segments will be added by this command
|
||||
sk.addPointsRelative(20,0,0, 20,0,100, -40,0,-50)
|
||||
|
||||
# set to close the sketcher
|
||||
sk.close()
|
||||
|
||||
# obtain the sketcher result
|
||||
sketcher2 = sk.wire()
|
||||
|
||||
# add object in the study
|
||||
id_sketcher2 = geompy.addToStudy(sketcher2, "Sketcher2")
|
||||
|
||||
# display the sketcher
|
||||
gg.createAndDisplayGO(id_sketcher2)
|
141
doc/salome/examples/Makefile.am
Normal file
141
doc/salome/examples/Makefile.am
Normal file
@ -0,0 +1,141 @@
|
||||
# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
#
|
||||
# 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
|
||||
# version 2.1 of the License.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# File : Makefile
|
||||
# Author : Alexander KOVALEV (Open Cascade NN)
|
||||
# Modified by :
|
||||
# Module : doc
|
||||
#
|
||||
include $(top_srcdir)/adm_local/unix/make_common_starter.am
|
||||
|
||||
pyexamplesdir = $(docdir)/examples/GEOM
|
||||
|
||||
BAD_TESTS =
|
||||
|
||||
GOOD_TESTS = \
|
||||
3dsketcher.py \
|
||||
advanced_geom_objs_ex01.py \
|
||||
advanced_geom_objs_ex02.py \
|
||||
advanced_geom_objs_ex03.py \
|
||||
angle.py \
|
||||
basic_geom_objs_ex01.py \
|
||||
basic_geom_objs_ex02.py \
|
||||
basic_geom_objs_ex03.py \
|
||||
basic_geom_objs_ex04.py \
|
||||
basic_geom_objs_ex05.py \
|
||||
basic_geom_objs_ex06.py \
|
||||
basic_geom_objs_ex07.py \
|
||||
basic_geom_objs_ex08.py \
|
||||
basic_geom_objs_ex09.py \
|
||||
basic_operations_ex01.py \
|
||||
basic_operations_ex02.py \
|
||||
basic_operations_ex03.py \
|
||||
basic_properties.py \
|
||||
blocks_operations_ex01.py \
|
||||
blocks_operations_ex02.py \
|
||||
blocks_operations_ex03.py \
|
||||
boolean_operations_ex01.py \
|
||||
boolean_operations_ex02.py \
|
||||
boolean_operations_ex03.py \
|
||||
boolean_operations_ex04.py \
|
||||
bounding_box.py \
|
||||
building_by_blocks_ex01.py \
|
||||
building_by_blocks_ex02.py \
|
||||
center_of_mass.py \
|
||||
check_compound_of_blocks.py \
|
||||
check_self_intersections.py \
|
||||
check_shape.py \
|
||||
complex_objs_ex01.py \
|
||||
complex_objs_ex02.py \
|
||||
complex_objs_ex03.py \
|
||||
complex_objs_ex04.py \
|
||||
complex_objs_ex05.py \
|
||||
complex_objs_ex06.py \
|
||||
complex_objs_ex07.py \
|
||||
complex_objs_ex08.py \
|
||||
complex_objs_ex09.py \
|
||||
complex_objs_ex10.py \
|
||||
free_boundaries.py \
|
||||
free_faces.py \
|
||||
get_non_blocks.py \
|
||||
import_export.py \
|
||||
inertia.py \
|
||||
min_distance.py \
|
||||
normal_face.py \
|
||||
notebook_geom.py \
|
||||
point_coordinates.py \
|
||||
primitives_ex01.py \
|
||||
primitives_ex02.py \
|
||||
primitives_ex03.py \
|
||||
primitives_ex04.py \
|
||||
primitives_ex05.py \
|
||||
primitives_ex06.py \
|
||||
primitives_ex07.py \
|
||||
repairing_operations_ex01.py \
|
||||
repairing_operations_ex02.py \
|
||||
repairing_operations_ex03.py \
|
||||
repairing_operations_ex04.py \
|
||||
repairing_operations_ex05.py \
|
||||
repairing_operations_ex06.py \
|
||||
repairing_operations_ex07.py \
|
||||
repairing_operations_ex08.py \
|
||||
repairing_operations_ex09.py \
|
||||
repairing_operations_ex10.py \
|
||||
repairing_operations_ex11.py \
|
||||
sketcher.py \
|
||||
tolerance.py \
|
||||
topological_geom_objs_ex01.py \
|
||||
topological_geom_objs_ex02.py \
|
||||
topological_geom_objs_ex03.py \
|
||||
topological_geom_objs_ex04.py \
|
||||
topological_geom_objs_ex05.py \
|
||||
topological_geom_objs_ex06.py \
|
||||
transformation_operations_ex01.py \
|
||||
transformation_operations_ex02.py \
|
||||
transformation_operations_ex03.py \
|
||||
transformation_operations_ex04.py \
|
||||
transformation_operations_ex05.py \
|
||||
transformation_operations_ex06.py \
|
||||
transformation_operations_ex07.py \
|
||||
transformation_operations_ex08.py \
|
||||
transformation_operations_ex09.py \
|
||||
transformation_operations_ex10.py \
|
||||
transformation_operations_ex11.py \
|
||||
transformation_operations_ex12.py \
|
||||
transformation_operations_ex13.py \
|
||||
viewing_geom_objs_ex01.py \
|
||||
viewing_geom_objs_ex02.py \
|
||||
viewing_geom_objs_ex03.py \
|
||||
viewing_geom_objs_ex04.py \
|
||||
whatis.py \
|
||||
working_with_groups_ex01.py \
|
||||
working_with_groups_ex02.py \
|
||||
working_with_groups_ex03.py \
|
||||
working_with_groups_ex04.py \
|
||||
working_with_groups_ex05.py \
|
||||
working_with_groups_ex06.py
|
||||
|
||||
pyexamples_SCRIPTS = $(BAD_TESTS) $(GOOD_TESTS)
|
||||
|
||||
EXTRA_DIST += $(pyexamples_SCRIPTS) testme.py
|
||||
|
||||
check-local:
|
||||
@for f in $(GOOD_TESTS) ; do \
|
||||
python $(top_srcdir)/doc/salome/examples/testme.py $(top_srcdir)/doc/salome/examples/$$f || exit 1; \
|
||||
done
|
73
doc/salome/examples/advanced_geom_objs_ex01.py
Normal file
73
doc/salome/examples/advanced_geom_objs_ex01.py
Normal file
@ -0,0 +1,73 @@
|
||||
# Creation of PipeTShape
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create PipeTShape object
|
||||
pipetshape = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0)
|
||||
|
||||
# add object in the study
|
||||
id_pipetshape = geompy.addToStudy(pipetshape[0],"PipeTShape")
|
||||
# add groups in the study
|
||||
for g in pipetshape[1:]:
|
||||
geompy.addToStudyInFather(pipetshape[0], g, g.GetName())
|
||||
|
||||
# Create junction vertices
|
||||
P1 = geompy.MakeVertex(0.0, 0.0, 0.0)
|
||||
P2 = geompy.MakeVertex(400.0, 0.0, 0.0)
|
||||
P3 = geompy.MakeVertex(200.0, 0.0, 200.0)
|
||||
|
||||
# create PipeTShape object with position
|
||||
pipetshape_position = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, True, P1, P2, P3)
|
||||
|
||||
# add object in the study
|
||||
id_pipetshape_position = geompy.addToStudy(pipetshape_position[0],"PipeTShape_position")
|
||||
# add groups in the study
|
||||
for g in pipetshape_position[1:]:
|
||||
geompy.addToStudyInFather(pipetshape_position[0], g, g.GetName())
|
||||
|
||||
# create PipeTShape with chamfer object
|
||||
pipetshapechamfer = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0)
|
||||
|
||||
# add object in the study
|
||||
id_pipetshapechamfer = geompy.addToStudy(pipetshapechamfer[0],"PipeTShapeChamfer")
|
||||
# add groups in the study
|
||||
for g in pipetshapechamfer[1:]:
|
||||
geompy.addToStudyInFather(pipetshapechamfer[0], g, g.GetName())
|
||||
|
||||
# create PipeTShape with chamfer object with position
|
||||
pipetshapechamfer_position = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0, True, P1, P2, P3)
|
||||
|
||||
# add object in the study
|
||||
id_pipetshapechamfer_position = geompy.addToStudy(pipetshapechamfer_position[0],"PipeTShapeChamfer_position")
|
||||
# add groups in the study
|
||||
for g in pipetshapechamfer_position[1:]:
|
||||
geompy.addToStudyInFather(pipetshapechamfer_position[0], g, g.GetName())
|
||||
|
||||
# create PipeTShape with fillet object
|
||||
pipetshapefillet = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0)
|
||||
|
||||
# add object in the study
|
||||
id_pipetshapefillet = geompy.addToStudy(pipetshapefillet[0],"PipeTShapeFillet")
|
||||
# add groups in the study
|
||||
for g in pipetshapefillet[1:]:
|
||||
geompy.addToStudyInFather(pipetshapefillet[0], g, g.GetName())
|
||||
|
||||
# create PipeTShape with fillet object with position
|
||||
pipetshapefillet_position = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0, True, P1, P2, P3)
|
||||
|
||||
# add object in the study
|
||||
id_pipetshapefillet_position = geompy.addToStudy(pipetshapefillet_position[0],"PipeTShapeFillet_position")
|
||||
# add groups in the study
|
||||
for g in pipetshapefillet_position[1:]:
|
||||
geompy.addToStudyInFather(pipetshapefillet_position[0], g, g.GetName())
|
||||
|
||||
|
||||
# display pipetshapes
|
||||
gg.createAndDisplayGO(id_pipetshape)
|
||||
gg.createAndDisplayGO(id_pipetshape_position)
|
||||
gg.createAndDisplayGO(id_pipetshapechamfer)
|
||||
gg.createAndDisplayGO(id_pipetshapechamfer_position)
|
||||
gg.createAndDisplayGO(id_pipetshapefillet)
|
||||
gg.createAndDisplayGO(id_pipetshapefillet_position)
|
15
doc/salome/examples/advanced_geom_objs_ex02.py
Normal file
15
doc/salome/examples/advanced_geom_objs_ex02.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Creation of DividedDisk
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
import GEOM
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create DividedDisk object
|
||||
divideddisk = geompy.MakeDividedDisk(100, 1, GEOM.SQUARE)
|
||||
|
||||
# add object in the study
|
||||
id_divideddisk = geompy.addToStudy(divideddisk,"DividedDisk")
|
||||
|
||||
# display divideddisk
|
||||
gg.createAndDisplayGO(id_divideddisk)
|
15
doc/salome/examples/advanced_geom_objs_ex03.py
Normal file
15
doc/salome/examples/advanced_geom_objs_ex03.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Creation of DividedCylinder
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
import GEOM
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create DividedCylinder object
|
||||
dividedcylinder = geompy.MakeDividedCylinder(100, 300, GEOM.SQUARE)
|
||||
|
||||
# add object in the study
|
||||
id_dividedcylinder = geompy.addToStudy(dividedcylinder,"DividedCylinder")
|
||||
|
||||
# display dividedcylinder
|
||||
gg.createAndDisplayGO(id_dividedcylinder)
|
60
doc/salome/examples/angle.py
Normal file
60
doc/salome/examples/angle.py
Normal file
@ -0,0 +1,60 @@
|
||||
# Angle
|
||||
|
||||
import salome
|
||||
salome.salome_init()
|
||||
|
||||
import math
|
||||
import geompy
|
||||
geompy.init_geom(salome.myStudy)
|
||||
|
||||
OX = geompy.MakeVectorDXDYDZ(10, 0,0)
|
||||
OXY = geompy.MakeVectorDXDYDZ(10,10,0)
|
||||
|
||||
# in one plane
|
||||
Angle = geompy.GetAngle(OX, OXY)
|
||||
|
||||
print "\nAngle between OX and OXY = ", Angle
|
||||
if math.fabs(Angle - 45.0) > 1e-05:
|
||||
print " Error: returned angle is", Angle, "while must be 45.0"
|
||||
pass
|
||||
|
||||
Angle = geompy.GetAngleRadians(OX, OXY)
|
||||
|
||||
print "\nAngle between OX and OXY in radians = ", Angle
|
||||
if math.fabs(Angle - math.pi/4) > 1e-05:
|
||||
print " Error: returned angle is", Angle, "while must be pi/4"
|
||||
pass
|
||||
|
||||
Angle = geompy.GetAngleVectors(OX, OXY, True)
|
||||
|
||||
print "\nAngle between vectors OX and OXY = ", Angle
|
||||
if math.fabs(Angle - 45.0) > 1e-05:
|
||||
print " Error: returned angle is", Angle, "while must be 45.0"
|
||||
pass
|
||||
|
||||
Angle = geompy.GetAngleRadiansVectors(OX, OXY, False)
|
||||
|
||||
print "\nBig angle between vectors OX and OXY in radians = ", Angle
|
||||
if math.fabs(Angle - math.pi*7./4.) > 1e-05:
|
||||
print " Error: returned angle is", Angle, "while must be 7*pi/4"
|
||||
pass
|
||||
|
||||
# not in one plane
|
||||
OXY_shift = geompy.MakeTranslation(OXY,10,-10,20)
|
||||
Angle = geompy.GetAngle(OX, OXY_shift)
|
||||
|
||||
print "\nAngle between OX and OXY_shift = ", Angle
|
||||
if math.fabs(Angle - 45.0) > 1e-05:
|
||||
print " Error: returned angle is", Angle, "while must be 45.0"
|
||||
pass
|
||||
|
||||
# not linear
|
||||
pnt1 = geompy.MakeVertex(0, 0, 0)
|
||||
pnt2 = geompy.MakeVertex(10, 0, 0)
|
||||
pnt3 = geompy.MakeVertex(20, 10, 0)
|
||||
arc = geompy.MakeArc(pnt1, pnt2, pnt3)
|
||||
Angle = geompy.GetAngle(OX, arc)
|
||||
|
||||
if (math.fabs(Angle + 1.0) > 1e-6 or geompy.MeasuOp.IsDone()):
|
||||
print "Error. Angle must not be computed on curvilinear edges"
|
||||
pass
|
61
doc/salome/examples/basic_geom_objs_ex01.py
Normal file
61
doc/salome/examples/basic_geom_objs_ex01.py
Normal file
@ -0,0 +1,61 @@
|
||||
# Creation of a Point
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0., 0., 0.)
|
||||
p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.)
|
||||
px = geompy.MakeVertex(100., 0., 0.)
|
||||
py = geompy.MakeVertex(0., 100., 0.)
|
||||
pz = geompy.MakeVertex(0., 0., 100.)
|
||||
p1 = geompy.MakeVertex(50., 50., 30.)
|
||||
|
||||
# create a curve and vertices on it
|
||||
Arc = geompy.MakeArc(py, pz, px)
|
||||
# create a vertex by parameter
|
||||
p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25)
|
||||
# create a vertex by length
|
||||
p_on_arc2 = geompy.MakeVertexOnCurveByLength(Arc, 50., None)
|
||||
#create a vertex by point projection
|
||||
p_on_arc3 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10)
|
||||
|
||||
# create 2 lines and make a point on its intersection
|
||||
line_1 = geompy.MakeLineTwoPnt(p0, p100)
|
||||
line_2 = geompy.MakeLineTwoPnt(p1, pz)
|
||||
p_inter = geompy.MakeVertexOnLinesIntersection(line_1, line_2)
|
||||
|
||||
# create a face and vertices on it
|
||||
Add_line = geompy.MakeLineTwoPnt(px, py)
|
||||
arc_face = geompy.MakeFaceWires([Arc, Add_line], 1)
|
||||
p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5)
|
||||
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35)
|
||||
p_on_face3 = geompy.MakeVertexInsideFace(arc_face)
|
||||
|
||||
|
||||
# add objects in the study
|
||||
id_p0 = geompy.addToStudy(p0, "Vertex 0")
|
||||
id_p100 = geompy.addToStudy(p100, "Vertex 100")
|
||||
id_px = geompy.addToStudy(px, "Vertex X")
|
||||
id_py = geompy.addToStudy(py, "Vertex Y")
|
||||
id_pz = geompy.addToStudy(pz, "Vertex Z")
|
||||
id_Arc = geompy.addToStudy(Arc, "Arc")
|
||||
id_line_1 = geompy.addToStudy(line_1, "Line 1")
|
||||
id_line_2 = geompy.addToStudy(line_2, "Line 2")
|
||||
id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc by parameter")
|
||||
id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc by length")
|
||||
id_p_on_arc3 = geompy.addToStudy(p_on_arc3, "Vertex on Arc by point projection")
|
||||
id_p_inter = geompy.addToStudy(p_inter, "Vertex on Lines Intersection")
|
||||
id_p_on_face1 = geompy.addToStudy(p_on_face1, "Vertex on face by parameter")
|
||||
id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on face by point projection")
|
||||
id_p_on_face3 = geompy.addToStudy(p_on_face3, "Vertex inside face")
|
||||
|
||||
# display vertices
|
||||
gg.createAndDisplayGO(id_p0)
|
||||
gg.createAndDisplayGO(id_p100)
|
||||
gg.createAndDisplayGO(id_Arc)
|
||||
gg.createAndDisplayGO(id_p_inter)
|
||||
gg.createAndDisplayGO(id_p_on_arc)
|
||||
gg.createAndDisplayGO(id_p_on_arc2)
|
||||
gg.createAndDisplayGO(id_p_on_arc3)
|
31
doc/salome/examples/basic_geom_objs_ex02.py
Normal file
31
doc/salome/examples/basic_geom_objs_ex02.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Creation of a Line
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0., 0., 0.)
|
||||
p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.)
|
||||
px = geompy.MakeVertex(100., 0. , 0. )
|
||||
py = geompy.MakeVertex(0. , 100., 0. )
|
||||
pz = geompy.MakeVertex(0. , 0. , 100.)
|
||||
|
||||
# create a vector from two points
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create a line from a point and a vector
|
||||
line1 = geompy.MakeLine(pz, vxy)
|
||||
|
||||
#create a line from two points
|
||||
line2 = geompy.MakeLineTwoPnt(p0, p100)
|
||||
|
||||
# add objects in the study
|
||||
id_vxy = geompy.addToStudy(vxy, "Vector")
|
||||
id_line1 = geompy.addToStudy(line1,"Line1")
|
||||
id_line2 = geompy.addToStudy(line2,"Line2")
|
||||
|
||||
# display lines
|
||||
gg.createAndDisplayGO(id_vxy)
|
||||
gg.createAndDisplayGO(id_line1)
|
||||
gg.createAndDisplayGO(id_line2)
|
30
doc/salome/examples/basic_geom_objs_ex03.py
Normal file
30
doc/salome/examples/basic_geom_objs_ex03.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Creation of a Circle
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0., 0., 0.)
|
||||
px = geompy.MakeVertex(100., 0. , 0. )
|
||||
py = geompy.MakeVertex(0. , 100., 0. )
|
||||
pz = geompy.MakeVertex(0. , 0. , 100.)
|
||||
|
||||
# create a vector on two points
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create a circle from a point, a vector and a radius
|
||||
circle1 = geompy.MakeCircle(pz, vxy, 30)
|
||||
|
||||
#create a circle from three points
|
||||
circle2 = geompy.MakeCircleThreePnt(p0, px, py)
|
||||
|
||||
# add objects in the study
|
||||
id_vxy = geompy.addToStudy(vxy, "Vector")
|
||||
id_circle1 = geompy.addToStudy(circle1,"Circle1")
|
||||
id_circle2 = geompy.addToStudy(circle2,"Circle2")
|
||||
|
||||
# display circles
|
||||
gg.createAndDisplayGO(id_vxy)
|
||||
gg.createAndDisplayGO(id_circle1)
|
||||
gg.createAndDisplayGO(id_circle2)
|
34
doc/salome/examples/basic_geom_objs_ex04.py
Normal file
34
doc/salome/examples/basic_geom_objs_ex04.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Creation of an Ellipse
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0., 0., 0.)
|
||||
p1 = geompy.MakeVertex(50., 50., 50.)
|
||||
p2 = geompy.MakeVertex(0., 50., 0.)
|
||||
|
||||
# create a normal vector from two points
|
||||
normal = geompy.MakeVector(p0, p1)
|
||||
|
||||
# create a major axis vector from two points
|
||||
major = geompy.MakeVector(p0, p2)
|
||||
|
||||
# create an ellipse from a point, a vector and radiuses
|
||||
ellipse1 = geompy.MakeEllipse(p1, normal, 50, 25)
|
||||
|
||||
# create an ellipse from a point, a normal vector, radiuses and a major axis vector
|
||||
ellipse2 = geompy.MakeEllipse(p1, normal, 50, 25, major)
|
||||
|
||||
# add objects in the study
|
||||
id_normal = geompy.addToStudy(normal, "Normal")
|
||||
id_major = geompy.addToStudy(major, "Major Axis")
|
||||
id_ellipse1 = geompy.addToStudy(ellipse1, "Ellipse 1")
|
||||
id_ellipse2 = geompy.addToStudy(ellipse2, "Ellipse 2")
|
||||
|
||||
# display the ellipse and its normal vector
|
||||
gg.createAndDisplayGO(id_normal)
|
||||
gg.createAndDisplayGO(id_major)
|
||||
gg.createAndDisplayGO(id_ellipse1)
|
||||
gg.createAndDisplayGO(id_ellipse2)
|
29
doc/salome/examples/basic_geom_objs_ex05.py
Normal file
29
doc/salome/examples/basic_geom_objs_ex05.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Creation of an Arc
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0., 0., 0.)
|
||||
p1 = geompy.MakeVertex(100., 0., 0.)
|
||||
p2 = geompy.MakeVertex(50., 0., 50.)
|
||||
|
||||
# create an arc from a three points
|
||||
arc1 = geompy.MakeArc(p0, p1, p2)
|
||||
|
||||
# create an arc from a center point, a start point and end point
|
||||
arc2 = geompy.MakeArcCenter(p0, p1, p2, 1)
|
||||
|
||||
# create an arc from a center point, a major point and minor point
|
||||
arc3 = geompy.MakeArcOfEllipse(p0, p1, p2)
|
||||
|
||||
# add objects in the study
|
||||
id_arc1 = geompy.addToStudy(arc1, "Arc 1")
|
||||
id_arc2 = geompy.addToStudy(arc2, "Arc 2")
|
||||
id_arc3 = geompy.addToStudy(arc3, "Arc 3")
|
||||
|
||||
# display the arcs
|
||||
gg.createAndDisplayGO(id_arc1)
|
||||
gg.createAndDisplayGO(id_arc2)
|
||||
gg.createAndDisplayGO(id_arc3)
|
68
doc/salome/examples/basic_geom_objs_ex06.py
Normal file
68
doc/salome/examples/basic_geom_objs_ex06.py
Normal file
@ -0,0 +1,68 @@
|
||||
# Creation of a Curve
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices and vectors
|
||||
p0 = geompy.MakeVertex(0. , 0. , 0. )
|
||||
p1 = geompy.MakeVertex(50. , 100., 200.)
|
||||
p2 = geompy.MakeVertex(150., 50., 100.)
|
||||
p3 = geompy.MakeVertex(100., 150., 170.)
|
||||
p4 = geompy.MakeVertex(200., 200., 150.)
|
||||
|
||||
v1 = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
||||
v2 = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
||||
|
||||
# create a polyline from a list of points
|
||||
polyline = geompy.MakePolyline([p0, p1, p2, p3, p4])
|
||||
|
||||
# create a bezier curve from a list of points
|
||||
bezier = geompy.MakeBezier([p0, p1, p2, p3, p4])
|
||||
|
||||
#create a b-spline curve from a list of points
|
||||
interpol = geompy.MakeInterpol([p0, p1, p2, p3, p4], False)
|
||||
|
||||
#create a b-spline curve with defined directions at the ends
|
||||
interpol_tangents = geompy.MakeInterpolWithTangents([p0, p1, p2, p3, p4], v1, v2)
|
||||
|
||||
#create a polyline using parametric definition of the basic points
|
||||
param_polyline = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Polyline, theNewMethod=True)
|
||||
|
||||
# create a bezier curve using parametric definition of the basic points
|
||||
param_bezier = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 20, geompy.GEOM.Bezier, theNewMethod=True)
|
||||
|
||||
#create a b-spline curve using parametric definition of the basic points
|
||||
param_interpol = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Interpolation, theNewMethod=True)
|
||||
|
||||
|
||||
# add objects in the study
|
||||
id_p0 = geompy.addToStudy(p0, "Point1")
|
||||
id_p1 = geompy.addToStudy(p1, "Point2")
|
||||
id_p2 = geompy.addToStudy(p2, "Point3")
|
||||
id_p3 = geompy.addToStudy(p3, "Point4")
|
||||
id_p4 = geompy.addToStudy(p4, "Point5")
|
||||
id_v1 = geompy.addToStudy(v1, "Vector1")
|
||||
id_v2 = geompy.addToStudy(v2, "Vector2")
|
||||
id_polyline = geompy.addToStudy(polyline, "Polyline")
|
||||
id_bezier = geompy.addToStudy(bezier, "Bezier")
|
||||
id_interpol = geompy.addToStudy(interpol, "Interpol")
|
||||
id_interpol_tangents = geompy.addToStudy(interpol_tangents, "Interpol Tangents")
|
||||
id_param_polyline = geompy.addToStudy(param_polyline, "Polyline Parametric")
|
||||
id_param_bezier = geompy.addToStudy(param_bezier, "Bezier Parametric")
|
||||
id_param_interpol = geompy.addToStudy(param_interpol, "Interpol Parametric")
|
||||
|
||||
|
||||
# display the points and the curves
|
||||
gg.createAndDisplayGO(id_p0)
|
||||
gg.createAndDisplayGO(id_p1)
|
||||
gg.createAndDisplayGO(id_p2)
|
||||
gg.createAndDisplayGO(id_p3)
|
||||
gg.createAndDisplayGO(id_p4)
|
||||
gg.createAndDisplayGO(id_polyline)
|
||||
gg.createAndDisplayGO(id_bezier)
|
||||
gg.createAndDisplayGO(id_interpol)
|
||||
gg.createAndDisplayGO(id_interpol_tangents)
|
||||
gg.createAndDisplayGO(id_param_polyline)
|
||||
gg.createAndDisplayGO(id_param_bezier)
|
||||
gg.createAndDisplayGO(id_param_interpol)
|
27
doc/salome/examples/basic_geom_objs_ex07.py
Normal file
27
doc/salome/examples/basic_geom_objs_ex07.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Creation of a Vector
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p1 = geompy.MakeVertex(10., 50., 20.)
|
||||
p2 = geompy.MakeVertex(70., 70., 70.)
|
||||
|
||||
# create a vector from two points
|
||||
vector1 = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a vector from the given components
|
||||
vector2 = geompy.MakeVectorDXDYDZ(30, 30, 100)
|
||||
|
||||
# add objects in the study
|
||||
id_p1 = geompy.addToStudy(p1, "Point1")
|
||||
id_p2 = geompy.addToStudy(p2, "Point2")
|
||||
id_vector1 = geompy.addToStudy(vector1,"Vector1")
|
||||
id_vector2 = geompy.addToStudy(vector2,"Vector2")
|
||||
|
||||
# display the points and the vectors
|
||||
gg.createAndDisplayGO(id_p1)
|
||||
gg.createAndDisplayGO(id_p2)
|
||||
gg.createAndDisplayGO(id_vector1)
|
||||
gg.createAndDisplayGO(id_vector2)
|
75
doc/salome/examples/basic_geom_objs_ex08.py
Normal file
75
doc/salome/examples/basic_geom_objs_ex08.py
Normal file
@ -0,0 +1,75 @@
|
||||
# Creation of a Plane
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p1 = geompy.MakeVertex( 0., 0., 100.)
|
||||
p2 = geompy.MakeVertex(100., 0., 0.)
|
||||
p3 = geompy.MakeVertex(200., 200., 200.)
|
||||
p4 = geompy.MakeVertex(100., 100., 0.)
|
||||
p5 = geompy.MakeVertex(0. , 100., 0.)
|
||||
|
||||
# create a vectors from the given components
|
||||
vector1 = geompy.MakeVectorDXDYDZ(100., 100., 100.)
|
||||
vector2 = geompy.MakeVectorDXDYDZ(-100., 0., 100.)
|
||||
|
||||
# create a vector from two points
|
||||
vector_arc = geompy.MakeVector(p2, p5)
|
||||
|
||||
# create an arc from three points
|
||||
arc = geompy.MakeArc(p2, p4, p5)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vector_arc, arc])
|
||||
|
||||
# create a face
|
||||
isPlanarWanted = 1
|
||||
face = geompy.MakeFace(wire, isPlanarWanted)
|
||||
trimsize = 1000.
|
||||
|
||||
# create a Local Coordinate System
|
||||
|
||||
LCS = geompy.MakeMarker(100., 100., 101., 1, 0, 0, 0, 1, 0)
|
||||
|
||||
# create a plane from a point, a vector and a trimsize
|
||||
plane1 = geompy.MakePlane(p1, vector1, trimsize)
|
||||
|
||||
# create a plane from three points and a trimsize
|
||||
plane2 = geompy.MakePlaneThreePnt(p1, p2, p3, trimsize)
|
||||
|
||||
# create a plane from the given face
|
||||
plane3 = geompy.MakePlaneFace(face, trimsize)
|
||||
|
||||
# create a plane from two vectors and a trimsize
|
||||
plane4 = geompy.MakePlane2Vec(vector1, vector2, trimsize)
|
||||
|
||||
# create a plane with the Local Coordinate System and a trimsize
|
||||
plane5 = geompy.MakePlaneLCS(LCS, trimsize, 1)
|
||||
|
||||
# add objects in the study
|
||||
id_face = geompy.addToStudy(face, "Face")
|
||||
id_plane1 = geompy.addToStudy(plane1,"Plane1")
|
||||
id_plane2 = geompy.addToStudy(plane2,"Plane2")
|
||||
id_plane3 = geompy.addToStudy(plane3,"Plane3")
|
||||
id_plane4 = geompy.addToStudy(plane4,"Plane4")
|
||||
id_plane5 = geompy.addToStudy(plane5,"Plane5")
|
||||
|
||||
# display the points and the vectors
|
||||
gg.createAndDisplayGO(id_face)
|
||||
gg.createAndDisplayGO(id_plane1)
|
||||
gg.createAndDisplayGO(id_plane2)
|
||||
gg.createAndDisplayGO(id_plane3)
|
||||
gg.createAndDisplayGO(id_plane4)
|
||||
gg.createAndDisplayGO(id_plane5)
|
||||
gg.setDisplayMode(id_plane1,1)
|
||||
gg.setTransparency(id_plane1,0.5)
|
||||
gg.setDisplayMode(id_plane2,1)
|
||||
gg.setTransparency(id_plane2,0.5)
|
||||
gg.setDisplayMode(id_plane3,1)
|
||||
gg.setTransparency(id_plane3,0.5)
|
||||
gg.setDisplayMode(id_plane4,1)
|
||||
gg.setTransparency(id_plane4,0.5)
|
||||
gg.setDisplayMode(id_plane5,1)
|
||||
gg.setTransparency(id_plane5,0.5)
|
38
doc/salome/examples/basic_geom_objs_ex09.py
Normal file
38
doc/salome/examples/basic_geom_objs_ex09.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Creation of a Local Coordinate System
|
||||
|
||||
import GEOM
|
||||
import geompy
|
||||
import math
|
||||
import SALOMEDS
|
||||
|
||||
#Create vertexes, vectors and shapes to construct local CS
|
||||
Vertex_1 = geompy.MakeVertex(50, 50, 50)
|
||||
Vertex_2 = geompy.MakeVertex(70, 70, 70)
|
||||
Vertex_3 = geompy.MakeVertex(0, 0, 0)
|
||||
Vector_X = geompy.MakeVectorDXDYDZ(50, 0, 0)
|
||||
Vector_Y = geompy.MakeVectorDXDYDZ(0, 50, 0)
|
||||
Face_1 = geompy.MakeFaceHW(100, 100, 1)
|
||||
Box_1 = geompy.MakeBoxTwoPnt(Vertex_1, Vertex_2)
|
||||
|
||||
#Construct local CS by manual definition
|
||||
LocalCS_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
|
||||
|
||||
#Construct local CS by center point and two vectors (X and Y directions)
|
||||
LocalCS_2 = geompy.MakeMarkerPntTwoVec(Vertex_3, Vector_X, Vector_Y)
|
||||
|
||||
#Construct local CS from shape orientation
|
||||
LocalCS_FACE = geompy.MakeMarkerFromShape(Face_1)
|
||||
LocalCS_BOX = geompy.MakeMarkerFromShape(Box_1)
|
||||
|
||||
#Add created object to study
|
||||
geompy.addToStudy( Face_1, "Face_1" )
|
||||
geompy.addToStudy( Vertex_1, "Vertex_1" )
|
||||
geompy.addToStudy( Vertex_2, "Vertex_2" )
|
||||
geompy.addToStudy( Box_1, "Box_1" )
|
||||
geompy.addToStudy( Vertex_3, "Vertex_3" )
|
||||
geompy.addToStudy( Vector_X, "Vector_X" )
|
||||
geompy.addToStudy( Vector_Y, "Vector_Y" )
|
||||
geompy.addToStudy( LocalCS_1, "LocalCS_1" )
|
||||
geompy.addToStudy( LocalCS_2, "LocalCS_3" )
|
||||
geompy.addToStudy( LocalCS_FACE, "LocalCS_FACE" )
|
||||
geompy.addToStudy( LocalCS_BOX, "LocalCS_BOX" )
|
41
doc/salome/examples/basic_operations_ex01.py
Normal file
41
doc/salome/examples/basic_operations_ex01.py
Normal file
@ -0,0 +1,41 @@
|
||||
# Partition
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
p200 = geompy.MakeVertex(200., 200., 200.)
|
||||
pz = geompy.MakeVertex( 0., 0., 100.)
|
||||
|
||||
# create a vector
|
||||
vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.)
|
||||
|
||||
# create a box from two points
|
||||
box = geompy.MakeBoxTwoPnt(p0, p200)
|
||||
|
||||
# create a plane
|
||||
trimsize = 500.
|
||||
plane = geompy.MakePlane(pz, vxyz, trimsize)
|
||||
|
||||
# create partition objects
|
||||
partition1 = geompy.MakePartition([box], [plane])
|
||||
partition2 = geompy.Partition([box], [plane])
|
||||
partition3 = geompy.MakeHalfPartition(box, plane)
|
||||
|
||||
# add objects in the study
|
||||
id_box = geompy.addToStudy(box,"Box")
|
||||
id_plane = geompy.addToStudy(plane,"Plane")
|
||||
id_partition1 = geompy.addToStudy(partition1,"MakePartition")
|
||||
id_partition2 = geompy.addToStudy(partition2,"Partition")
|
||||
id_partition3 = geompy.addToStudy(partition3,"MakeHalfPartition")
|
||||
|
||||
# display the partition objects and the plane
|
||||
gg.createAndDisplayGO(id_box)
|
||||
gg.setDisplayMode(id_box,1)
|
||||
gg.createAndDisplayGO(id_plane)
|
||||
gg.setDisplayMode(id_plane,1)
|
||||
gg.createAndDisplayGO(id_partition1)
|
||||
gg.createAndDisplayGO(id_partition2)
|
||||
gg.createAndDisplayGO(id_partition3)
|
28
doc/salome/examples/basic_operations_ex02.py
Normal file
28
doc/salome/examples/basic_operations_ex02.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Archimede
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
p200 = geompy.MakeVertex(200., 200., 200.)
|
||||
|
||||
# create a box from two points
|
||||
box = geompy.MakeBoxTwoPnt(p0, p200)
|
||||
|
||||
# perform an Archimede operation on the selected shape with selected parameters
|
||||
weight = 1000000.
|
||||
waterdensity = 1.
|
||||
meshingdeflection = 0.01
|
||||
archimede = geompy.Archimede(box, weight, waterdensity, meshingdeflection)
|
||||
|
||||
# add objects in the study
|
||||
id_box = geompy.addToStudy(box,"Box")
|
||||
id_archimede = geompy.addToStudy(archimede,"Archimede")
|
||||
|
||||
# display the box and the result of Archimede operation
|
||||
gg.createAndDisplayGO(id_box)
|
||||
gg.setDisplayMode(id_box,1)
|
||||
gg.createAndDisplayGO(id_archimede)
|
||||
gg.setDisplayMode(id_archimede,1)
|
55
doc/salome/examples/basic_operations_ex03.py
Normal file
55
doc/salome/examples/basic_operations_ex03.py
Normal file
@ -0,0 +1,55 @@
|
||||
# Restore presentation parameters and sub-shapes
|
||||
|
||||
import geompy
|
||||
import GEOM
|
||||
import SALOMEDS
|
||||
|
||||
# create a box and a cylinder
|
||||
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
cyl = geompy.MakeCylinderRH(100, 300)
|
||||
|
||||
# create translated box
|
||||
vec = geompy.MakeVectorDXDYDZ(100, 50, 0)
|
||||
tra = geompy.MakeTranslationVector(box, vec)
|
||||
|
||||
# create partition objects
|
||||
partition1 = geompy.MakePartition([box, cyl])
|
||||
partition2 = geompy.MakePartition([box], [cyl])
|
||||
partition3 = geompy.MakePartition([box], [tra])
|
||||
|
||||
# set colours
|
||||
box.SetColor(SALOMEDS.Color(1,0,0))
|
||||
cyl.SetColor(SALOMEDS.Color(0,1,0))
|
||||
|
||||
# add objects in the study
|
||||
geompy.addToStudy(box, "Box")
|
||||
geompy.addToStudy(cyl, "Cylinder")
|
||||
geompy.addToStudy(vec, "Vector")
|
||||
geompy.addToStudy(tra, "Translation")
|
||||
geompy.addToStudy(partition1, "Partition_1")
|
||||
geompy.addToStudy(partition2, "Partition_2")
|
||||
geompy.addToStudy(partition3, "Partition_3")
|
||||
|
||||
# Restore presentation parameters and sub-shapes
|
||||
# different methods can be used to find the sub-shapes in the result:
|
||||
# GetInPlace, GetSame, GetInPlaceByHistory, GetShapesOnShape.
|
||||
# By default, GetInPlace method is used (GEOM.FSM_GetInPlace)
|
||||
geompy.RestoreSubShapes(partition1)
|
||||
|
||||
geompy.RestoreSubShapes(partition2, [], GEOM.FSM_GetInPlace)
|
||||
|
||||
# The list of arguments can be used to avoid restoring all arguments,
|
||||
# but restore only the passed.
|
||||
geompy.RestoreSubShapes(partition3, [tra], GEOM.FSM_GetInPlaceByHistory)
|
||||
|
||||
# To find sub-shapes in a transformed shape only one method could be
|
||||
# used: pass GEOM.FSM_Transformed for that.
|
||||
# True passed for the last argument, means that the transformed shape
|
||||
# will inherit colour and sub-shapes from its first argument (see above
|
||||
# MakeTranslation).
|
||||
geompy.RestoreSubShapes(tra, [], GEOM.FSM_Transformed, True)
|
||||
|
||||
# Also we could do this directly with method addToStudy:
|
||||
partition4 = geompy.MakePartition([box, tra])
|
||||
geompy.addToStudy(partition4, "Partition_4", True, [],
|
||||
GEOM.FSM_GetInPlaceByHistory, False)
|
20
doc/salome/examples/basic_properties.py
Normal file
20
doc/salome/examples/basic_properties.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Basic Properties
|
||||
|
||||
import geompy
|
||||
import math
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
props = geompy.BasicProperties(box)
|
||||
print "\nBox 100x30x100 Basic Properties:"
|
||||
print " Wires length: ", props[0]
|
||||
print " Surface area: ", props[1]
|
||||
print " Volume : ", props[2]
|
||||
length = math.sqrt((props[0] - 1840)*(props[0] - 1840))
|
||||
area = math.sqrt((props[1] - 32000)*(props[1] - 32000))
|
||||
volume = math.sqrt((props[2] - 300000)*(props[2] - 300000))
|
||||
if length > 1e-7 or area > 1e-7 or volume > 1e-7:
|
||||
print "While must be:"
|
||||
print " Wires length: ", 1840
|
||||
print " Surface area: ", 32000
|
||||
print " Volume : ", 300000.
|
35
doc/salome/examples/blocks_operations_ex01.py
Normal file
35
doc/salome/examples/blocks_operations_ex01.py
Normal file
@ -0,0 +1,35 @@
|
||||
# Multi Transformation
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p_25_25_50 = geompy.MakeVertex(25., 25., 50.)
|
||||
p_50_25_25 = geompy.MakeVertex(50., 25., 25.)
|
||||
p_25_50_25 = geompy.MakeVertex(25., 50., 25.)
|
||||
|
||||
box = geompy.MakeBoxDXDYDZ(50, 50, 50)
|
||||
|
||||
top_face = geompy.GetFaceNearPoint(box, p_25_25_50)
|
||||
yz_face = geompy.GetFaceNearPoint(box, p_50_25_25)
|
||||
xz_face = geompy.GetFaceNearPoint(box, p_25_50_25)
|
||||
|
||||
top_face_ind = geompy.GetSubShapeID(box, top_face)
|
||||
yz_face_ind = geompy.GetSubShapeID(box, yz_face)
|
||||
xz_face_ind = geompy.GetSubShapeID(box, xz_face)
|
||||
|
||||
# Multi-transformate block and glue the result
|
||||
box_tr1 = geompy.MakeMultiTransformation1D(box, yz_face_ind, top_face_ind, 3)
|
||||
box_tr2 = geompy.MakeMultiTransformation2D(box, xz_face_ind, yz_face_ind, 3, top_face_ind, 0, 2)
|
||||
|
||||
# add objects in the study
|
||||
id_box = geompy.addToStudy(box, "Box")
|
||||
id_box_tr1 = geompy.addToStudy(box_tr1, "Multi-transformed Block 1D")
|
||||
id_box_tr2 = geompy.addToStudy(box_tr2, "Multi-transformed Block 2D")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_box)
|
||||
gg.setDisplayMode(id_box,1)
|
||||
gg.createAndDisplayGO(id_box_tr1)
|
||||
gg.createAndDisplayGO(id_box_tr2)
|
26
doc/salome/examples/blocks_operations_ex02.py
Normal file
26
doc/salome/examples/blocks_operations_ex02.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Explode on Blocks
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a box and a sphere
|
||||
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
sphere = geompy.MakeSphereR(100)
|
||||
|
||||
# make a compound
|
||||
compound = geompy.MakeCompound([box, sphere])
|
||||
|
||||
# get all the blocks of the given compound, by criteria: min_nb_faces <= nb. of faces <= max_nb_faces
|
||||
min_nb_faces = 6
|
||||
max_nb_faces = 6
|
||||
make_block_explode = geompy.MakeBlockExplode(compound, min_nb_faces, max_nb_faces)
|
||||
|
||||
# add objects in the study
|
||||
id_compound = geompy.addToStudy(compound, "Compound")
|
||||
id_make_block_explode = geompy.addToStudyInFather(compound, make_block_explode[0], "MakeBlockExplode")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_compound)
|
||||
gg.createAndDisplayGO(id_make_block_explode)
|
||||
gg.setDisplayMode(id_make_block_explode,1)
|
20
doc/salome/examples/blocks_operations_ex03.py
Normal file
20
doc/salome/examples/blocks_operations_ex03.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Propagate
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
|
||||
# build all possible propagation groups
|
||||
listChains = geompy.Propagate(check_box)
|
||||
|
||||
# add objects in the study
|
||||
geompy.addToStudy(check_box, "Box")
|
||||
ii = 1
|
||||
for chain in listChains:
|
||||
geompy.addToStudyInFather(check_box, chain, "propagation chain " + `ii`)
|
||||
ii = ii + 1
|
||||
pass
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
38
doc/salome/examples/boolean_operations_ex01.py
Normal file
38
doc/salome/examples/boolean_operations_ex01.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Fuse
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(25, 55, 0)
|
||||
p2 = geompy.MakeVertex( 0, 0, 0)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a cylinder
|
||||
height = 35
|
||||
radius1 = 20
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
# create a sphere
|
||||
sphere = geompy.MakeSphereR(40)
|
||||
|
||||
# fuse
|
||||
fuse1 = geompy.MakeFuse(cylinder, sphere)
|
||||
fuse2 = geompy.MakeBoolean(cylinder, sphere, 3)
|
||||
|
||||
# add objects in the study
|
||||
id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
|
||||
id_sphere = geompy.addToStudy(sphere, "Sphere")
|
||||
id_fuse1 = geompy.addToStudy(fuse1, "Fuse_1")
|
||||
id_fuse2 = geompy.addToStudy(fuse2, "Fuse_2")
|
||||
|
||||
# display results
|
||||
gg.createAndDisplayGO(id_cylinder)
|
||||
gg.setDisplayMode(id_cylinder,1)
|
||||
gg.createAndDisplayGO(id_sphere)
|
||||
gg.setDisplayMode(id_sphere,1)
|
||||
gg.createAndDisplayGO(id_fuse1)
|
||||
gg.setDisplayMode(id_fuse1,1)
|
||||
gg.createAndDisplayGO(id_fuse2)
|
||||
gg.setDisplayMode(id_fuse2,1)
|
28
doc/salome/examples/boolean_operations_ex02.py
Normal file
28
doc/salome/examples/boolean_operations_ex02.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Common
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(25, 55, 0)
|
||||
p2 = geompy.MakeVertex( 0, 0, 0)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a cylinder
|
||||
height = 35
|
||||
radius1 = 20
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
# create a sphere
|
||||
sphere = geompy.MakeSphereR(40)
|
||||
|
||||
# make common
|
||||
common = geompy.MakeCommon(cylinder, sphere)
|
||||
|
||||
# add objects in the study
|
||||
id_common = geompy.addToStudy(common, "Common")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_common)
|
||||
gg.setDisplayMode(id_common,1)
|
28
doc/salome/examples/boolean_operations_ex03.py
Normal file
28
doc/salome/examples/boolean_operations_ex03.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Cut
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(25, 55, 0)
|
||||
p2 = geompy.MakeVertex( 0, 0, 0)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a cylinder
|
||||
height = 35
|
||||
radius1 = 20
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
# create a sphere
|
||||
sphere = geompy.MakeSphereR(40)
|
||||
|
||||
#cut
|
||||
cut = geompy.MakeCut(cylinder, sphere)
|
||||
|
||||
# add objects in the study
|
||||
id_cut = geompy.addToStudy(cut, "Cut")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_cut)
|
||||
gg.setDisplayMode(id_cut,1)
|
28
doc/salome/examples/boolean_operations_ex04.py
Normal file
28
doc/salome/examples/boolean_operations_ex04.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Section
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(25, 55, 0)
|
||||
p2 = geompy.MakeVertex( 0, 0, 0)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a cylinder
|
||||
height = 35
|
||||
radius1 = 20
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
# create a sphere
|
||||
sphere = geompy.MakeSphereR(40)
|
||||
|
||||
# make a section
|
||||
section = geompy.MakeSection(cylinder, sphere)
|
||||
|
||||
# add objects in the study
|
||||
id_section = geompy.addToStudy(section, "Section")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_section)
|
||||
gg.setDisplayMode(id_section,1)
|
17
doc/salome/examples/bounding_box.py
Normal file
17
doc/salome/examples/bounding_box.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Bounding Box
|
||||
|
||||
import geompy
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
|
||||
bb = geompy.BoundingBox(box)
|
||||
print "\nBounding Box of box 100x30x100:"
|
||||
print " Xmin = ", bb[0], ", Xmax = ", bb[1]
|
||||
print " Ymin = ", bb[2], ", Ymax = ", bb[3]
|
||||
print " Zmin = ", bb[4], ", Zmax = ", bb[5]
|
||||
|
||||
aBB = geompy.MakeBoundingBox(box)
|
||||
|
||||
geompy.addToStudy(box, "box 100x30x100")
|
||||
geompy.addToStudy(aBB, "Bounding box of box 100x30x100")
|
55
doc/salome/examples/building_by_blocks_ex01.py
Normal file
55
doc/salome/examples/building_by_blocks_ex01.py
Normal file
@ -0,0 +1,55 @@
|
||||
# Quadrangle Face
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p1 = geompy.MakeVertex( 0., 0., 0.)
|
||||
p2 = geompy.MakeVertex(150., 30., 0.)
|
||||
p3 = geompy.MakeVertex( 0., 120., 50.)
|
||||
p4 = geompy.MakeVertex( 0., 40., 70.)
|
||||
|
||||
# create edges
|
||||
edge1 = geompy.MakeEdge(p1, p2)
|
||||
edge2 = geompy.MakeEdge(p2, p3)
|
||||
edge3 = geompy.MakeEdge(p3, p4)
|
||||
edge4 = geompy.MakeEdge(p4, p1)
|
||||
|
||||
# create a quadrangle face from four edges
|
||||
qface1 = geompy.MakeQuad(edge1, edge2, edge3, edge4)
|
||||
|
||||
# create a quadrangle face from two edges
|
||||
qface2 = geompy.MakeQuad2Edges(edge1, edge3)
|
||||
|
||||
# create a quadrangle from four points in its corners
|
||||
qface3 = geompy.MakeQuad4Vertices(p1, p2, p3, p4)
|
||||
|
||||
# add objects in the study
|
||||
id_p1 = geompy.addToStudy(p1,"Point1")
|
||||
id_p2 = geompy.addToStudy(p2,"Point2")
|
||||
id_p3 = geompy.addToStudy(p3,"Point3")
|
||||
id_p4 = geompy.addToStudy(p4,"Point4")
|
||||
id_edge1 = geompy.addToStudy(edge1,"Edge1")
|
||||
id_edge2 = geompy.addToStudy(edge2,"Edge2")
|
||||
id_edge3 = geompy.addToStudy(edge3,"Edge3")
|
||||
id_edge4 = geompy.addToStudy(edge4,"Edge4")
|
||||
id_qface1 = geompy.addToStudy(qface1,"Qface1")
|
||||
id_qface2 = geompy.addToStudy(qface2,"Qface2")
|
||||
id_qface3 = geompy.addToStudy(qface3,"Qface3")
|
||||
|
||||
# display the vertices, the edges and the quadrangle faces
|
||||
gg.createAndDisplayGO(id_p1)
|
||||
gg.createAndDisplayGO(id_p2)
|
||||
gg.createAndDisplayGO(id_p3)
|
||||
gg.createAndDisplayGO(id_p4)
|
||||
gg.createAndDisplayGO(id_edge1)
|
||||
gg.createAndDisplayGO(id_edge2)
|
||||
gg.createAndDisplayGO(id_edge3)
|
||||
gg.createAndDisplayGO(id_edge4)
|
||||
gg.createAndDisplayGO(id_qface1)
|
||||
gg.setDisplayMode(id_qface1,1)
|
||||
gg.createAndDisplayGO(id_qface2)
|
||||
gg.setDisplayMode(id_qface2,1)
|
||||
gg.createAndDisplayGO(id_qface3)
|
||||
gg.setDisplayMode(id_qface3,1)
|
54
doc/salome/examples/building_by_blocks_ex02.py
Normal file
54
doc/salome/examples/building_by_blocks_ex02.py
Normal file
@ -0,0 +1,54 @@
|
||||
# Hexagonal Solid
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
p1 = geompy.MakeVertex( 0., 0., 40.)
|
||||
p2 = geompy.MakeVertex( 70., -15., 0.)
|
||||
p3 = geompy.MakeVertex( 70., -15., 70.)
|
||||
|
||||
p4 = geompy.MakeVertex( 0., 70., 0.)
|
||||
p5 = geompy.MakeVertex( 0., 70., 40.)
|
||||
p6 = geompy.MakeVertex( 70., 70., 0.)
|
||||
p7 = geompy.MakeVertex( 70., 70., 70.)
|
||||
|
||||
p8 = geompy.MakeVertex( 0., -50., 0.)
|
||||
p9 = geompy.MakeVertex( 0., -50., 40.)
|
||||
p10 = geompy.MakeVertex( 70., -35., 0.)
|
||||
p11 = geompy.MakeVertex( 70., -35., 70.)
|
||||
|
||||
# create faces
|
||||
qface1 = geompy.MakeQuad4Vertices(p0, p1, p2, p3)
|
||||
qface2 = geompy.MakeQuad4Vertices(p4, p5, p6, p7)
|
||||
qface3 = geompy.MakeQuad4Vertices(p0, p1, p4, p5)
|
||||
qface4 = geompy.MakeQuad4Vertices(p2, p3, p6, p7)
|
||||
qface5 = geompy.MakeQuad4Vertices(p0, p2, p4, p6)
|
||||
qface6 = geompy.MakeQuad4Vertices(p1, p3, p5, p7)
|
||||
qface7 = geompy.MakeQuad4Vertices(p8, p9, p10, p11)
|
||||
|
||||
# create a hexahedral solid between two given faces
|
||||
solid1 = geompy.MakeHexa2Faces(qface1, qface7)
|
||||
|
||||
# create a hexahedral solid, bounded by six given faces
|
||||
solid2 = geompy.MakeHexa(qface1, qface2, qface3, qface4, qface5, qface6)
|
||||
|
||||
# add objects in the study
|
||||
geompy.addToStudy(qface1,"qface1")
|
||||
geompy.addToStudy(qface2,"qface2")
|
||||
geompy.addToStudy(qface3,"qface3")
|
||||
geompy.addToStudy(qface4,"qface4")
|
||||
geompy.addToStudy(qface5,"qface5")
|
||||
geompy.addToStudy(qface6,"qface6")
|
||||
geompy.addToStudy(qface7,"qface7")
|
||||
|
||||
id_solid1 = geompy.addToStudy(solid1,"Solid1")
|
||||
id_solid2 = geompy.addToStudy(solid2,"Solid2")
|
||||
|
||||
# display solids
|
||||
gg.createAndDisplayGO(id_solid1)
|
||||
gg.setDisplayMode(id_solid1, 1)
|
||||
gg.createAndDisplayGO(id_solid2)
|
||||
gg.setDisplayMode(id_solid2, 1)
|
19
doc/salome/examples/center_of_mass.py
Normal file
19
doc/salome/examples/center_of_mass.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Center of masses
|
||||
|
||||
import geompy
|
||||
import math
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
cm = geompy.MakeCDG(box)
|
||||
if cm is None:
|
||||
raise RuntimeError, "MakeCDG(box) failed"
|
||||
else:
|
||||
print "\nCentre of gravity of box has been successfully obtained:"
|
||||
coords = geompy.PointCoordinates(cm)
|
||||
print "(", coords[0], ", ", coords[1], ", ", coords[2], ")"
|
||||
dx = math.sqrt((coords[0] - 50)*(coords[0] - 50))
|
||||
dy = math.sqrt((coords[1] - 15)*(coords[1] - 15))
|
||||
dz = math.sqrt((coords[2] - 50)*(coords[2] - 50))
|
||||
if dx > 1e-7 or dy > 1e-7 or dz > 1e-7:
|
||||
print "But must be (50, 15, 50)"
|
21
doc/salome/examples/check_compound_of_blocks.py
Normal file
21
doc/salome/examples/check_compound_of_blocks.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Check Compound of Blocks
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create boxes
|
||||
box1 = geompy.MakeBox(0,0,0,100,50,100)
|
||||
box2 = geompy.MakeBox(100,0,0,250,50,100)
|
||||
|
||||
# make a compound
|
||||
compound = geompy.MakeCompound([box1, box2])
|
||||
|
||||
# glue the faces of the compound
|
||||
tolerance = 1e-5
|
||||
glue = geompy.MakeGlueFaces(compound, tolerance)
|
||||
IsValid = geompy.CheckCompoundOfBlocks(glue)
|
||||
if IsValid == 0:
|
||||
raise RuntimeError, "Invalid compound created"
|
||||
else:
|
||||
print "\nCompound is valid"
|
11
doc/salome/examples/check_self_intersections.py
Normal file
11
doc/salome/examples/check_self_intersections.py
Normal file
@ -0,0 +1,11 @@
|
||||
# Detect Self-intersections
|
||||
|
||||
import geompy
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
IsValid = geompy.CheckSelfIntersections(box)
|
||||
if IsValid == 0:
|
||||
raise RuntimeError, "Box with self-intersections created"
|
||||
else:
|
||||
print "\nBox is valid"
|
11
doc/salome/examples/check_shape.py
Normal file
11
doc/salome/examples/check_shape.py
Normal file
@ -0,0 +1,11 @@
|
||||
# Check Shape
|
||||
|
||||
import geompy
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
IsValid = geompy.CheckShape(box)
|
||||
if IsValid == 0:
|
||||
raise RuntimeError, "Invalid box created"
|
||||
else:
|
||||
print "\nBox is valid"
|
61
doc/salome/examples/complex_objs_ex01.py
Normal file
61
doc/salome/examples/complex_objs_ex01.py
Normal file
@ -0,0 +1,61 @@
|
||||
# Creation of a Prism
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex( 0., 0., 0.)
|
||||
p2 = geompy.MakeVertex( 100., 0., 0.)
|
||||
p3 = geompy.MakeVertex( 100., 100., 0.)
|
||||
p4 = geompy.MakeVertex( 0., 100., 0.)
|
||||
p5 = geompy.MakeVertex( 0., 0., 60.)
|
||||
p6 = geompy.MakeVertex(-100., 0., 0.)
|
||||
p7 = geompy.MakeVertex(-100.,-100., 0.)
|
||||
p8 = geompy.MakeVertex( 0.,-100., 0.)
|
||||
|
||||
# create a vector from the given components
|
||||
vector = geompy.MakeVectorDXDYDZ(50., 50., 50.)
|
||||
|
||||
#create vectors from two points
|
||||
vector1_arc1 = geompy.MakeVector(p1, p2)
|
||||
vector2_arc1 = geompy.MakeVector(p1, p4)
|
||||
vector1_arc2 = geompy.MakeVector(p1, p6)
|
||||
vector2_arc2 = geompy.MakeVector(p1, p8)
|
||||
|
||||
# create arcs from three points
|
||||
arc1 = geompy.MakeArc(p2, p3, p4)
|
||||
arc2 = geompy.MakeArc(p6, p7, p8)
|
||||
|
||||
# create wires
|
||||
wire1 = geompy.MakeWire([vector1_arc1, arc1, vector2_arc1])
|
||||
wire2 = geompy.MakeWire([vector1_arc2, arc2, vector2_arc2])
|
||||
|
||||
# create faces
|
||||
isPlanarWanted = 1
|
||||
face1 = geompy.MakeFace(wire1, isPlanarWanted)
|
||||
face2 = geompy.MakeFace(wire2, isPlanarWanted)
|
||||
|
||||
# create prisms
|
||||
prism1 = geompy.MakePrism(face2, p1, p5)
|
||||
prism2 = geompy.MakePrismVecH(face1, vector, 50)
|
||||
prism3 = geompy.MakePrismVecH2Ways(face1, vector, 50)
|
||||
|
||||
# add objects in the study
|
||||
id_face1 = geompy.addToStudy(face1,"Face1")
|
||||
id_face2 = geompy.addToStudy(face2,"Face2")
|
||||
id_prism1 = geompy.addToStudy(prism1,"Prism1")
|
||||
id_prism2 = geompy.addToStudy(prism2,"Prism2")
|
||||
id_prism3 = geompy.addToStudy(prism3,"Prism3")
|
||||
|
||||
# display cylinders
|
||||
gg.createAndDisplayGO(id_face1)
|
||||
gg.setDisplayMode(id_face1,1)
|
||||
gg.createAndDisplayGO(id_face2)
|
||||
gg.setDisplayMode(id_face2,1)
|
||||
gg.createAndDisplayGO(id_prism1)
|
||||
gg.setDisplayMode(id_prism1,1)
|
||||
gg.createAndDisplayGO(id_prism2)
|
||||
gg.setDisplayMode(id_prism2,1)
|
||||
gg.createAndDisplayGO(id_prism3)
|
||||
gg.setDisplayMode(id_prism3,1)
|
34
doc/salome/examples/complex_objs_ex02.py
Normal file
34
doc/salome/examples/complex_objs_ex02.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Creation of a Revolution
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex( 10., 10., 10.)
|
||||
p2 = geompy.MakeVertex( 15., 15., 50.)
|
||||
p3 = geompy.MakeVertex( 40., 40., 0.)
|
||||
|
||||
#create vectors from two points
|
||||
vector1 = geompy.MakeVector(p1, p2)
|
||||
vector2 = geompy.MakeVector(p1, p3)
|
||||
|
||||
# create a vector from the given components
|
||||
vector3 = geompy.MakeVectorDXDYDZ(-20., -20., 100.)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vector1, vector2])
|
||||
|
||||
# create a revolution
|
||||
revolution = geompy.MakeRevolution(wire, vector3, 2.3)
|
||||
|
||||
# add objects in the study
|
||||
id_vector3 = geompy.addToStudy(vector3,"Axis")
|
||||
id_wire = geompy.addToStudy(wire,"Wire")
|
||||
id_revolution = geompy.addToStudy(revolution,"Revolution")
|
||||
|
||||
# display the vector, the wire and the revolution
|
||||
gg.createAndDisplayGO(id_vector3)
|
||||
gg.createAndDisplayGO(id_wire)
|
||||
gg.createAndDisplayGO(id_revolution)
|
||||
gg.setDisplayMode(id_revolution,1)
|
39
doc/salome/examples/complex_objs_ex03.py
Normal file
39
doc/salome/examples/complex_objs_ex03.py
Normal file
@ -0,0 +1,39 @@
|
||||
# Creation of a Filling
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
mindeg = 2
|
||||
maxdeg = 5
|
||||
tol3d = 0.0001
|
||||
tol2d = 0.0001
|
||||
nbiter = 5
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex( -30., -30., 50.)
|
||||
p2 = geompy.MakeVertex( -60., -60., 30.)
|
||||
p3 = geompy.MakeVertex( -30., -30., 10.)
|
||||
|
||||
# create an arc from three points
|
||||
arc = geompy.MakeArc(p1, p2, p3)
|
||||
ShapeListCompound = []
|
||||
i = 0
|
||||
while i <= 3 :
|
||||
S = geompy.MakeTranslation(arc, i * 50., 0., 0.)
|
||||
ShapeListCompound.append(S)
|
||||
i = i + 1
|
||||
|
||||
compound = geompy.MakeCompound(ShapeListCompound)
|
||||
|
||||
# create a filling
|
||||
filling = geompy.MakeFilling(compound, mindeg, maxdeg, tol3d, tol2d, nbiter)
|
||||
|
||||
# add objects in the study
|
||||
id_compound = geompy.addToStudy(compound,"Compound")
|
||||
id_filling = geompy.addToStudy(filling,"Filling")
|
||||
|
||||
# display the compound and the filling
|
||||
gg.createAndDisplayGO(id_compound)
|
||||
gg.createAndDisplayGO(id_filling)
|
||||
gg.setDisplayMode(id_filling,1)
|
38
doc/salome/examples/complex_objs_ex04.py
Normal file
38
doc/salome/examples/complex_objs_ex04.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Creation of a Pipe
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0. , 0. , 0. )
|
||||
px = geompy.MakeVertex(100., 0. , 0. )
|
||||
py = geompy.MakeVertex(0. , 100., 0. )
|
||||
pz = geompy.MakeVertex(0. , 0. , 100.)
|
||||
pxyz = geompy.MakeVertex(100., 100., 100.)
|
||||
|
||||
# create a vector from two points
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create an arc from three points
|
||||
arc = geompy.MakeArc(py, pz, px)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vxy, arc])
|
||||
|
||||
# create an edge
|
||||
edge = geompy.MakeEdge(p0, pxyz)
|
||||
|
||||
# create a pipe
|
||||
pipe = geompy.MakePipe(wire, edge)
|
||||
|
||||
# add objects in the study
|
||||
id_wire = geompy.addToStudy(wire,"Wire")
|
||||
id_edge = geompy.addToStudy(edge,"Edge")
|
||||
id_pipe = geompy.addToStudy(pipe,"Pipe")
|
||||
|
||||
# display the wire, the edge (path) and the pipe
|
||||
gg.createAndDisplayGO(id_wire)
|
||||
gg.createAndDisplayGO(id_edge)
|
||||
gg.createAndDisplayGO(id_pipe)
|
||||
gg.setDisplayMode(id_pipe,1)
|
32
doc/salome/examples/complex_objs_ex05.py
Normal file
32
doc/salome/examples/complex_objs_ex05.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Creation of a PipeWithDifferentSections
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
Wire_1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0])
|
||||
edges = geompy.SubShapeAll(Wire_1, geompy.ShapeType["EDGE"])
|
||||
vertices = geompy.SubShapeAll(Wire_1, geompy.ShapeType["VERTEX"])
|
||||
|
||||
# create sections
|
||||
circles=[]
|
||||
circles.append(geompy.MakeCircle(vertices[0], edges[0], 20))
|
||||
circles.append(geompy.MakeCircle(vertices[1], edges[0], 40))
|
||||
circles.append(geompy.MakeCircle(vertices[2], edges[2], 30))
|
||||
circles.append(geompy.MakeCircle(vertices[3], edges[2], 20))
|
||||
|
||||
# create pipe
|
||||
Pipe = geompy.MakePipeWithDifferentSections(circles, vertices, Wire_1, 0, 0)
|
||||
|
||||
# add objects in the study
|
||||
geompy.addToStudy(circles[0], "circles1")
|
||||
geompy.addToStudy(circles[1], "circles2")
|
||||
geompy.addToStudy(circles[2], "circles3")
|
||||
geompy.addToStudy(circles[3], "circles4")
|
||||
id_wire = geompy.addToStudy(Wire_1, "Path")
|
||||
id_pipe = geompy.addToStudy(Pipe, "Pipe")
|
||||
|
||||
# display the wire(path) and the pipe
|
||||
gg.createAndDisplayGO(id_wire)
|
||||
gg.createAndDisplayGO(id_pipe)
|
||||
gg.setDisplayMode(id_pipe,1)
|
192
doc/salome/examples/complex_objs_ex06.py
Normal file
192
doc/salome/examples/complex_objs_ex06.py
Normal file
@ -0,0 +1,192 @@
|
||||
# Creation of a PipeWithShellSections
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create path
|
||||
WirePath = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0])
|
||||
|
||||
#=======================================================
|
||||
# Create shell sections
|
||||
#=======================================================
|
||||
ps = [Vertex_1,Vertex_2,Vertex_3,Vertex_4]
|
||||
theLocations = [Vertex_1, Vertex_2, Vertex_3, Vertex_4]
|
||||
VC = geompy.MakeCompound(theLocations)
|
||||
geompy.addToStudy(VC,"VC")
|
||||
vs = [Edge_1,Edge_1,Edge_3,Edge_3]
|
||||
hs = [20,40,30,20]
|
||||
shells = []
|
||||
subbases = []
|
||||
|
||||
# 1 section
|
||||
c0 = geompy.PointCoordinates(ps[0])
|
||||
c1 = geompy.PointCoordinates(ps[1])
|
||||
nx = c1[0] - c0[0]
|
||||
ny = c1[1] - c0[1]
|
||||
nz = c1[2] - c0[2]
|
||||
|
||||
faces = []
|
||||
f1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:TT 20 20:TT 0 20:WF",
|
||||
[c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
|
||||
f2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 20:TT -20 20:TT -20 0:WF",
|
||||
[c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
|
||||
f3 = geompy.MakeSketcher("Sketcher:F 0 0:TT -20 0:TT -20 -20:TT 0 -20:WF",
|
||||
[c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
|
||||
f4 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 -20:TT 20 -20:TT 20 0:WF",
|
||||
[c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
|
||||
faces.append(f1)
|
||||
faces.append(f2)
|
||||
faces.append(f3)
|
||||
faces.append(f4)
|
||||
shell = geompy.MakeSewing(faces,1.e-6)
|
||||
shells.append(shell)
|
||||
faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
|
||||
subbases.append(faces[0])
|
||||
|
||||
# 2 section
|
||||
faces = []
|
||||
|
||||
w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0",
|
||||
[c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
|
||||
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
||||
arc = MakeArc(w,3,-1)
|
||||
w = geompy.MakeWire([e1,e2,e3,arc])
|
||||
f1 = geompy.MakeFace(w,1)
|
||||
|
||||
w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20",
|
||||
[c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
|
||||
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
||||
arc = MakeArc(w,3,-1)
|
||||
w = geompy.MakeWire([e1,e2,e3,arc])
|
||||
f2 = geompy.MakeFace(w,1)
|
||||
|
||||
w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20",
|
||||
[c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
|
||||
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
||||
arc = MakeArc(w,3,-1)
|
||||
w = geompy.MakeWire([e1,e2,e3,arc])
|
||||
f3 = geompy.MakeFace(w,1)
|
||||
|
||||
w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0",
|
||||
[c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
|
||||
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
||||
arc = MakeArc(w,3,-1)
|
||||
w = geompy.MakeWire([e1,e2,e3,arc])
|
||||
f4 = geompy.MakeFace(w,1)
|
||||
|
||||
faces.append(f1)
|
||||
faces.append(f2)
|
||||
faces.append(f3)
|
||||
faces.append(f4)
|
||||
shell = geompy.MakeSewing(faces,1.e-6)
|
||||
shells.append(shell)
|
||||
faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
|
||||
subbases.append(faces[0])
|
||||
|
||||
# 3 section
|
||||
faces = []
|
||||
c2 = geompy.PointCoordinates(ps[2])
|
||||
c3 = geompy.PointCoordinates(ps[3])
|
||||
nx = c3[0] - c2[0]
|
||||
ny = c3[1] - c2[1]
|
||||
nz = c3[2] - c2[2]
|
||||
|
||||
w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0",
|
||||
[c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
|
||||
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
||||
arc = MakeArc(w,3,1)
|
||||
w = geompy.MakeWire([e1,e2,e3,arc])
|
||||
f1 = geompy.MakeFace(w,1)
|
||||
|
||||
w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20",
|
||||
[c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
|
||||
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
||||
arc = MakeArc(w,3,1)
|
||||
w = geompy.MakeWire([e1,e2,e3,arc])
|
||||
f2 = geompy.MakeFace(w,1)
|
||||
|
||||
w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20",
|
||||
[c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
|
||||
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
||||
arc = MakeArc(w,3,1)
|
||||
w = geompy.MakeWire([e1,e2,e3,arc])
|
||||
f3 = geompy.MakeFace(w,1)
|
||||
|
||||
w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0",
|
||||
[c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
|
||||
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
||||
arc = MakeArc(w,3,1)
|
||||
w = geompy.MakeWire([e1,e2,e3,arc])
|
||||
f4 = geompy.MakeFace(w,1)
|
||||
|
||||
faces.append(f1)
|
||||
faces.append(f2)
|
||||
faces.append(f3)
|
||||
faces.append(f4)
|
||||
shell = geompy.MakeSewing(faces,1.e-6)
|
||||
shells.append(shell)
|
||||
faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
|
||||
subbases.append(faces[2])
|
||||
|
||||
# 4 section
|
||||
faces = []
|
||||
|
||||
kk = 4
|
||||
dx = c3[0] - nx/kk
|
||||
dy = c3[1] - ny/kk
|
||||
dz = c3[2] - nz/kk
|
||||
rad = math.sqrt(nx*nx+ny*ny+nz*nz)
|
||||
vc = geompy.MakeVertex(dx,dy,dz)
|
||||
sph = geompy.MakeSpherePntR(vc,rad/kk)
|
||||
shellsph = geompy.SubShapeAll(sph, geompy.ShapeType["SHELL"])
|
||||
|
||||
fs = []
|
||||
vec = geompy.MakeVectorDXDYDZ(0,0,1)
|
||||
ff = geompy.MakePlane(ps[3],vec,40)
|
||||
fs.append(ff)
|
||||
vp = geompy.MakeVertex(c3[0],c3[1],c3[2]+20)
|
||||
ff = geompy.MakePlane(vp,vec,40)
|
||||
fs.append(ff)
|
||||
vp = geompy.MakeVertex(c3[0],c3[1],c3[2]-20)
|
||||
ff = geompy.MakePlane(vp,vec,40)
|
||||
fs.append(ff)
|
||||
vec = geompy.MakeVectorDXDYDZ(1,0,0)
|
||||
ff = geompy.MakePlane(ps[3],vec,40)
|
||||
fs.append(ff)
|
||||
vp = geompy.MakeVertex(c3[0]+20,c3[1],c3[2])
|
||||
ff = geompy.MakePlane(vp,vec,40)
|
||||
fs.append(ff)
|
||||
vp = geompy.MakeVertex(c3[0]-20,c3[1],c3[2])
|
||||
ff = geompy.MakePlane(vp,vec,40)
|
||||
fs.append(ff)
|
||||
aPartition = geompy.MakePartition(shellsph,fs)
|
||||
fs = geompy.SubShapeAllSortedCentres(aPartition, geompy.ShapeType["FACE"])
|
||||
|
||||
faces.append(fs[0])
|
||||
faces.append(fs[1])
|
||||
faces.append(fs[2])
|
||||
faces.append(fs[3])
|
||||
shell = geompy.MakeSewing(faces,1.e-6)
|
||||
shells.append(shell)
|
||||
faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
|
||||
|
||||
|
||||
#===========================================================
|
||||
# Create Pipe
|
||||
#===========================================================
|
||||
subbases = []
|
||||
Pipe = geompy.MakePipeWithShellSections(shells, subbases, theLocations, WirePath,
|
||||
theWithContact=0, theWithCorrection=0)
|
||||
|
||||
# add objects in the study
|
||||
resc = geompy.MakeCompound(shells)
|
||||
id_sec = geompy.addToStudy(resc,"sections")
|
||||
id_wire = geompy.addToStudy(WirePath,"WirePath")
|
||||
id_pipe = geompy.addToStudy(Pipe, "Pipe")
|
||||
|
||||
# display the wire(path), sections and the pipe
|
||||
gg.createAndDisplayGO(id_wire)
|
||||
gg.createAndDisplayGO(id_sec)
|
||||
gg.createAndDisplayGO(id_pipe)
|
||||
gg.setDisplayMode(id_pipe,1)
|
116
doc/salome/examples/complex_objs_ex07.py
Normal file
116
doc/salome/examples/complex_objs_ex07.py
Normal file
@ -0,0 +1,116 @@
|
||||
# Creation of a PipeShellsWithoutPath
|
||||
|
||||
import geompy
|
||||
import math
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# Add a section based on quadrangles
|
||||
# ----------------------------------
|
||||
def section(s, p1, p2=None, p3=None, p4=None):
|
||||
if p2==None:
|
||||
q = p1
|
||||
else:
|
||||
q = geompy.MakeQuad4Vertices(p1, p2, p3, p4)
|
||||
pass
|
||||
s.append(q)
|
||||
publish(q, "section")
|
||||
return q
|
||||
|
||||
|
||||
# find distance between two points
|
||||
# -------------------------------
|
||||
def Dist(p1,p2):
|
||||
c1 = geompy.PointCoordinates(p1)
|
||||
c2 = geompy.PointCoordinates(p2)
|
||||
return math.sqrt( (c2[0]-c1[0])*(c2[0]-c1[0]) +
|
||||
(c2[1]-c1[1])*(c2[1]-c1[1]) +
|
||||
(c2[2]-c1[2])*(c2[2]-c1[2]) )
|
||||
|
||||
|
||||
# return middle point
|
||||
# -------------------------------
|
||||
def MiddleVert(p1,p2):
|
||||
c1 = geompy.PointCoordinates(p1)
|
||||
c2 = geompy.PointCoordinates(p2)
|
||||
return geompy.MakeVertex( (c2[0]+c1[0])/2, (c2[1]+c1[1])/2, (c2[2]+c1[2])/2 )
|
||||
|
||||
|
||||
# Complex section
|
||||
# result - 16 quads from lines
|
||||
# pnt - point from path
|
||||
# vec - direction from path
|
||||
def MakeComplexSect(pnt,vec,rmax,rmin,nb):
|
||||
dang = 1.0/nb/2
|
||||
cmax = geompy.MakeCircle(pnt,vec,rmax)
|
||||
cmin = geompy.MakeCircle(pnt,vec,rmin)
|
||||
faces = []
|
||||
for i in range(0,2*nb,2):
|
||||
p1 = geompy.MakeVertexOnCurve(cmin,dang*i)
|
||||
p2 = geompy.MakeVertexOnCurve(cmax,dang*(i+1))
|
||||
p3 = geompy.MakeVertexOnCurve(cmin,dang*(i+2))
|
||||
f = geompy.MakeQuad4Vertices(pnt,p1,p2,p3)
|
||||
faces.append(f)
|
||||
pass
|
||||
shell = geompy.MakeSewing(faces,1.e-6)
|
||||
return shell
|
||||
|
||||
|
||||
#=======================================================
|
||||
# Create simple path and recieve points
|
||||
# for section creation
|
||||
#=======================================================
|
||||
WirePath = geompy.MakeSketcher("Sketcher:F 0 0:T 60 0:T 40 0:R 0:C 100 90:",
|
||||
[0, 0, 0, 0, 0, 1, 1, 0, 0])
|
||||
vs = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"])
|
||||
|
||||
#=======================================================
|
||||
# Create shell sections
|
||||
#=======================================================
|
||||
shells = []
|
||||
subbases = []
|
||||
locs = []
|
||||
|
||||
# 1 section
|
||||
shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
|
||||
shells.append(shell)
|
||||
vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
|
||||
locs.append(vs1[17])
|
||||
|
||||
# 2 section
|
||||
shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16)
|
||||
shells.append(shell)
|
||||
vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
|
||||
locs.append(vs2[17])
|
||||
|
||||
# 3 section
|
||||
shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
|
||||
shells.append(shell)
|
||||
vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
|
||||
locs.append(vs3[17])
|
||||
|
||||
# 4 section
|
||||
shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16)
|
||||
shells.append(shell)
|
||||
vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
|
||||
locs.append(vs4[17])
|
||||
|
||||
|
||||
#===========================================================
|
||||
# Create Pipe
|
||||
#===========================================================
|
||||
|
||||
Pipe = geompy.MakePipeShellsWithoutPath(shells,locs)
|
||||
|
||||
# add objects in the study
|
||||
resc = geompy.MakeCompound(shells)
|
||||
id_sec = geompy.addToStudy(resc,"sections")
|
||||
resl = geompy.MakeCompound(locs)
|
||||
id_loc = geompy.addToStudy(resl,"locations")
|
||||
id_pipe = geompy.addToStudy(Pipe, "Pipe")
|
||||
|
||||
# display the sections, locations and pipe
|
||||
gg.createAndDisplayGO(id_sec)
|
||||
gg.createAndDisplayGO(id_loc)
|
||||
gg.createAndDisplayGO(id_pipe)
|
||||
gg.setDisplayMode(id_pipe,1)
|
76
doc/salome/examples/complex_objs_ex08.py
Normal file
76
doc/salome/examples/complex_objs_ex08.py
Normal file
@ -0,0 +1,76 @@
|
||||
# Creation of a PipeBiNormalAlongVector
|
||||
|
||||
def MakeHelix(radius, height, rotation, direction):
|
||||
# - create a helix -
|
||||
radius = 1.0 * radius
|
||||
height = 1.0 * height
|
||||
rotation = 1.0 * rotation
|
||||
if direction > 0:
|
||||
direction = +1
|
||||
else:
|
||||
direction = -1
|
||||
pass
|
||||
from math import sqrt
|
||||
length_z = height
|
||||
length_xy = radius*rotation
|
||||
length = sqrt(length_z*length_z + length_xy*length_xy)
|
||||
import geompy
|
||||
nb_steps = 1
|
||||
epsilon = 1.0e-6
|
||||
while 1:
|
||||
z_step = height / nb_steps
|
||||
angle_step = rotation / nb_steps
|
||||
z = 0.0
|
||||
angle = 0.0
|
||||
helix_points = []
|
||||
for n in range(nb_steps+1):
|
||||
from math import cos, sin
|
||||
x = radius * cos(angle)
|
||||
y = radius * sin(angle)
|
||||
p = geompy.MakeVertex(x, y, z)
|
||||
helix_points.append( p )
|
||||
z += z_step
|
||||
angle += direction * angle_step
|
||||
pass
|
||||
helix = geompy.MakeInterpol(helix_points)
|
||||
length_test = geompy.BasicProperties(helix)[0]
|
||||
prec = abs(length-length_test)/length
|
||||
# print nb_steps, length_test, prec
|
||||
if prec < epsilon:
|
||||
break
|
||||
nb_steps *= 2
|
||||
pass
|
||||
return helix
|
||||
|
||||
def MakeSpring(radius, height, rotation, direction, thread_radius, base_rotation=0.0):
|
||||
# - create a pipe -
|
||||
thread_radius = 1.0 * thread_radius
|
||||
# create a helix
|
||||
helix = MakeHelix(radius, height, rotation, direction)
|
||||
# base in the (Ox, Oz) plane
|
||||
import geompy
|
||||
p0 = geompy.MakeVertex(radius-3*thread_radius, 0.0, -thread_radius)
|
||||
p1 = geompy.MakeVertex(radius+3*thread_radius, 0.0, -thread_radius)
|
||||
p2 = geompy.MakeVertex(radius+3*thread_radius, 0.0, +thread_radius)
|
||||
p3 = geompy.MakeVertex(radius-3*thread_radius, 0.0, +thread_radius)
|
||||
e0 = geompy.MakeEdge(p0, p1)
|
||||
e1 = geompy.MakeEdge(p1, p2)
|
||||
e2 = geompy.MakeEdge(p2, p3)
|
||||
e3 = geompy.MakeEdge(p3, p0)
|
||||
w = geompy.MakeWire([e0, e1, e2, e3])
|
||||
# create a base face
|
||||
base = geompy.MakeFace(w, True)
|
||||
# create a binormal vector
|
||||
binormal = geompy.MakeVectorDXDYDZ(0.0, 0.0, 10.0)
|
||||
# create a pipe
|
||||
spring = geompy.MakePipeBiNormalAlongVector(base, helix, binormal)
|
||||
# Publish in the study
|
||||
geompy.addToStudy(base, "base")
|
||||
geompy.addToStudy(helix, "helix")
|
||||
geompy.addToStudy(binormal, "binormal")
|
||||
geompy.addToStudy(spring, "spring")
|
||||
return spring
|
||||
|
||||
from math import pi
|
||||
|
||||
spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2)
|
43
doc/salome/examples/complex_objs_ex09.py
Normal file
43
doc/salome/examples/complex_objs_ex09.py
Normal file
@ -0,0 +1,43 @@
|
||||
# Creation of a Middle Path
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
|
||||
# Create a box
|
||||
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
|
||||
# Get two opposite faces
|
||||
[Face_1,Face_2] = geompy.SubShapes(Box_1, [31, 33])
|
||||
|
||||
# Get edges
|
||||
Box_1_edge_12 = geompy.GetSubShape(Box_1, [12])
|
||||
Box_1_edge_22 = geompy.GetSubShape(Box_1, [22])
|
||||
Box_1_edge_25 = geompy.GetSubShape(Box_1, [25])
|
||||
Box_1_edge_29 = geompy.GetSubShape(Box_1, [29])
|
||||
Box_1_edge_8 = geompy.GetSubShape(Box_1, [8])
|
||||
Box_1_edge_18 = geompy.GetSubShape(Box_1, [18])
|
||||
Box_1_edge_26 = geompy.GetSubShape(Box_1, [26])
|
||||
Box_1_edge_30 = geompy.GetSubShape(Box_1, [30])
|
||||
|
||||
# These three calls to RestorePath return the same result
|
||||
Path_1 = geompy.RestorePath(Box_1, Face_1, Face_2)
|
||||
Path_2 = geompy.RestorePathEdges(Box_1, [Face_1], [Face_2])
|
||||
Path_3 = geompy.RestorePathEdges(Box_1,
|
||||
[Box_1_edge_12, Box_1_edge_22, Box_1_edge_25, Box_1_edge_29],
|
||||
[Box_1_edge_8, Box_1_edge_18, Box_1_edge_26, Box_1_edge_30])
|
||||
|
||||
# Publish created objects
|
||||
geompy.addToStudy( Box_1, 'Box_1' )
|
||||
geompy.addToStudyInFather( Box_1, Face_1, 'Face_1' )
|
||||
geompy.addToStudyInFather( Box_1, Face_2, 'Face_2' )
|
||||
geompy.addToStudyInFather( Box_1, Box_1_edge_25, 'Box_1:edge_25' )
|
||||
geompy.addToStudyInFather( Box_1, Box_1_edge_22, 'Box_1:edge_22' )
|
||||
geompy.addToStudyInFather( Box_1, Box_1_edge_12, 'Box_1:edge_12' )
|
||||
geompy.addToStudyInFather( Box_1, Box_1_edge_29, 'Box_1:edge_29' )
|
||||
geompy.addToStudyInFather( Box_1, Box_1_edge_18, 'Box_1:edge_18' )
|
||||
geompy.addToStudyInFather( Box_1, Box_1_edge_26, 'Box_1:edge_26' )
|
||||
geompy.addToStudyInFather( Box_1, Box_1_edge_8, 'Box_1:edge_8' )
|
||||
geompy.addToStudyInFather( Box_1, Box_1_edge_30, 'Box_1:edge_30' )
|
||||
geompy.addToStudy( Path_1, 'Path_1' )
|
||||
geompy.addToStudy( Path_2, 'Path_2' )
|
||||
geompy.addToStudy( Path_3, 'Path_3' )
|
24
doc/salome/examples/complex_objs_ex10.py
Normal file
24
doc/salome/examples/complex_objs_ex10.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Creation of Tangent Plane On Face
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
|
||||
# Create Vertexes for curve
|
||||
Vertex_1 = geompy.MakeVertex(0, 0, 0)
|
||||
Vertex_2 = geompy.MakeVertex(0, 90, 30)
|
||||
Vertex_3 = geompy.MakeVertex(100, 90, 0)
|
||||
Vertex_4 = geompy.MakeVertex(-100, 90, 0)
|
||||
# Create curve
|
||||
Curve_1 = geompy.MakeInterpol([Vertex_4, Vertex_2, Vertex_3, Vertex_1])
|
||||
# Create Face by Extrusion of the Curve
|
||||
Extrusion_1 = geompy.MakePrismDXDYDZ(Curve_1, 0, 30, -60)
|
||||
# Make Tangent on this Extrusion (Face)
|
||||
Tangent_1 = geompy.MakeTangentPlaneOnFace(Extrusion_1, 0.7, 0.5, 150)
|
||||
# Publish in the study
|
||||
geompy.addToStudy( Vertex_1, "Vertex_1" )
|
||||
geompy.addToStudy( Vertex_2, "Vertex_2" )
|
||||
geompy.addToStudy( Vertex_3, "Vertex_3" )
|
||||
geompy.addToStudy( Vertex_4, "Vertex_4" )
|
||||
geompy.addToStudy( Curve_1, "Curve_1" )
|
||||
geompy.addToStudy( Extrusion_1, "Extrusion_1" )
|
||||
geompy.addToStudy( Tangent_1, "Tangent_1" )
|
79
doc/salome/examples/free_boundaries.py
Normal file
79
doc/salome/examples/free_boundaries.py
Normal file
@ -0,0 +1,79 @@
|
||||
# Check Free Boundaries
|
||||
|
||||
import os
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create boxes
|
||||
box1 = geompy.MakeBox(0,0,0,100,50,100)
|
||||
box2 = geompy.MakeBox(100,0,0,250,50,100)
|
||||
|
||||
# make a compound
|
||||
compound = geompy.MakeCompound([box1, box2])
|
||||
|
||||
# import from *.brep
|
||||
ImportFromBREP = geompy.ImportBREP(os.getenv("DATA_DIR")+"/Shapes/Brep/flight_solid.brep")
|
||||
|
||||
# get a face
|
||||
faces = geompy.SubShapeAllSortedCentres(ImportFromBREP, geompy.ShapeType["FACE"])
|
||||
|
||||
# get the free boundary for face 32
|
||||
Res = geompy.GetFreeBoundary(faces[32])
|
||||
isSuccess = Res[0]
|
||||
ClosedWires = Res[1]
|
||||
OpenWires = Res[2]
|
||||
|
||||
if isSuccess == 1 :
|
||||
print "Checking free boudaries is OK."
|
||||
else :
|
||||
print "Checking free boudaries is KO!"
|
||||
print "len(ClosedWires) = ", len(ClosedWires)
|
||||
|
||||
i = 0
|
||||
for wire in ClosedWires :
|
||||
wire_name = "Face 32 -> Close wires : WIRE %d"%(i+1)
|
||||
geompy.addToStudy(ClosedWires[i], wire_name)
|
||||
if i < len(ClosedWires) :
|
||||
i = i+ 1
|
||||
|
||||
print "len(OpenWires) = ", len(OpenWires)
|
||||
|
||||
i = 0
|
||||
for wire in OpenWires :
|
||||
wire_name = "Face 32 -> Open wires : WIRE %d"%(i+1)
|
||||
geompy.addToStudy(OpenWires[i], wire_name)
|
||||
if i < len(OpenWires) :
|
||||
i = i+ 1
|
||||
|
||||
# get the free boundary for face 41
|
||||
Res = geompy.GetFreeBoundary(faces[41])
|
||||
isSuccess = Res[0]
|
||||
ClosedWires = Res[1]
|
||||
OpenWires = Res[2]
|
||||
|
||||
if isSuccess == 1 :
|
||||
print "Checking free boudaries is OK."
|
||||
else :
|
||||
print "Checking free boudaries is KO!"
|
||||
print "len(ClosedWires) = ", len(ClosedWires)
|
||||
|
||||
i = 0
|
||||
for wire in ClosedWires :
|
||||
wire_name = "Face 41 -> Close wires : WIRE %d"%(i+1)
|
||||
geompy.addToStudy(ClosedWires[i], wire_name)
|
||||
if i < len(ClosedWires) :
|
||||
i = i+ 1
|
||||
|
||||
print "len(OpenWires) = ", len(OpenWires)
|
||||
|
||||
i = 0
|
||||
for wire in OpenWires :
|
||||
wire_name = "Face 41 -> Open wires : WIRE %d"%(i+1)
|
||||
geompy.addToStudy(OpenWires[i], wire_name)
|
||||
if i < len(OpenWires) :
|
||||
i = i+ 1
|
||||
|
||||
# add the imported object to the study
|
||||
id_ImportFromBREP = geompy.addToStudy(ImportFromBREP, "ImportFromBREP")
|
||||
salome.sg.updateObjBrowser(1)
|
46
doc/salome/examples/free_faces.py
Normal file
46
doc/salome/examples/free_faces.py
Normal file
@ -0,0 +1,46 @@
|
||||
# Check Free Faces
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(35, 35, 0)
|
||||
p2 = geompy.MakeVertex(35, 35, 50)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a cylinder
|
||||
cylinder = geompy.MakeCone(p1, v, 30, 20, 20)
|
||||
|
||||
# create a cone
|
||||
cone = geompy.MakeCone(p1, v, 70, 40, 60)
|
||||
|
||||
# make cut
|
||||
cut = geompy.MakeCut(cone, cylinder)
|
||||
|
||||
# get faces as sub-shapes
|
||||
faces = []
|
||||
faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
|
||||
f_2 = geompy.GetSubShapeID(cut, faces[0])
|
||||
|
||||
# remove one face from the shape
|
||||
cut_without_f_2 = geompy.SuppressFaces(cut, [f_2])
|
||||
|
||||
# suppress the specified wire
|
||||
result = geompy.GetFreeFacesIDs(cut_without_f_2)
|
||||
print "A number of free faces is ", len(result)
|
||||
|
||||
# add objects in the study
|
||||
all_faces = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["FACE"])
|
||||
for face in all_faces :
|
||||
sub_shape_id = geompy.GetSubShapeID(cut_without_f_2, face)
|
||||
if result.count(sub_shape_id) > 0 :
|
||||
face_name = "Free face %d"%(sub_shape_id)
|
||||
geompy.addToStudy(face, face_name)
|
||||
|
||||
# in this example all faces from cut_without_f_2 are free
|
||||
id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_cut_without_f_2)
|
||||
gg.setDisplayMode(id_cut_without_f_2,1)
|
26
doc/salome/examples/get_non_blocks.py
Normal file
26
doc/salome/examples/get_non_blocks.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Get Non Blocks
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
|
||||
# create solids
|
||||
box = geompy.MakeBoxDXDYDZ(100, 100, 100)
|
||||
cyl = geompy.MakeCylinderRH(100, 200)
|
||||
|
||||
geompy.addToStudy(box, 'box')
|
||||
geompy.addToStudy(cyl, 'cyl')
|
||||
|
||||
# make a compound
|
||||
compound = geompy.MakeCompound([box, cyl])
|
||||
geompy.addToStudy(compound, 'compound')
|
||||
|
||||
# explore the compound
|
||||
pair = geompy.GetNonBlocks(compound)
|
||||
|
||||
if pair[0] is not None:
|
||||
geompy.addToStudyInFather(compound, pair[0], "GrNonBlocks")
|
||||
pass
|
||||
|
||||
if pair[1] is not None:
|
||||
geompy.addToStudyInFather(compound, pair[1], "GrNonQuads")
|
||||
pass
|
40
doc/salome/examples/import_export.py
Normal file
40
doc/salome/examples/import_export.py
Normal file
@ -0,0 +1,40 @@
|
||||
# Import/Export
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
|
||||
# Example of import from IGES using various formats
|
||||
|
||||
# get a path to SAMPLES_SRC
|
||||
import os
|
||||
thePath = os.getenv("DATA_DIR")
|
||||
# create filenames
|
||||
theFileName1 = thePath + "/Shapes/Iges/boite-3Dipsos_m.igs"
|
||||
theFileName2 = thePath + "/Shapes/Iges/boite-3Dipsos_mm.igs"
|
||||
#print "thePath = ", thePath
|
||||
|
||||
# get units from files
|
||||
UnitName1 = geompy.GetIGESUnit(theFileName1)
|
||||
UnitName2 = geompy.GetIGESUnit(theFileName2)
|
||||
print "UnitName1 = ", UnitName1
|
||||
print "UnitName2 = ", UnitName2
|
||||
|
||||
# import shapes
|
||||
Shape1 = geompy.ImportIGES(theFileName1)
|
||||
Shape2 = geompy.ImportIGES(theFileName2)
|
||||
Shape3 = geompy.ImportFile(theFileName2,"IGES_SCALE")
|
||||
[Xmin1,Xmax1, Ymin1,Ymax1, Zmin1,Zmax1] = geompy.BoundingBox(Shape1)
|
||||
[Xmin2,Xmax2, Ymin2,Ymax2, Zmin2,Zmax2] = geompy.BoundingBox(Shape2)
|
||||
[Xmin3,Xmax3, Ymin3,Ymax3, Zmin3,Zmax3] = geompy.BoundingBox(Shape3)
|
||||
geompy.addToStudy(Shape1, "3Dipsos_m")
|
||||
geompy.addToStudy(Shape2, "3Dipsos_mm")
|
||||
geompy.addToStudy(Shape3, "3Dipsos_mm_scaled")
|
||||
d1 = (Xmax1-Xmin1)*(Xmax1-Xmin1) + (Ymax1-Ymin1)*(Ymax1-Ymin1) + (Zmax1-Zmin1)*(Zmax1-Zmin1)
|
||||
d2 = (Xmax2-Xmin2)*(Xmax2-Xmin2) + (Ymax2-Ymin2)*(Ymax2-Ymin2) + (Zmax2-Zmin2)*(Zmax2-Zmin2)
|
||||
d3 = (Xmax3-Xmin3)*(Xmax3-Xmin3) + (Ymax3-Ymin3)*(Ymax3-Ymin3) + (Zmax3-Zmin3)*(Zmax3-Zmin3)
|
||||
import math
|
||||
dd32 = math.sqrt(d3/d2)
|
||||
dd12 = math.sqrt(d1/d2)
|
||||
dd31 = math.sqrt(d3/d1)
|
||||
# values dd31, dd12 and dd31 can be using for checking
|
||||
print "dd32 = ",dd32," dd12 = ",dd12," dd31 = ",dd31
|
14
doc/salome/examples/inertia.py
Normal file
14
doc/salome/examples/inertia.py
Normal file
@ -0,0 +1,14 @@
|
||||
# Inertia
|
||||
|
||||
import geompy
|
||||
import math
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
In = geompy.Inertia(box)
|
||||
print "\nInertia matrix of box 100x30x100:"
|
||||
print " (", In[0], ", ", In[1], ", ", In[2], ")"
|
||||
print " (", In[3], ", ", In[4], ", ", In[5], ")"
|
||||
print " (", In[6], ", ", In[7], ", ", In[8], ")"
|
||||
print "Main moments of inertia of box 100x30x100:"
|
||||
print " Ix = ", In[9], ", Iy = ", In[10], ", Iz = ", In[11]
|
49
doc/salome/examples/min_distance.py
Normal file
49
doc/salome/examples/min_distance.py
Normal file
@ -0,0 +1,49 @@
|
||||
# Minimal Distance
|
||||
|
||||
import geompy
|
||||
|
||||
# Create two curves with three closest points
|
||||
Vertex_1 = geompy.MakeVertex(0, 0, 0)
|
||||
Vertex_2 = geompy.MakeVertex(0, 70, 0)
|
||||
Vertex_3 = geompy.MakeVertex(30, 100, 0)
|
||||
Vertex_4 = geompy.MakeVertex(60, 70, 0)
|
||||
Vertex_5 = geompy.MakeVertex(90, 100, 0)
|
||||
Vertex_6 = geompy.MakeVertex(120, 70, 0)
|
||||
Vertex_7 = geompy.MakeVertex(120, 0, 0)
|
||||
Vertex_8 = geompy.MakeVertex(90, -30, 0)
|
||||
Vertex_9 = geompy.MakeVertex(60, 0, 0)
|
||||
Vertex_10 = geompy.MakeVertex(30, -30, 0)
|
||||
|
||||
geompy.addToStudy( Vertex_1, 'Vertex_1' )
|
||||
geompy.addToStudy( Vertex_2, 'Vertex_2' )
|
||||
geompy.addToStudy( Vertex_3, 'Vertex_3' )
|
||||
geompy.addToStudy( Vertex_4, 'Vertex_4' )
|
||||
geompy.addToStudy( Vertex_5, 'Vertex_5' )
|
||||
geompy.addToStudy( Vertex_6, 'Vertex_6' )
|
||||
geompy.addToStudy( Vertex_7, 'Vertex_7' )
|
||||
geompy.addToStudy( Vertex_8, 'Vertex_8' )
|
||||
geompy.addToStudy( Vertex_9, 'Vertex_9' )
|
||||
geompy.addToStudy( Vertex_10, 'Vertex_10' )
|
||||
|
||||
Curve_a = geompy.MakeInterpol([Vertex_2, Vertex_3, Vertex_4, Vertex_5, Vertex_6], False, True)
|
||||
Curve_b = geompy.MakeInterpol([Vertex_1, Vertex_7, Vertex_8, Vertex_9, Vertex_10], False, True)
|
||||
|
||||
geompy.addToStudy( Curve_a, 'Curve_a' )
|
||||
geompy.addToStudy( Curve_b, 'Curve_b' )
|
||||
|
||||
# Get all closest points
|
||||
[nbSols, listCoords] = geompy.ClosestPoints(Curve_a, Curve_b)
|
||||
|
||||
for i in range(nbSols):
|
||||
v1 = geompy.MakeVertex(listCoords[i*6 + 0], listCoords[i*6 + 1], listCoords[i*6 + 2])
|
||||
v2 = geompy.MakeVertex(listCoords[i*6 + 3], listCoords[i*6 + 4], listCoords[i*6 + 5])
|
||||
|
||||
geompy.addToStudy(v1, 'MinDist_%d_Curve_a'%(i+1))
|
||||
geompy.addToStudy(v2, 'MinDist_%d_Curve_b'%(i+1))
|
||||
|
||||
# Get minimum distance
|
||||
print "Minimal distance between Curve_a and Curve_b is", geompy.MinDistance(Curve_a, Curve_b)
|
||||
|
||||
# Get minimum distance with components along axes
|
||||
[aDist, DX, DY, DZ] = geompy.MinDistanceComponents(Curve_a, Curve_b)
|
||||
print "Minimal distance between Curve_a and Curve_b is (", DX, ",", DY, ",", DZ, ")"
|
17
doc/salome/examples/normal_face.py
Normal file
17
doc/salome/examples/normal_face.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Normal to a Face
|
||||
|
||||
import geompy
|
||||
import math
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
|
||||
faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"])
|
||||
face0 = faces[0]
|
||||
vnorm = geompy.GetNormal(face0)
|
||||
if vnorm is None:
|
||||
raise RuntimeError, "GetNormal(face0) failed"
|
||||
else:
|
||||
geompy.addToStudy(face0, "Face0")
|
||||
geompy.addToStudy(vnorm, "Normale to Face0")
|
||||
print "\nNormale of face has been successfully obtained"
|
21
doc/salome/examples/notebook_geom.py
Normal file
21
doc/salome/examples/notebook_geom.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Using SALOME NoteBook
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
import salome_notebook
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# set variables
|
||||
notebook = salome_notebook.notebook
|
||||
notebook.set("Length", 150)
|
||||
notebook.set("Width", 100)
|
||||
|
||||
# create box
|
||||
box = geompy.MakeBoxDXDYDZ("Length", "Width", 200)
|
||||
|
||||
# add object in the study
|
||||
id_box = geompy.addToStudy(box,"Box")
|
||||
|
||||
# display the boxes
|
||||
gg.createAndDisplayGO(id_box)
|
||||
gg.setDisplayMode(id_box,1)
|
21
doc/salome/examples/point_coordinates.py
Normal file
21
doc/salome/examples/point_coordinates.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Point Coordinates
|
||||
|
||||
import math
|
||||
import geompy
|
||||
|
||||
# create a point
|
||||
point = geompy.MakeVertex(15., 23., 80.)
|
||||
|
||||
# get the coordinates of the point and check its values
|
||||
coords = geompy.PointCoordinates(point)
|
||||
|
||||
# check the obtained coordinate values
|
||||
tolerance = 1.e-07
|
||||
def IsEqual(val1, val2): return (math.fabs(val1 - val2) < tolerance)
|
||||
|
||||
if IsEqual(coords[0], 15.) and IsEqual(coords[1], 23.) and IsEqual(coords[2], 80.):
|
||||
print "All values are OK."
|
||||
else :
|
||||
print "Coordinates of point must be (15, 23, 80), but returned (",
|
||||
print coords[0], ", ", coords[1], ", ", coords[2], ")"
|
||||
pass
|
27
doc/salome/examples/primitives_ex01.py
Normal file
27
doc/salome/examples/primitives_ex01.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Creation of a Box
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(15, 25, 35)
|
||||
p70 = geompy.MakeVertex(70, 70, 70)
|
||||
|
||||
# create boxes
|
||||
box1 = geompy.MakeBoxDXDYDZ(10, 20, 30)
|
||||
box2 = geompy.MakeBox(10,20,30, 15,25,35)
|
||||
box3 = geompy.MakeBoxTwoPnt(p0, p70)
|
||||
|
||||
# add objects in the study
|
||||
id_box1 = geompy.addToStudy(box1,"Box1")
|
||||
id_box2 = geompy.addToStudy(box2,"Box2")
|
||||
id_box3 = geompy.addToStudy(box3,"Box3")
|
||||
|
||||
# display the boxes
|
||||
gg.createAndDisplayGO(id_box1)
|
||||
gg.setDisplayMode(id_box1,1)
|
||||
gg.createAndDisplayGO(id_box2)
|
||||
gg.setDisplayMode(id_box2,1)
|
||||
gg.createAndDisplayGO(id_box3)
|
||||
gg.setDisplayMode(id_box3,1)
|
30
doc/salome/examples/primitives_ex02.py
Normal file
30
doc/salome/examples/primitives_ex02.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Creation of a Cylinder
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(25, 35, 45)
|
||||
p2 = geompy.MakeVertex(70, 70, 70)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create cylinders
|
||||
height = 40
|
||||
|
||||
radius1 = 15
|
||||
cylinder1 = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
radius2 = 30
|
||||
cylinder2 = geompy.MakeCylinderRH(radius2, height)
|
||||
|
||||
# add objects in the study
|
||||
id_cylinder1 = geompy.addToStudy(cylinder1,"Cylinder1")
|
||||
id_cylinder2 = geompy.addToStudy(cylinder2,"Cylinder2")
|
||||
|
||||
# display the cylinders
|
||||
gg.createAndDisplayGO(id_cylinder1)
|
||||
gg.setDisplayMode(id_cylinder1,1)
|
||||
gg.createAndDisplayGO(id_cylinder2)
|
||||
gg.setDisplayMode(id_cylinder2,1)
|
29
doc/salome/examples/primitives_ex03.py
Normal file
29
doc/salome/examples/primitives_ex03.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Creation of a Sphere
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex
|
||||
p = geompy.MakeVertex(55, 45, 25)
|
||||
|
||||
# create spheres
|
||||
radius1 = 20
|
||||
sphere1 = geompy.MakeSpherePntR(p, radius1)
|
||||
radius2 = 15
|
||||
sphere2 = geompy.MakeSphere(0, 0, 45, radius2)
|
||||
radius3 = 30
|
||||
sphere3 = geompy.MakeSphereR(radius3)
|
||||
|
||||
# add objects in the study
|
||||
id_sphere1 = geompy.addToStudy(sphere1,"Sphere1")
|
||||
id_sphere2 = geompy.addToStudy(sphere2,"Sphere2")
|
||||
id_sphere3 = geompy.addToStudy(sphere3,"Sphere3")
|
||||
|
||||
# display spheres
|
||||
gg.createAndDisplayGO(id_sphere1)
|
||||
gg.setDisplayMode(id_sphere1,1)
|
||||
gg.createAndDisplayGO(id_sphere2)
|
||||
gg.setDisplayMode(id_sphere2,1)
|
||||
gg.createAndDisplayGO(id_sphere3)
|
||||
gg.setDisplayMode(id_sphere3,1)
|
24
doc/salome/examples/primitives_ex04.py
Normal file
24
doc/salome/examples/primitives_ex04.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Creation of a Torus
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(35, 40, 45)
|
||||
p2 = geompy.MakeVertex(35, 45, 70)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create toruses
|
||||
torus1 = geompy.MakeTorus(p1, v, 20, 10)
|
||||
torus2 = geompy.MakeTorusRR(30, 15)
|
||||
|
||||
# add objects in the study
|
||||
id_torus1 = geompy.addToStudy(torus1,"Torus1")
|
||||
id_torus2 = geompy.addToStudy(torus2,"Torus2")
|
||||
|
||||
# display toruses
|
||||
gg.createAndDisplayGO(id_torus1)
|
||||
gg.setDisplayMode(id_torus1,1)
|
||||
gg.createAndDisplayGO(id_torus2)
|
||||
gg.setDisplayMode(id_torus2,1)
|
24
doc/salome/examples/primitives_ex05.py
Normal file
24
doc/salome/examples/primitives_ex05.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Creation of a Cone
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(35, 35, 0)
|
||||
p2 = geompy.MakeVertex(35, 35, 70)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create cones
|
||||
cone1 = geompy.MakeCone(p1, v, 17, 1, 20)
|
||||
cone2 = geompy.MakeConeR1R2H(30, 10, 30)
|
||||
|
||||
# add objects in the study
|
||||
id_cone1 = geompy.addToStudy(cone1,"Cone1")
|
||||
id_cone2 = geompy.addToStudy(cone2,"Cone2")
|
||||
|
||||
# display cones
|
||||
gg.createAndDisplayGO(id_cone1)
|
||||
gg.setDisplayMode(id_cone1,1)
|
||||
gg.createAndDisplayGO(id_cone2)
|
||||
gg.setDisplayMode(id_cone2,1)
|
35
doc/salome/examples/primitives_ex06.py
Normal file
35
doc/salome/examples/primitives_ex06.py
Normal file
@ -0,0 +1,35 @@
|
||||
# Creation of a Disk
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0., 0., 0.)
|
||||
px = geompy.MakeVertex(100., 0. , 0. )
|
||||
py = geompy.MakeVertex(0. , 100., 0. )
|
||||
pz = geompy.MakeVertex(0. , 0. , 100.)
|
||||
|
||||
# create a vector on two points
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create a disk in OXY plane
|
||||
disk1 = geompy.MakeDiskR(100, 1)
|
||||
|
||||
# create a disk from a point, a vector and a radius
|
||||
disk2 = geompy.MakeDiskPntVecR(pz, vxy, 30)
|
||||
|
||||
#create a circle from three points
|
||||
disk3 = geompy.MakeDiskThreePnt(p0, px, py)
|
||||
|
||||
# add objects in the study
|
||||
id_vxy = geompy.addToStudy(vxy, "Vector")
|
||||
id_disk1 = geompy.addToStudy(disk1,"Disk1")
|
||||
id_disk2 = geompy.addToStudy(disk2,"Disk2")
|
||||
id_disk3 = geompy.addToStudy(disk3,"Disk3")
|
||||
|
||||
# display disks
|
||||
gg.createAndDisplayGO(id_vxy)
|
||||
gg.createAndDisplayGO(id_disk1)
|
||||
gg.createAndDisplayGO(id_diks2)
|
||||
gg.createAndDisplayGO(id_diks3)
|
31
doc/salome/examples/primitives_ex07.py
Normal file
31
doc/salome/examples/primitives_ex07.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Creation of a Rectangle
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
px = geompy.MakeVertex(100., 0. , 0. )
|
||||
py = geompy.MakeVertex(0. , 100., 0. )
|
||||
|
||||
# create a vector on two points
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create a rectangle in OXY plane
|
||||
face1 = geompy.MakeFaceHW(100, 100, 1)
|
||||
|
||||
# create a rectangle using normal vector
|
||||
face2 = geompy.MakeFaceObjHW(vxy, 50, 150)
|
||||
|
||||
# create a rectangle from other face
|
||||
face3 = geompy.MakeFaceObjHW(face2, 150, 50)
|
||||
|
||||
# add objects in the study
|
||||
id_face1 = geompy.addToStudy(face1,"Face1")
|
||||
id_face2 = geompy.addToStudy(face2,"Face2")
|
||||
id_face3 = geompy.addToStudy(face3,"Face3")
|
||||
|
||||
# display rectangles
|
||||
gg.createAndDisplayGO(id_face1)
|
||||
gg.createAndDisplayGO(id_face2)
|
||||
gg.createAndDisplayGO(id_face3)
|
46
doc/salome/examples/repairing_operations_ex01.py
Normal file
46
doc/salome/examples/repairing_operations_ex01.py
Normal file
@ -0,0 +1,46 @@
|
||||
# Shape Processing
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices, an edge, an arc, a wire, a face and a prism
|
||||
p1 = geompy.MakeVertex(0,0,0)
|
||||
p2 = geompy.MakeVertex(200,0,0)
|
||||
p3 = geompy.MakeVertex(100,150,0)
|
||||
edge = geompy.MakeEdge(p1,p2)
|
||||
arc = geompy.MakeArc(p1,p3,p2)
|
||||
wire = geompy.MakeWire([edge,arc])
|
||||
face = geompy.MakeFace(wire, 1)
|
||||
theShape = geompy.MakePrismVecH(face, edge, 130)
|
||||
|
||||
# check the shape at the beginning
|
||||
print "Before ProcessShape:"
|
||||
isValid = geompy.CheckShape(theShape)
|
||||
if isValid == 0:
|
||||
print "The shape is not valid"
|
||||
else:
|
||||
print "The shape seems to be valid"
|
||||
|
||||
# process the Shape
|
||||
Operators = ["FixShape"]
|
||||
Parameters = ["FixShape.Tolerance3d"]
|
||||
Values = ["1e-7"]
|
||||
PS = geompy.ProcessShape(theShape, Operators, Parameters, Values)
|
||||
|
||||
# check the shape at the end
|
||||
print "After ProcessShape:"
|
||||
isValid = geompy.CheckShape(PS)
|
||||
if isValid == 0:
|
||||
print "The shape is not valid"
|
||||
raise RuntimeError, "It seems, that the ProcessShape() has failed"
|
||||
else:
|
||||
print "The shape seems to be valid"
|
||||
|
||||
# add in the study and display
|
||||
Id_Shape = geompy.addToStudy(theShape, "Invalid Shape")
|
||||
Id_PS = geompy.addToStudy(PS, "Processed Shape")
|
||||
gg.createAndDisplayGO(Id_Shape)
|
||||
gg.setDisplayMode(Id_Shape,1)
|
||||
gg.createAndDisplayGO(Id_PS)
|
||||
gg.setDisplayMode(Id_PS,1)
|
28
doc/salome/examples/repairing_operations_ex02.py
Normal file
28
doc/salome/examples/repairing_operations_ex02.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Suppress Faces
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
|
||||
# The list of IDs (IDList) for suppress faces
|
||||
sup_faces = []
|
||||
sup_faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"])
|
||||
|
||||
# get indices of the sub-shape
|
||||
f1_id = geompy.GetSubShapeID(box, sup_faces[3])
|
||||
|
||||
# remove faces from the given object (shape)
|
||||
result = geompy.SuppressFaces(box, [f1_id])
|
||||
|
||||
# add objects in the study
|
||||
id_box = geompy.addToStudy(box, "Box")
|
||||
id_result = geompy.addToStudy(result, "Result")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_box)
|
||||
gg.setDisplayMode(id_box,1)
|
||||
gg.createAndDisplayGO(id_result)
|
||||
gg.setDisplayMode(id_result,1)
|
30
doc/salome/examples/repairing_operations_ex03.py
Normal file
30
doc/salome/examples/repairing_operations_ex03.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Close Contour
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices and vectors
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
px = geompy.MakeVertex(100., 0., 0.)
|
||||
py = geompy.MakeVertex( 0., 100., 0.)
|
||||
py1 = geompy.MakeVertex( 0., 140., 0.)
|
||||
pz = geompy.MakeVertex( 0., 0., 100.)
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create an arc
|
||||
arc = geompy.MakeArc(py1, pz, px)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vxy, arc])
|
||||
|
||||
# close an open wire by creation of an edge between ends
|
||||
wire_close = geompy.CloseContour(wire, [1], 0)
|
||||
|
||||
# add objects in the study
|
||||
id_wire = geompy.addToStudy(wire, "Wire")
|
||||
id_wire_close = geompy.addToStudy(wire_close, "Wire close")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_wire)
|
||||
gg.createAndDisplayGO(id_wire_close)
|
34
doc/salome/examples/repairing_operations_ex04.py
Normal file
34
doc/salome/examples/repairing_operations_ex04.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Suppress Internal Wires
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(55, 65, 50)
|
||||
p2 = geompy.MakeVertex(55, 0, 50)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a cylinder
|
||||
height = 100
|
||||
radius1 = 40
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100, 100, 100)
|
||||
|
||||
# make a cut
|
||||
cut = geompy.MakeCut(box, cylinder)
|
||||
|
||||
# suppress all internal wires
|
||||
result = geompy.SuppressInternalWires(cut, [])
|
||||
|
||||
# add objects in the study
|
||||
id_cut = geompy.addToStudy(cut, "Cut")
|
||||
id_result = geompy.addToStudy(result, "Result")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_cut)
|
||||
gg.setDisplayMode(id_cut,1)
|
||||
gg.createAndDisplayGO(id_result)
|
||||
gg.setDisplayMode(id_result,1)
|
50
doc/salome/examples/repairing_operations_ex05.py
Normal file
50
doc/salome/examples/repairing_operations_ex05.py
Normal file
@ -0,0 +1,50 @@
|
||||
# Suppress Holes
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(35, 35, 0)
|
||||
p2 = geompy.MakeVertex(35, 35, 50)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a cylinder
|
||||
height = 20
|
||||
radius1 = 20
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
# create a cone
|
||||
cone = geompy.MakeCone(p1, v, 70, 0, 80)
|
||||
|
||||
# make a cut
|
||||
cut = geompy.MakeCut(cone, cylinder)
|
||||
|
||||
# get faces as sub-shapes
|
||||
faces = []
|
||||
faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
|
||||
f_2 = geompy.GetSubShapeID(cut, faces[2])
|
||||
|
||||
# remove one face from the shape
|
||||
cut_without_f_2 = geompy.SuppressFaces(cut, [f_2])
|
||||
|
||||
# get wires as sub-shapes
|
||||
wires = []
|
||||
wires = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["WIRE"])
|
||||
w_0 = geompy.GetSubShapeID(cut_without_f_2, wires[0])
|
||||
|
||||
# suppress the selected wire
|
||||
result = geompy.SuppressHoles(cut_without_f_2, [w_0])
|
||||
|
||||
# add objects in the study
|
||||
id_cut = geompy.addToStudy(cut, "Cut")
|
||||
id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")
|
||||
id_result = geompy.addToStudy(result, "Result")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_cut)
|
||||
gg.setDisplayMode(id_cut,1)
|
||||
gg.createAndDisplayGO(id_cut_without_f_2)
|
||||
gg.setDisplayMode(id_cut_without_f_2,1)
|
||||
gg.createAndDisplayGO(id_result)
|
||||
gg.setDisplayMode(id_result,1)
|
39
doc/salome/examples/repairing_operations_ex06.py
Normal file
39
doc/salome/examples/repairing_operations_ex06.py
Normal file
@ -0,0 +1,39 @@
|
||||
# Sewing
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
import math
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create base points
|
||||
px = geompy.MakeVertex(100., 0., 0.)
|
||||
py = geompy.MakeVertex(0., 100., 0.)
|
||||
pz = geompy.MakeVertex(0., 0., 100.)
|
||||
|
||||
# create base geometry 2D & 3D
|
||||
vector = geompy.MakeVector(px, py)
|
||||
arc = geompy.MakeArc(py, pz, px)
|
||||
|
||||
# create base objects
|
||||
angle = 45. * math.pi / 180
|
||||
WantPlanarFace = 1 #True
|
||||
wire = geompy.MakeWire([vector, arc])
|
||||
face = geompy.MakeFace(wire, WantPlanarFace)
|
||||
face_rot = geompy.MakeRotation(face, vector, angle)
|
||||
|
||||
# make sewing
|
||||
precision = 0.00001
|
||||
sewing = geompy.MakeSewing([face, face_rot], precision)
|
||||
|
||||
# add objects in the study
|
||||
id_face = geompy.addToStudy(face, "Face")
|
||||
id_face_rot = geompy.addToStudy(face_rot, "Face rotation")
|
||||
id_sewing = geompy.addToStudy(sewing, "Sewing")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_face)
|
||||
gg.setDisplayMode(id_face,1)
|
||||
gg.createAndDisplayGO(id_face_rot)
|
||||
gg.setDisplayMode(id_face_rot,1)
|
||||
gg.createAndDisplayGO(id_sewing)
|
||||
gg.setDisplayMode(id_sewing,1)
|
32
doc/salome/examples/repairing_operations_ex07.py
Normal file
32
doc/salome/examples/repairing_operations_ex07.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Glue Faces
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create boxes
|
||||
box1 = geompy.MakeBox(0,0,0,100,50,100)
|
||||
box2 = geompy.MakeBox(100,0,0,250,50,100)
|
||||
|
||||
# make compound
|
||||
compound = geompy.MakeCompound([box1, box2])
|
||||
|
||||
# glue compound's faces
|
||||
tolerance = 1e-5
|
||||
glue = geompy.MakeGlueFaces(compound, tolerance)
|
||||
|
||||
# add objects in study
|
||||
id_box1 = geompy.addToStudy(box1, "Box1")
|
||||
id_box2 = geompy.addToStudy(box2, "Box2")
|
||||
id_compound = geompy.addToStudy(compound, "Compound")
|
||||
id_glue = geompy.addToStudy(glue, "Glue faces")
|
||||
|
||||
# display results
|
||||
gg.createAndDisplayGO(id_box1)
|
||||
gg.setDisplayMode(id_box1,1)
|
||||
gg.createAndDisplayGO(id_box2)
|
||||
gg.setDisplayMode(id_box2,1)
|
||||
gg.createAndDisplayGO(id_compound)
|
||||
gg.setDisplayMode(id_compound,1)
|
||||
gg.createAndDisplayGO(id_glue)
|
||||
gg.setDisplayMode(id_glue,1)
|
30
doc/salome/examples/repairing_operations_ex08.py
Normal file
30
doc/salome/examples/repairing_operations_ex08.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Glue Edges
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create boxes
|
||||
box1 = geompy.MakeBox(0,0,0,100,50,100)
|
||||
box2 = geompy.MakeBox(100,0,0,250,50,100)
|
||||
|
||||
# make compound
|
||||
compound = geompy.MakeCompound([box1, box2])
|
||||
|
||||
# glue all compound's edges
|
||||
tolerance = 1e-5
|
||||
glue1 = geompy.MakeGlueEdges(compound, tolerance)
|
||||
|
||||
# glue some compound's edges
|
||||
list_edges = geompy.GetGlueEdges(compound, tolerance)
|
||||
glue2 = geompy.MakeGlueEdgesByList(compound, tolerance, [list_edges[0], list_edges[2]])
|
||||
|
||||
# add objects in study
|
||||
geompy.addToStudy(box1, "Box1")
|
||||
geompy.addToStudy(box2, "Box2")
|
||||
geompy.addToStudy(compound, "Compound")
|
||||
geompy.addToStudy(glue1, "Glue all edges")
|
||||
geompy.addToStudy(glue2, "Glue two edges")
|
||||
|
||||
if salome.sg.hasDesktop():
|
||||
salome.sg.updateObjBrowser(1)
|
33
doc/salome/examples/repairing_operations_ex09.py
Normal file
33
doc/salome/examples/repairing_operations_ex09.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Limit Tolerance
|
||||
|
||||
import geompy
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# import initial topology
|
||||
shape1 = geompy.ImportBREP("my_shape_1.brep")
|
||||
shape2 = geompy.ImportBREP("my_shape_2.brep")
|
||||
|
||||
geompy.addToStudy(shape1, "Shape 1")
|
||||
geompy.addToStudy(shape2, "Shape 2")
|
||||
|
||||
# perform partition
|
||||
try:
|
||||
part = geompy.MakePartition([shape1, shape2])
|
||||
except:
|
||||
# limit tolerance
|
||||
tolerance = 1e-07
|
||||
shape1_lt = geompy.LimitTolerance(shape1, tolerance)
|
||||
shape2_lt = geompy.LimitTolerance(shape2, tolerance)
|
||||
|
||||
# process shape
|
||||
good_shape1 = geompy.ProcessShape(shape1_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"])
|
||||
good_shape2 = geompy.ProcessShape(shape2_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"])
|
||||
|
||||
geompy.addToStudy(good_shape1, "Shape 1 corrected")
|
||||
geompy.addToStudy(good_shape2, "Shape 2 corrected")
|
||||
|
||||
# perform partition on corrected shapes
|
||||
part = geompy.MakePartition([good_shape1, good_shape2])
|
||||
pass
|
||||
|
||||
geompy.addToStudy(part, "Partition")
|
27
doc/salome/examples/repairing_operations_ex10.py
Normal file
27
doc/salome/examples/repairing_operations_ex10.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Add Point on Edge
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
|
||||
# create vertices
|
||||
p1 = geompy.MakeVertex(0,0,50)
|
||||
p2 = geompy.MakeVertex(60,0,50)
|
||||
|
||||
# make an edge
|
||||
edge = geompy.MakeEdge(p1, p2) #geompy.GetSubShape(box, edge_ind)
|
||||
|
||||
# divide an edge
|
||||
divide = geompy.DivideEdge(edge, -1, 0.5, 0)
|
||||
|
||||
# add objects in the study
|
||||
id_edge = geompy.addToStudy(edge, "Edge")
|
||||
edge_points = geompy.SubShapeAllSortedCentres(edge, geompy.ShapeType["VERTEX"])
|
||||
for point in edge_points:
|
||||
geompy.addToStudyInFather(edge, point, "Edge's point")
|
||||
|
||||
id_divide = geompy.addToStudy(divide, "Divided edge")
|
||||
edge_points = geompy.SubShapeAllSortedCentres(divide, geompy.ShapeType["VERTEX"])
|
||||
for point in edge_points:
|
||||
geompy.addToStudyInFather(divide, point, "Edge's point after divide")
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
49
doc/salome/examples/repairing_operations_ex11.py
Normal file
49
doc/salome/examples/repairing_operations_ex11.py
Normal file
@ -0,0 +1,49 @@
|
||||
# Fuse Collinear Edges within a Wire
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
|
||||
# create vertices
|
||||
p1 = geompy.MakeVertex(0, 0, 0)
|
||||
p2 = geompy.MakeVertex(70, 0, 0)
|
||||
p3 = geompy.MakeVertex(70, 50, 0)
|
||||
p4 = geompy.MakeVertex(70, 80, 0)
|
||||
p5 = geompy.MakeVertex(50, 80, 0)
|
||||
p6 = geompy.MakeVertex(20, 80, 0)
|
||||
p7 = geompy.MakeVertex(0, 80, 0)
|
||||
p8 = geompy.MakeVertex(0, 30, 0)
|
||||
|
||||
points = [p1, p2, p3, p4, p5, p6, p7, p8]
|
||||
|
||||
# make a wire
|
||||
wire_1 = geompy.MakePolyline(points, True)
|
||||
|
||||
# suppress some vertices in the wire
|
||||
wire_2 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p3])
|
||||
wire_3 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p5, p6])
|
||||
|
||||
# suppress all suitable vertices in the wire
|
||||
wire_4 = geompy.FuseCollinearEdgesWithinWire(wire_1, [])
|
||||
|
||||
wires = [wire_1, wire_2, wire_3, wire_4]
|
||||
|
||||
# add objects in the study
|
||||
ii = 1
|
||||
for point in points:
|
||||
geompy.addToStudy(point, "p%d"%ii)
|
||||
ii = ii + 1
|
||||
pass
|
||||
|
||||
ii = 1
|
||||
for wire in wires:
|
||||
geompy.addToStudy(wire, "wire_%d"%ii)
|
||||
wire_points = geompy.SubShapeAllSortedCentres(wire, geompy.ShapeType["VERTEX"])
|
||||
jj = 1
|
||||
for point in wire_points:
|
||||
geompy.addToStudyInFather(wire, point, "point_%d"%jj)
|
||||
jj = jj + 1
|
||||
pass
|
||||
ii = ii + 1
|
||||
pass
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
42
doc/salome/examples/sketcher.py
Normal file
42
doc/salome/examples/sketcher.py
Normal file
@ -0,0 +1,42 @@
|
||||
# 2D Sketcher
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p1 = geompy.MakeVertex(70., 0., 0.)
|
||||
p2 = geompy.MakeVertex(70., 70., 80.)
|
||||
p3 = geompy.MakeVertex( 0., 70., 0.)
|
||||
|
||||
#create a vector from two points
|
||||
vector_arc = geompy.MakeVector(p1, p3)
|
||||
|
||||
# create an arc from three points
|
||||
arc = geompy.MakeArc(p1, p2, p3)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vector_arc, arc])
|
||||
|
||||
# create a planar face
|
||||
isPlanarWanted = 1
|
||||
face = geompy.MakeFace(wire, isPlanarWanted)
|
||||
|
||||
# create a sketcher (face), following the textual description
|
||||
sketcher1 = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WF",
|
||||
[100,0,0, 1,1,1, -1,1,0])
|
||||
|
||||
# create a sketcher (wire) on the given face
|
||||
sketcher2 = geompy.MakeSketcherOnPlane("Sketcher:F 10 -30:R 10:C 20 180:R 15:L 50:WW", face)
|
||||
|
||||
# add objects in the study
|
||||
id_face = geompy.addToStudy(face,"Face")
|
||||
id_sketcher1 = geompy.addToStudy(sketcher1,"Sketcher1")
|
||||
id_sketcher2 = geompy.addToStudy(sketcher2,"Sketcher2")
|
||||
|
||||
# display the first sketcher and the second sketcher with its planar face
|
||||
gg.createAndDisplayGO(id_face)
|
||||
gg.setDisplayMode(id_face,1)
|
||||
gg.setTransparency(id_face,0.5)
|
||||
gg.createAndDisplayGO(id_sketcher1)
|
||||
gg.createAndDisplayGO(id_sketcher2)
|
28
doc/salome/examples/testme.py
Executable file
28
doc/salome/examples/testme.py
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import unittest, sys
|
||||
|
||||
class SalomeSession(object):
|
||||
def __init__(self, script):
|
||||
import runSalome
|
||||
sys.argv = ["runSalome.py"]
|
||||
sys.argv += ["--terminal"]
|
||||
sys.argv += ["--modules=GEOM"]
|
||||
sys.argv += ["--execute=%s" % script]
|
||||
clt, d = runSalome.main()
|
||||
self.port = d['port']
|
||||
return
|
||||
|
||||
def __del__(self):
|
||||
port = self.port
|
||||
import killSalomeWithPort
|
||||
killSalomeWithPort.killMyPort(port)
|
||||
return
|
||||
pass
|
||||
|
||||
class MyTest(unittest.TestCase):
|
||||
def testFunction(self):
|
||||
SalomeSession(sys.argv[1])
|
||||
pass
|
||||
|
||||
unittest.main(argv=sys.argv[:1])
|
14
doc/salome/examples/tolerance.py
Normal file
14
doc/salome/examples/tolerance.py
Normal file
@ -0,0 +1,14 @@
|
||||
# Tolerance
|
||||
|
||||
import geompy
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
Toler = geompy.Tolerance(box)
|
||||
print "\nBox 100x30x100 tolerance:"
|
||||
print " Face min. tolerance: ", Toler[0]
|
||||
print " Face max. tolerance: ", Toler[1]
|
||||
print " Edge min. tolerance: ", Toler[2]
|
||||
print " Edge max. tolerance: ", Toler[3]
|
||||
print " Vertex min. tolerance: ", Toler[4]
|
||||
print " Vertex max. tolerance: ", Toler[5]
|
57
doc/salome/examples/topological_geom_objs_ex01.py
Normal file
57
doc/salome/examples/topological_geom_objs_ex01.py
Normal file
@ -0,0 +1,57 @@
|
||||
# Creation of an Edge
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
#
|
||||
# create edge by two points
|
||||
#
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0. , 0. , 0. )
|
||||
pxyz = geompy.MakeVertex(100., 100., 100.)
|
||||
|
||||
# create an edge
|
||||
edge = geompy.MakeEdge(p0, pxyz)
|
||||
|
||||
# add object in the study
|
||||
id_edge = geompy.addToStudy(edge,"Edge_1")
|
||||
|
||||
# display an edge
|
||||
gg.createAndDisplayGO(id_edge)
|
||||
|
||||
#
|
||||
# create edge from wire
|
||||
#
|
||||
|
||||
# create a circle
|
||||
c = geompy.MakeCircle(None, None, 100)
|
||||
|
||||
# create a wire
|
||||
w = geompy.MakeWire([c], 1e-07)
|
||||
|
||||
# create an edge from wire
|
||||
edge = geompy.MakeEdgeWire(w)
|
||||
|
||||
# add object in the study
|
||||
id_edge = geompy.addToStudy(edge,"Edge_2")
|
||||
|
||||
# display an edge
|
||||
gg.createAndDisplayGO(id_edge)
|
||||
|
||||
#
|
||||
# create edge from existing curve and a length
|
||||
#
|
||||
|
||||
# create a circle
|
||||
c = geompy.MakeCircle(None, None, 100)
|
||||
|
||||
# create an edge of length 25.0 from the circle
|
||||
edge = geompy.MakeEdgeOnCurveByLength(c, 25.0)
|
||||
|
||||
# add object in the study
|
||||
id_edge = geompy.addToStudy(edge,"Edge_3")
|
||||
|
||||
# display an edge
|
||||
gg.createAndDisplayGO(id_edge)
|
25
doc/salome/examples/topological_geom_objs_ex02.py
Normal file
25
doc/salome/examples/topological_geom_objs_ex02.py
Normal file
@ -0,0 +1,25 @@
|
||||
# Creation of a Wire
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
px = geompy.MakeVertex(100., 0. , 0. )
|
||||
py = geompy.MakeVertex(0. , 100., 0. )
|
||||
pz = geompy.MakeVertex(0. , 0. , 100.)
|
||||
|
||||
# create a vector from two points
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create an arc from three points
|
||||
arc = geompy.MakeArc(py, pz, px)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vxy, arc])
|
||||
|
||||
# add an object in the study
|
||||
id_wire = geompy.addToStudy(wire,"Wire")
|
||||
|
||||
# display the wire
|
||||
gg.createAndDisplayGO(id_wire)
|
51
doc/salome/examples/topological_geom_objs_ex03.py
Normal file
51
doc/salome/examples/topological_geom_objs_ex03.py
Normal file
@ -0,0 +1,51 @@
|
||||
# Creation of a Face
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices
|
||||
p0 = geompy.MakeVertex(0. , 0. , 0. )
|
||||
px = geompy.MakeVertex(100., 0. , 0. )
|
||||
py = geompy.MakeVertex(0. , 100., 0. )
|
||||
pz = geompy.MakeVertex(0. , 0. , 100.)
|
||||
pxyz = geompy.MakeVertex(100., 100., 100.)
|
||||
|
||||
# create a vector from two points
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create an arc from three points
|
||||
arc = geompy.MakeArc(py, pz, px)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vxy, arc])
|
||||
|
||||
# create sketchers
|
||||
sketcher1 = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW",
|
||||
[100,0,0, 1,1,1, -1,1,0])
|
||||
sketcher2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
|
||||
sketcher3 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
|
||||
isPlanarFace = 1
|
||||
|
||||
# create a face from the wire
|
||||
face1 = geompy.MakeFace(wire, isPlanarFace)
|
||||
|
||||
# create faces from two wires
|
||||
face2 = geompy.MakeFaceWires([wire, sketcher1],isPlanarFace)
|
||||
face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace)
|
||||
|
||||
# add objects in the study
|
||||
id_face1 = geompy.addToStudy(face1,"Face1")
|
||||
id_face2 = geompy.addToStudy(face2,"Face2")
|
||||
id_face3 = geompy.addToStudy(face3,"Face3")
|
||||
|
||||
# display the faces
|
||||
gg.createAndDisplayGO(id_face1)
|
||||
gg.setDisplayMode(id_face1,1)
|
||||
gg.setTransparency(id_face1,0.2)
|
||||
gg.createAndDisplayGO(id_face2)
|
||||
gg.setDisplayMode(id_face2,1)
|
||||
gg.setTransparency(id_face2,0.2)
|
||||
gg.createAndDisplayGO(id_face3)
|
||||
gg.setDisplayMode(id_face3,1)
|
||||
gg.setTransparency(id_face3,0.2)
|
34
doc/salome/examples/topological_geom_objs_ex04.py
Normal file
34
doc/salome/examples/topological_geom_objs_ex04.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Creation of a Shell
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
#create vertices
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
pxyz = geompy.MakeVertex( 5., 5., 40.)
|
||||
|
||||
# create sketchers
|
||||
sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
|
||||
sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
|
||||
isPlanarFace = 1
|
||||
|
||||
# create a face from two wires
|
||||
face = geompy.MakeFaces([sketcher1, sketcher2],isPlanarFace)
|
||||
|
||||
# create a prism
|
||||
prism = geompy.MakePrism(face, p0, pxyz)
|
||||
|
||||
# explode the prism into faces
|
||||
prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"])
|
||||
|
||||
# create a shell from a set of faces
|
||||
shell = geompy.MakeShell([prism_faces[0], prism_faces[2], prism_faces[3],
|
||||
prism_faces[7], prism_faces[9]])
|
||||
|
||||
# add objects in the study
|
||||
id_shell = geompy.addToStudy(shell,"Shell")
|
||||
|
||||
# display the shell
|
||||
gg.createAndDisplayGO(id_shell)
|
||||
gg.setDisplayMode(id_shell,1)
|
36
doc/salome/examples/topological_geom_objs_ex05.py
Normal file
36
doc/salome/examples/topological_geom_objs_ex05.py
Normal file
@ -0,0 +1,36 @@
|
||||
# Creation of a Solid
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
#create vertices
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
pz = geompy.MakeVertex( 0., 0., 40.)
|
||||
|
||||
# create sketchers
|
||||
sketcher = geompy.MakeSketcher("Sketcher:F -50 -50:TT 100 -50:R 0:C 50 70:R 0:L 100:WW")
|
||||
|
||||
# create faces from two wires
|
||||
face = geompy.MakeFace(sketcher,1)
|
||||
|
||||
# create a prism
|
||||
prism = geompy.MakePrism(face, p0, pz)
|
||||
|
||||
# explode the prism into faces
|
||||
prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"])
|
||||
|
||||
# create a shell from a set of faces
|
||||
shell = geompy.MakeShell([prism_faces[0], prism_faces[1],
|
||||
prism_faces[3], prism_faces[4],
|
||||
prism_faces[5], prism_faces[2]])
|
||||
|
||||
# create a solid, bounded by the given shells
|
||||
solid = geompy.MakeSolid([shell])
|
||||
|
||||
# add objects in the study
|
||||
id_solid = geompy.addToStudy(solid,"Solid")
|
||||
|
||||
# display the solid
|
||||
gg.createAndDisplayGO(id_solid)
|
||||
gg.setDisplayMode(id_solid,1)
|
28
doc/salome/examples/topological_geom_objs_ex06.py
Normal file
28
doc/salome/examples/topological_geom_objs_ex06.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Creation of a Compound
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex( -30., -30., 50.)
|
||||
p2 = geompy.MakeVertex( -60., -60., 30.)
|
||||
p3 = geompy.MakeVertex( -30., -30., 10.)
|
||||
|
||||
# create an arc from three points
|
||||
arc = geompy.MakeArc(p1, p2, p3)
|
||||
ShapeListCompound = []
|
||||
i = 0
|
||||
while i <= 3 :
|
||||
S = geompy.MakeTranslation(arc, i * 50., 0., 0.)
|
||||
ShapeListCompound.append(S)
|
||||
i = i + 1
|
||||
|
||||
# create a compund of the given shapes
|
||||
compound = geompy.MakeCompound(ShapeListCompound)
|
||||
|
||||
# add object in the study
|
||||
id_compound = geompy.addToStudy(compound,"Compound")
|
||||
|
||||
# display the compound
|
||||
gg.createAndDisplayGO(id_compound)
|
43
doc/salome/examples/transformation_operations_ex01.py
Normal file
43
doc/salome/examples/transformation_operations_ex01.py
Normal file
@ -0,0 +1,43 @@
|
||||
# Translation
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(10, 40, 0)
|
||||
p2 = geompy.MakeVertex( 0, 0, 50)
|
||||
p3 = geompy.MakeVertex(50, 80, 0)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
vt = geompy.MakeVector(p1, p3)
|
||||
|
||||
# create a cylinder
|
||||
height = 35
|
||||
radius1 = 20
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
# translate the given object along the vector, specified by its end points
|
||||
# (all three functions produce the same result)
|
||||
translation1 = geompy.MakeTranslationTwoPoints(cylinder, p1, p3)
|
||||
translation2 = geompy.MakeTranslation(cylinder, 40, 40, 0)
|
||||
translation3 = geompy.MakeTranslationVector(cylinder, vt)
|
||||
translation4 = geompy.MakeTranslationVectorDistance(cylinder, vt, 200)
|
||||
|
||||
# add objects in the study
|
||||
id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
|
||||
id_translation1 = geompy.addToStudy(translation1, "Translation1")
|
||||
id_translation2 = geompy.addToStudy(translation2, "Translation2")
|
||||
id_translation3 = geompy.addToStudy(translation3, "Translation3")
|
||||
id_translation4 = geompy.addToStudy(translation4, "Translation4")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_cylinder)
|
||||
gg.setDisplayMode(id_cylinder,1)
|
||||
gg.createAndDisplayGO(id_translation1)
|
||||
gg.setDisplayMode(id_translation1,1)
|
||||
gg.createAndDisplayGO(id_translation2)
|
||||
gg.setDisplayMode(id_translation2,1)
|
||||
gg.createAndDisplayGO(id_translation3)
|
||||
gg.setDisplayMode(id_translation3,1)
|
||||
gg.createAndDisplayGO(id_translation4)
|
||||
gg.setDisplayMode(id_translation4,1)
|
44
doc/salome/examples/transformation_operations_ex02.py
Normal file
44
doc/salome/examples/transformation_operations_ex02.py
Normal file
@ -0,0 +1,44 @@
|
||||
# Rotation
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
import math
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(10, 40, 0)
|
||||
p2 = geompy.MakeVertex( 0, 0, 50)
|
||||
p3 = geompy.MakeVertex(10, 50,-20)
|
||||
p4 = geompy.MakeVertex(10, 50, 60)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
vr = geompy.MakeVector(p3, p4)
|
||||
|
||||
# create a cylinder
|
||||
height = 35
|
||||
radius1 = 20
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
|
||||
# rotate the given object around the given axis by the given angle
|
||||
rotation1 = geompy.MakeRotation(cylinder, vr, math.pi)
|
||||
rotation2 = geompy.MakeRotationThreePoints(cylinder, p4, p1, p2)
|
||||
|
||||
# add objects in the study
|
||||
id_vr = geompy.addToStudy(vr, "Rotation 1 axis")
|
||||
id_p4 = geompy.addToStudy(p4, "Rotation 2 center")
|
||||
id_p1 = geompy.addToStudy(p1, "Rotation 2 point 1")
|
||||
id_p2 = geompy.addToStudy(p2, "Rotation 2 point 2")
|
||||
id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
|
||||
id_rotation1 = geompy.addToStudy(rotation1, "Rotation 1")
|
||||
id_rotation2 = geompy.addToStudy(rotation2, "Rotation 2")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_vr)
|
||||
gg.createAndDisplayGO(id_p4)
|
||||
gg.createAndDisplayGO(id_p1)
|
||||
gg.createAndDisplayGO(id_p2)
|
||||
gg.createAndDisplayGO(id_cylinder)
|
||||
gg.setDisplayMode(id_cylinder,1)
|
||||
gg.createAndDisplayGO(id_rotation1)
|
||||
gg.createAndDisplayGO(id_rotation2)
|
||||
gg.setDisplayMode(id_rotation1,1)
|
||||
gg.setDisplayMode(id_rotation2,1)
|
43
doc/salome/examples/transformation_operations_ex03.py
Normal file
43
doc/salome/examples/transformation_operations_ex03.py
Normal file
@ -0,0 +1,43 @@
|
||||
# Modify Location
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
import math
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a vertex and a vector
|
||||
p1 = geompy.MakeVertex(10, 40, 0)
|
||||
p2 = geompy.MakeVertex( 0, 0, 50)
|
||||
v = geompy.MakeVector(p1, p2)
|
||||
|
||||
# create a cylinder
|
||||
height = 35
|
||||
radius1 = 20
|
||||
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
|
||||
circle = geompy.MakeCircle(p2, v, radius1)
|
||||
|
||||
# create local coordinate systems
|
||||
cs1 = geompy.MakeMarker( 0, 0, 0, 1,0,0, 0,1,0)
|
||||
cs2 = geompy.MakeMarker(30,40,40, 1,0,0, 0,1,0)
|
||||
|
||||
# modify the location of the given object
|
||||
position = geompy.MakePosition(cylinder, cs1, cs2)
|
||||
position2 = geompy.PositionAlongPath(position, circle, 0.75, 1, 1)
|
||||
|
||||
# add objects in the study
|
||||
id_cs1 = geompy.addToStudy(cs1, "Coordinate system 1")
|
||||
id_cs2 = geompy.addToStudy(cs2, "Coordinate system 2")
|
||||
id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
|
||||
id_circle = geompy.addToStudy(circle, "Circle")
|
||||
id_position = geompy.addToStudy(position, "Position")
|
||||
id_position2 = geompy.addToStudy(position2, "PositionAlongPath")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_cylinder)
|
||||
gg.setDisplayMode(id_cylinder,1)
|
||||
gg.createAndDisplayGO(id_position)
|
||||
gg.setDisplayMode(id_position,1)
|
||||
gg.createAndDisplayGO(id_circle)
|
||||
gg.setDisplayMode(id_circle,1)
|
||||
gg.createAndDisplayGO(id_position2)
|
||||
gg.setDisplayMode(id_position2,1)
|
46
doc/salome/examples/transformation_operations_ex04.py
Normal file
46
doc/salome/examples/transformation_operations_ex04.py
Normal file
@ -0,0 +1,46 @@
|
||||
# Mirror Image
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
|
||||
# create an object, symmetrical to another object through the given plane
|
||||
p1 = geompy.MakeVertex( 0, 25, 0)
|
||||
p2 = geompy.MakeVertex( 5, 25, 0)
|
||||
p3 = geompy.MakeVertex( 0,-30, 40)
|
||||
plane = geompy.MakePlaneThreePnt(p1, p2, p3, 1000.)
|
||||
mirror1 = geompy.MakeMirrorByPlane(box, plane)
|
||||
|
||||
# create an object, symmetrical to another object through the given axis
|
||||
p4 = geompy.MakeVertex( 210, 210, -20)
|
||||
p5 = geompy.MakeVertex( 210, 210, 220)
|
||||
axis = geompy.MakeVector(p4, p5)
|
||||
mirror2 = geompy.MakeMirrorByAxis(box, axis)
|
||||
|
||||
# create an object, symmetrical to another object through the given point
|
||||
mirror3 = geompy.MakeMirrorByPoint(box, p4)
|
||||
|
||||
# add objects in the study
|
||||
id_box = geompy.addToStudy(box, "Box")
|
||||
id_plane = geompy.addToStudy(plane, "Plane")
|
||||
id_mirror1 = geompy.addToStudy(mirror1, "Mirror plane")
|
||||
id_axis = geompy.addToStudy(axis, "Axis")
|
||||
id_mirror2 = geompy.addToStudy(mirror2, "Mirror axis")
|
||||
id_p4 = geompy.addToStudy(p4, "Point")
|
||||
id_mirror3 = geompy.addToStudy(mirror3, "Mirror point")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_box)
|
||||
gg.setDisplayMode(id_box,1)
|
||||
gg.createAndDisplayGO(id_plane)
|
||||
gg.createAndDisplayGO(id_mirror1)
|
||||
gg.setDisplayMode(id_mirror1,1)
|
||||
gg.createAndDisplayGO(id_axis)
|
||||
gg.createAndDisplayGO(id_mirror2)
|
||||
gg.setDisplayMode(id_mirror2,1)
|
||||
gg.createAndDisplayGO(id_p4)
|
||||
gg.createAndDisplayGO(id_mirror3)
|
||||
gg.setDisplayMode(id_mirror3,1)
|
24
doc/salome/examples/transformation_operations_ex05.py
Normal file
24
doc/salome/examples/transformation_operations_ex05.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Scale Transform
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a box and a sphere
|
||||
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
|
||||
# scale the given object by the factor
|
||||
p0 = geompy.MakeVertex(100, 100, 100)
|
||||
factor = 0.5
|
||||
scale = geompy.MakeScaleTransform(box, p0, factor)
|
||||
|
||||
# add objects in the study
|
||||
id_box = geompy.addToStudy(box, "Box")
|
||||
id_scale = geompy.addToStudy(scale, "Scale")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_box)
|
||||
gg.setDisplayMode(id_box,1)
|
||||
gg.setTransparency(id_box,0.5)
|
||||
gg.createAndDisplayGO(id_scale)
|
||||
gg.setDisplayMode(id_scale,1)
|
20
doc/salome/examples/transformation_operations_ex06.py
Normal file
20
doc/salome/examples/transformation_operations_ex06.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Offset Surface
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a box and a sphere
|
||||
box = geompy.MakeBox(20, 20, 20, 200, 200, 200)
|
||||
|
||||
# create a new object as offset of the given object
|
||||
offset = geompy.MakeOffset(box, 70.)
|
||||
|
||||
# add objects in the study
|
||||
id_box = geompy.addToStudy(box, "Box")
|
||||
id_offset = geompy.addToStudy(offset, "Offset")
|
||||
|
||||
# display the results
|
||||
gg.createAndDisplayGO(id_box)
|
||||
gg.setDisplayMode(id_box,1)
|
||||
gg.createAndDisplayGO(id_offset)
|
31
doc/salome/examples/transformation_operations_ex07.py
Normal file
31
doc/salome/examples/transformation_operations_ex07.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Projection
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
|
||||
# create a cylindric face and a curve(edge)
|
||||
cylinder = geompy.MakeCylinderRH(100, 300)
|
||||
[face_cyl] = geompy.SubShapes(cylinder, [3])
|
||||
|
||||
p1 = geompy.MakeVertex(200, 0, 100)
|
||||
p2 = geompy.MakeVertex(200, 80, 100)
|
||||
p3 = geompy.MakeVertex(200, 80, 180)
|
||||
p4 = geompy.MakeVertex(130, 80, 180)
|
||||
p5 = geompy.MakeVertex(90, 80, 240)
|
||||
|
||||
curve = geompy.MakeInterpol([p1, p2, p3, p4, p5], False, False)
|
||||
|
||||
# create a new object as projection of the
|
||||
# given curve on the given cylindric face
|
||||
projection = geompy.MakeProjection(curve, face_cyl)
|
||||
|
||||
# add objects in the study
|
||||
geompy.addToStudy(cylinder, "cylinder")
|
||||
geompy.addToStudyInFather(cylinder, face_cyl, "face_cyl")
|
||||
geompy.addToStudy(p1, "p1")
|
||||
geompy.addToStudy(p2, "p2")
|
||||
geompy.addToStudy(p3, "p3")
|
||||
geompy.addToStudy(p4, "p4")
|
||||
geompy.addToStudy(p5, "p5")
|
||||
geompy.addToStudy(curve, "curve")
|
||||
geompy.addToStudy(projection, "projection")
|
48
doc/salome/examples/transformation_operations_ex08.py
Normal file
48
doc/salome/examples/transformation_operations_ex08.py
Normal file
@ -0,0 +1,48 @@
|
||||
# Multi Translation
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create vertices and vectors
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
px = geompy.MakeVertex(20., 0., 0.)
|
||||
py = geompy.MakeVertex( 0., 20., 0.)
|
||||
pz = geompy.MakeVertex( 0., 0., 20.)
|
||||
pxy = geompy.MakeVertex( 50., 0., 0.)
|
||||
pxyz = geompy.MakeVertex( 50., 50., 50.)
|
||||
vz = geompy.MakeVector(p0, pz)
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
vtr1d = geompy.MakeVector(p0, pxyz)
|
||||
vtr2d = geompy.MakeVector(p0, pxy)
|
||||
|
||||
# create an arc
|
||||
arc = geompy.MakeArc(py, pz, px)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vxy, arc])
|
||||
|
||||
# create a planar face
|
||||
face = geompy.MakeFace(wire, 1)
|
||||
|
||||
# create a prism
|
||||
prism = geompy.MakePrismVecH(face, vz, 20.0)
|
||||
|
||||
# translate the given object along the given vector a given number of times
|
||||
tr1d = geompy.MakeMultiTranslation1D(prism, vtr1d, 20, 4)
|
||||
|
||||
# consequently apply two specified translations to the object a given number of times
|
||||
tr2d = geompy.MakeMultiTranslation2D(prism, vtr1d, 20, 4, vtr2d, 80, 3)
|
||||
|
||||
# add objects in the study
|
||||
id_prism = geompy.addToStudy(prism,"Prism")
|
||||
id_tr1d = geompy.addToStudy(tr1d,"Translation 1D")
|
||||
id_tr2d = geompy.addToStudy(tr2d,"Translation 2D")
|
||||
|
||||
# display the prism and the results of fillet operation
|
||||
gg.createAndDisplayGO(id_prism)
|
||||
gg.setDisplayMode(id_prism,1)
|
||||
gg.createAndDisplayGO(id_tr1d)
|
||||
gg.setDisplayMode(id_tr1d,1)
|
||||
gg.createAndDisplayGO(id_tr2d)
|
||||
gg.setDisplayMode(id_tr2d,1)
|
64
doc/salome/examples/transformation_operations_ex09.py
Normal file
64
doc/salome/examples/transformation_operations_ex09.py
Normal file
@ -0,0 +1,64 @@
|
||||
# Multi Rotation
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
import math
|
||||
|
||||
# create vertices and vectors
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
px = geompy.MakeVertex(20., 0., 0.)
|
||||
py = geompy.MakeVertex( 0., 20., 0.)
|
||||
pz = geompy.MakeVertex( 0., 0., 20.)
|
||||
pxyz = geompy.MakeVertex( 50., 50., 10.)
|
||||
vz = geompy.MakeVector(p0, pz)
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
vrot = geompy.MakeVector(p0, pxyz)
|
||||
|
||||
# create an arc
|
||||
arc = geompy.MakeArc(py, pz, px)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vxy, arc])
|
||||
|
||||
# create a planar face
|
||||
face = geompy.MakeFace(wire, 1)
|
||||
|
||||
# create a prism
|
||||
prism = geompy.MakePrismVecH(face, vz, 20.0)
|
||||
|
||||
# 1. Rotate the prism around the axis vrot 4 times
|
||||
|
||||
# rotation angle = 2 * PI / 4
|
||||
rot1da = geompy.MultiRotate1DNbTimes(prism, vrot, 4)
|
||||
|
||||
# by the given angle of 30 degrees
|
||||
rot1db = geompy.MultiRotate1DByStep(prism, vrot, math.pi/6., 4)
|
||||
|
||||
# 2. Rotate the prism around the axis vrot 4 times
|
||||
# and translate the result of each rotation 5 times on distance 50
|
||||
|
||||
# rotation angle = 2 * PI / 4
|
||||
rot2da = geompy.MultiRotate2DNbTimes(prism, vrot, 4, 50, 5)
|
||||
|
||||
# by the given angle of 60 degrees
|
||||
rot2db = geompy.MultiRotate2DByStep(prism, vrot, math.pi/3., 4, 50, 5)
|
||||
|
||||
# add objects in the study
|
||||
id_prism = geompy.addToStudy(prism,"Prism")
|
||||
id_rot1da = geompy.addToStudy(rot1da,"Rotation 1D Nb.Times")
|
||||
id_rot1db = geompy.addToStudy(rot1db,"Rotation 1D By Step")
|
||||
id_rot2da = geompy.addToStudy(rot2da,"Rotation 2D Nb.Times")
|
||||
id_rot2db = geompy.addToStudy(rot2db,"Rotation 2D By Step")
|
||||
|
||||
# display the prism and the results of fillet operation
|
||||
gg.createAndDisplayGO(id_prism)
|
||||
gg.setDisplayMode(id_prism,1)
|
||||
gg.createAndDisplayGO(id_rot1da)
|
||||
gg.setDisplayMode(id_rot1da,1)
|
||||
gg.createAndDisplayGO(id_rot1db)
|
||||
gg.setDisplayMode(id_rot1db,1)
|
||||
gg.createAndDisplayGO(id_rot2da)
|
||||
gg.setDisplayMode(id_rot2da,1)
|
||||
gg.createAndDisplayGO(id_rot2db)
|
||||
gg.setDisplayMode(id_rot2db,1)
|
17
doc/salome/examples/transformation_operations_ex10.py
Normal file
17
doc/salome/examples/transformation_operations_ex10.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Fillet 2D
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create a face in OXY plane
|
||||
face = geompy.MakeFaceHW(100, 100, 1)
|
||||
fillet2d = geompy.MakeFillet2D(face, 30, [7, 9])
|
||||
|
||||
# add objects in the study
|
||||
id_face = geompy.addToStudy(face,"Face_1")
|
||||
id_fillet2d = geompy.addToStudy(fillet2d,"Fillet 2D_1")
|
||||
|
||||
# display disks
|
||||
gg.createAndDisplayGO(id_face)
|
||||
gg.createAndDisplayGO(id_fillet2d)
|
19
doc/salome/examples/transformation_operations_ex11.py
Normal file
19
doc/salome/examples/transformation_operations_ex11.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Fillet 1D
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
|
||||
# create box
|
||||
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
# take box edges to create custom complex wire
|
||||
[Edge_1,Edge_2,Edge_3,Edge_4,Edge_5,Edge_6,Edge_7,Edge_8,Edge_9,Edge_10,Edge_11,Edge_12] = geompy.SubShapeAllSortedCentres(Box_1, geompy.ShapeType["EDGE"])
|
||||
# create wire
|
||||
Wire_1 = geompy.MakeWire([Edge_12, Edge_7, Edge_11, Edge_6, Edge_1,Edge_4])
|
||||
# make fillet at given wire vertices with giver radius
|
||||
Fillet_1D_1 = geompy.MakeFillet1D(Wire_1, 55, [3, 4, 6, 8, 10])
|
||||
|
||||
|
||||
# display disks
|
||||
gg.createAndDisplayGO(Wire_1)
|
||||
gg.createAndDisplayGO(Fillet_1D_1)
|
53
doc/salome/examples/transformation_operations_ex12.py
Normal file
53
doc/salome/examples/transformation_operations_ex12.py
Normal file
@ -0,0 +1,53 @@
|
||||
# Fillet
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
radius = 10.
|
||||
ShapeTypeEdge = geompy.ShapeType["EDGE"]
|
||||
|
||||
# create vertices and vectors
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
px = geompy.MakeVertex(100., 0., 0.)
|
||||
py = geompy.MakeVertex( 0., 100., 0.)
|
||||
pz = geompy.MakeVertex( 0., 0., 100.)
|
||||
vz = geompy.MakeVector(p0, pz)
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create an arc
|
||||
arc = geompy.MakeArc(py, pz, px)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vxy, arc])
|
||||
|
||||
# create a planar face
|
||||
face = geompy.MakeFace(wire, 1)
|
||||
|
||||
# create a prism
|
||||
prism = geompy.MakePrismVecH(face, vz, 100.0)
|
||||
|
||||
# get the list of IDs (IDList) for the fillet
|
||||
prism_edges = geompy.SubShapeAllSortedCentres(prism, ShapeTypeEdge)
|
||||
IDlist_e = []
|
||||
IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[0]))
|
||||
IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[1]))
|
||||
IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[2]))
|
||||
|
||||
# make a fillet on the specified edges of the given shape
|
||||
fillet = geompy.MakeFillet(prism, radius, ShapeTypeEdge, IDlist_e)
|
||||
|
||||
# make a fillet on all edges of the given shape
|
||||
filletall = geompy.MakeFilletAll(prism, radius)
|
||||
|
||||
# add objects in the study
|
||||
id_prism = geompy.addToStudy(prism,"Prism")
|
||||
id_fillet = geompy.addToStudy(fillet,"Fillet")
|
||||
id_filletall = geompy.addToStudy(filletall,"Fillet all")
|
||||
|
||||
# display the prism and the results of fillet operation
|
||||
gg.createAndDisplayGO(id_prism)
|
||||
gg.setDisplayMode(id_prism,1)
|
||||
gg.createAndDisplayGO(id_fillet)
|
||||
gg.setDisplayMode(id_fillet,1)
|
||||
gg.createAndDisplayGO(id_filletall)
|
||||
gg.setDisplayMode(id_filletall,1)
|
63
doc/salome/examples/transformation_operations_ex13.py
Normal file
63
doc/salome/examples/transformation_operations_ex13.py
Normal file
@ -0,0 +1,63 @@
|
||||
# Chamfer
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
d1 = 10.
|
||||
d2 = 10.
|
||||
ShapeTypeFace = geompy.ShapeType["FACE"]
|
||||
|
||||
# create vertices and vectors
|
||||
p0 = geompy.MakeVertex( 0., 0., 0.)
|
||||
px = geompy.MakeVertex(100., 0., 0.)
|
||||
py = geompy.MakeVertex( 0., 100., 0.)
|
||||
pz = geompy.MakeVertex( 0., 0., 100.)
|
||||
vz = geompy.MakeVector(p0, pz)
|
||||
vxy = geompy.MakeVector(px, py)
|
||||
|
||||
# create an arc
|
||||
arc = geompy.MakeArc(py, pz, px)
|
||||
|
||||
# create a wire
|
||||
wire = geompy.MakeWire([vxy, arc])
|
||||
|
||||
# create a planar face
|
||||
face = geompy.MakeFace(wire, 1)
|
||||
|
||||
# create a prism
|
||||
prism = geompy.MakePrismVecH(face, vz, 100.0)
|
||||
|
||||
# get the list of IDs (IDList) for the chamfer
|
||||
prism_faces = geompy.SubShapeAllSortedCentres(prism, ShapeTypeFace)
|
||||
f_ind_1 = geompy.GetSubShapeID(prism, prism_faces[0])
|
||||
f_ind_2 = geompy.GetSubShapeID(prism, prism_faces[1])
|
||||
IDlist_f = [f_ind_1, f_ind_2]
|
||||
|
||||
# perform a chamfer on the edges common to the specified faces
|
||||
chamfer_e = geompy.MakeChamferEdge(prism, d1, d2, f_ind_1, f_ind_2)
|
||||
|
||||
# perform a chamfer on all edges of the specified faces
|
||||
chamfer_f = geompy.MakeChamferFaces(prism, d1, d2, IDlist_f)
|
||||
chamfer_f1 = geompy.MakeChamfer(prism, d1, d2, ShapeTypeFace, IDlist_f)
|
||||
|
||||
# perform a symmetric chamfer on all edges of the given shape
|
||||
chamfer_all = geompy.MakeChamferAll(prism, d1)
|
||||
|
||||
# add objects in the study
|
||||
id_prism = geompy.addToStudy(prism,"Prism")
|
||||
id_chamfer_e = geompy.addToStudy(chamfer_e,"Chamfer edge")
|
||||
id_chamfer_f = geompy.addToStudy(chamfer_f,"Chamfer faces")
|
||||
id_chamfer_f1 = geompy.addToStudy(chamfer_f1,"Chamfer faces 1")
|
||||
id_chamfer_all = geompy.addToStudy(chamfer_all,"Chamfer all")
|
||||
|
||||
# display the prism and the results of chamfer operation
|
||||
gg.createAndDisplayGO(id_prism)
|
||||
gg.setDisplayMode(id_prism,1)
|
||||
gg.createAndDisplayGO(id_chamfer_e)
|
||||
gg.setDisplayMode(id_chamfer_e,1)
|
||||
gg.createAndDisplayGO(id_chamfer_f)
|
||||
gg.setDisplayMode(id_chamfer_f,1)
|
||||
gg.createAndDisplayGO(id_chamfer_f1)
|
||||
gg.setDisplayMode(id_chamfer_f1,1)
|
||||
gg.createAndDisplayGO(id_chamfer_all)
|
||||
gg.setDisplayMode(id_chamfer_all,1)
|
17
doc/salome/examples/viewing_geom_objs_ex01.py
Normal file
17
doc/salome/examples/viewing_geom_objs_ex01.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Changing Display Mode
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
box = geompy.MakeBox(0,0,0, 50,50,50)
|
||||
box2 = geompy.MakeBox(-50,-50,-50, 0,0,0)
|
||||
|
||||
sphere = geompy.MakeSphere(50,50,50, 30)
|
||||
fuse = geompy.MakeBoolean(box,sphere,3)
|
||||
fuse_id = geompy.addToStudy(fuse,"Fuse")
|
||||
box_id = geompy.addToStudy(box2, "Box")
|
||||
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
gg.createAndDisplayGO(fuse_id)
|
||||
gg.setDisplayMode(fuse_id,1)
|
||||
gg.createAndDisplayGO(box_id)
|
||||
gg.setVectorsMode(box_id, 1)
|
14
doc/salome/examples/viewing_geom_objs_ex02.py
Normal file
14
doc/salome/examples/viewing_geom_objs_ex02.py
Normal file
@ -0,0 +1,14 @@
|
||||
# Changing Color
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
box = geompy.MakeBox(0,0,0, 50,50,50)
|
||||
|
||||
sphere = geompy.MakeSphere(50,50,50, 30)
|
||||
fuse = geompy.MakeBoolean(box,sphere,3)
|
||||
fuse_id = geompy.addToStudy(fuse,"Fuse")
|
||||
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
gg.createAndDisplayGO(fuse_id)
|
||||
gg.setDisplayMode(fuse_id,1)
|
||||
gg.setColor(fuse_id,218,165,31)
|
16
doc/salome/examples/viewing_geom_objs_ex03.py
Normal file
16
doc/salome/examples/viewing_geom_objs_ex03.py
Normal file
@ -0,0 +1,16 @@
|
||||
# Changing Transparency
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
|
||||
box = geompy.MakeBox(0,0,0, 50,50,50)
|
||||
sphere = geompy.MakeSphere(50,50,50, 30)
|
||||
|
||||
fuse = geompy.MakeBoolean(box,sphere,3)
|
||||
fuse_id = geompy.addToStudy(fuse,"Fuse")
|
||||
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
gg.createAndDisplayGO(fuse_id)
|
||||
gg.setDisplayMode(fuse_id,1)
|
||||
gg.setColor(fuse_id,218,165,31)
|
||||
gg.setTransparency(fuse_id,0.5)
|
14
doc/salome/examples/viewing_geom_objs_ex04.py
Normal file
14
doc/salome/examples/viewing_geom_objs_ex04.py
Normal file
@ -0,0 +1,14 @@
|
||||
# Set Point Marker
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
|
||||
texture = geompy.LoadTexture("/users/user/mytexture.dat")
|
||||
|
||||
v1 = geompy.MakeVertex(0, 0, 0)
|
||||
v2 = geompy.MakeVertex(100, 0, 0)
|
||||
v3 = geompy.MakeVertex(0, 100, 0)
|
||||
|
||||
v1.SetMarkerStd(GEOM.MT_O_PLUS, GEOM.MS_25)
|
||||
v2.SetMarkerStd(GEOM.MT_BALL, GEOM.MS_40)
|
||||
v3.SetMarkerTexture(texture)
|
9
doc/salome/examples/whatis.py
Normal file
9
doc/salome/examples/whatis.py
Normal file
@ -0,0 +1,9 @@
|
||||
# What Is
|
||||
|
||||
import geompy
|
||||
|
||||
# create a box
|
||||
box = geompy.MakeBoxDXDYDZ(100,30,100)
|
||||
Descr = geompy.WhatIs(box)
|
||||
print "\nBox 100x30x100 description:"
|
||||
print Descr
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user