4 salome.salome_init_without_session()
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
8 gg = salome.ImportComponentGUI("GEOM")
11 px = geompy.MakeVertex(100., 0. , 0. )
12 py = geompy.MakeVertex(0. , 100., 0. )
13 pz = geompy.MakeVertex(0. , 0. , 100.)
15 # create a vector from two points
16 vxy = geompy.MakeVector(px, py)
18 # create an arc from three points
19 arc = geompy.MakeArc(py, pz, px)
22 wire = geompy.MakeWire([vxy, arc])
24 # add an object in the study
25 id_wire = geompy.addToStudy(wire,"Wire")
28 gg.createAndDisplayGO(id_wire)
30 # Create a wire from edges that are not connected to each other.
31 # Given tolerance should cover the gaps to build connected wire.
32 # Three different modes to do that are possible.
35 px_gap = geompy.MakeVertex(100. + gap, 0. , 0. )
36 py_gap = geompy.MakeVertex(0. , 100. + gap, 0. )
37 vxy_gap = geompy.MakeVector(px_gap, py_gap)
39 # 1. Join edges by fixing tolerance
40 wire_ft = geompy.MakeWire([vxy_gap, arc], tolerance, "wire_fixed_tolerance")
41 # final wire tolerance will be near the half of the gap (0.5)
42 print(geompy.Tolerance(wire_ft)[5])
43 assert(abs(geompy.Tolerance(wire_ft)[5] - 0.5) < 1e-04)
45 # 2. Join edges by changing their underlying curves (but keeping curve types)
46 # This functionality is available in TUI only.
47 wire_cc = geompy.MakeWireConstCurveType([vxy_gap, arc], tolerance, "wire_const_curve_type")
48 # final wire tolerance will stay small
49 print(geompy.Tolerance(wire_cc)[5])
50 assert(geompy.Tolerance(wire_cc)[5] < 1e-04)
52 # 3. Join edges by changing their underlying curves (approximating with b-splines)
53 # This functionality is available in TUI only.
54 wire_ap = geompy.MakeWireWithMode([vxy_gap, arc], tolerance, GEOM.WBM_Approximation, "wire_approximated_curves")
55 # final wire tolerance will stay small
56 print(geompy.Tolerance(wire_ap)[5])
57 assert(geompy.Tolerance(wire_ap)[5] < 1e-04)