3 \page tui_repairing_operations_page Repairing Operations
5 \anchor tui_shape_processing
6 <br><h2>Shape Processing</h2>
11 gg = salome.ImportComponentGUI("GEOM")
13 # create vertices, an edge, an arc, a wire, a face and a prism
14 p1 = geompy.MakeVertex(0,0,0)
15 p2 = geompy.MakeVertex(200,0,0)
16 p3 = geompy.MakeVertex(100,150,0)
17 edge = geompy.MakeEdge(p1,p2)
18 arc = geompy.MakeArc(p1,p3,p2)
19 wire = geompy.MakeWire([edge,arc])
20 face = geompy.MakeFace(wire, 1)
21 theShape = geompy.MakePrismVecH(face, edge, 130)
23 # check the shape at the beginning
24 print "Before ProcessShape:"
25 isValid = geompy.CheckShape(theShape)
27 print "The shape is not valid"
29 print "The shape seems to be valid"
32 Operators = ["FixShape"]
33 Parameters = ["FixShape.Tolerance3d"]
35 PS = geompy.ProcessShape(theShape, Operators, Parameters, Values)
37 # check the shape at the end
38 print "After ProcessShape:"
39 isValid = geompy.CheckShape(PS)
41 print "The shape is not valid"
42 raise RuntimeError, "It seems, that the ProcessShape() has failed"
44 print "The shape seems to be valid"
46 # add in the study and display
47 Id_Shape = geompy.addToStudy(theShape, "Invalid Shape")
48 Id_PS = geompy.addToStudy(PS, "Processed Shape")
49 gg.createAndDisplayGO(Id_Shape)
50 gg.setDisplayMode(Id_Shape,1)
51 gg.createAndDisplayGO(Id_PS)
52 gg.setDisplayMode(Id_PS,1)
55 \anchor tui_suppress_faces
56 <br><h2>Suppress Faces</h2>
61 gg = salome.ImportComponentGUI("GEOM")
64 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
66 # The list of IDs (IDList) for suppress faces
68 sup_faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"])
70 # get indices of the sub-shape
71 f1_id = geompy.GetSubShapeID(box, sup_faces[3])
73 # remove faces from the given object (shape)
74 result = geompy.SuppressFaces(box, [f1_id])
76 # add objects in the study
77 id_box = geompy.addToStudy(box, "Box")
78 id_result = geompy.addToStudy(result, "Result")
81 gg.createAndDisplayGO(id_box)
82 gg.setDisplayMode(id_box,1)
83 gg.createAndDisplayGO(id_result)
84 gg.setDisplayMode(id_result,1)
87 \anchor tui_close_contour
88 <br><h2>Close Contour</h2>
93 gg = salome.ImportComponentGUI("GEOM")
95 # create vertices and vectors
96 p0 = geompy.MakeVertex( 0., 0., 0.)
97 px = geompy.MakeVertex(100., 0., 0.)
98 py = geompy.MakeVertex( 0., 100., 0.)
99 py1 = geompy.MakeVertex( 0., 140., 0.)
100 pz = geompy.MakeVertex( 0., 0., 100.)
101 vxy = geompy.MakeVector(px, py)
104 arc = geompy.MakeArc(py1, pz, px)
107 wire = geompy.MakeWire([vxy, arc])
109 # close an open wire by creation of an edge between ends
110 wire_close = geompy.CloseContour(wire, [1], 0)
112 # add objects in the study
113 id_wire = geompy.addToStudy(wire, "Wire")
114 id_wire_close = geompy.addToStudy(wire_close, "Wire close")
116 # display the results
117 gg.createAndDisplayGO(id_wire)
118 gg.createAndDisplayGO(id_wire_close)
121 \anchor tui_suppress_internal_wires
122 <br><h2>Suppress Internal Wires</h2>
127 gg = salome.ImportComponentGUI("GEOM")
129 # create a vertex and a vector
130 p1 = geompy.MakeVertex(55, 65, 50)
131 p2 = geompy.MakeVertex(55, 0, 50)
132 v = geompy.MakeVector(p1, p2)
137 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
140 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
143 cut = geompy.MakeCut(box, cylinder)
145 # suppress all internal wires
146 result = geompy.SuppressInternalWires(cut, [])
148 # add objects in the study
149 id_cut = geompy.addToStudy(cut, "Cut")
150 id_result = geompy.addToStudy(result, "Result")
152 # display the results
153 gg.createAndDisplayGO(id_cut)
154 gg.setDisplayMode(id_cut,1)
155 gg.createAndDisplayGO(id_result)
156 gg.setDisplayMode(id_result,1)
159 \anchor tui_suppress_holes
160 <br><h2>Suppress Holes</h2>
165 gg = salome.ImportComponentGUI("GEOM")
167 # create a vertex and a vector
168 p1 = geompy.MakeVertex(35, 35, 0)
169 p2 = geompy.MakeVertex(35, 35, 50)
170 v = geompy.MakeVector(p1, p2)
175 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
178 cone = geompy.MakeCone(p1, v, 70, 0, 80)
181 cut = geompy.MakeCut(cone, cylinder)
183 # get faces as sub-shapes
185 faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
186 f_2 = geompy.GetSubShapeID(cut, faces[2])
188 # remove one face from the shape
189 cut_without_f_2 = geompy.SuppressFaces(cut, [f_2])
191 # get wires as sub-shapes
193 wires = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["WIRE"])
194 w_0 = geompy.GetSubShapeID(cut_without_f_2, wires[0])
196 # suppress the selected wire
197 result = geompy.SuppressHoles(cut_without_f_2, [w_0])
199 # add objects in the study
200 id_cut = geompy.addToStudy(cut, "Cut")
201 id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")
202 id_result = geompy.addToStudy(result, "Result")
204 # display the results
205 gg.createAndDisplayGO(id_cut)
206 gg.setDisplayMode(id_cut,1)
207 gg.createAndDisplayGO(id_cut_without_f_2)
208 gg.setDisplayMode(id_cut_without_f_2,1)
209 gg.createAndDisplayGO(id_result)
210 gg.setDisplayMode(id_result,1)
220 gg = salome.ImportComponentGUI("GEOM")
223 px = geompy.MakeVertex(100., 0., 0.)
224 py = geompy.MakeVertex(0., 100., 0.)
225 pz = geompy.MakeVertex(0., 0., 100.)
227 # create base geometry 2D & 3D
228 vector = geompy.MakeVector(px, py)
229 arc = geompy.MakeArc(py, pz, px)
231 # create base objects
232 angle = 45. * math.pi / 180
233 WantPlanarFace = 1 #True
234 wire = geompy.MakeWire([vector, arc])
235 face = geompy.MakeFace(wire, WantPlanarFace)
236 face_rot = geompy.MakeRotation(face, vector, angle)
240 sewing = geompy.MakeSewing([face, face_rot], precision)
242 # add objects in the study
243 id_face = geompy.addToStudy(face, "Face")
244 id_face_rot = geompy.addToStudy(face_rot, "Face rotation")
245 id_sewing = geompy.addToStudy(sewing, "Sewing")
247 # display the results
248 gg.createAndDisplayGO(id_face)
249 gg.setDisplayMode(id_face,1)
250 gg.createAndDisplayGO(id_face_rot)
251 gg.setDisplayMode(id_face_rot,1)
252 gg.createAndDisplayGO(id_sewing)
253 gg.setDisplayMode(id_sewing,1)
256 \anchor tui_glue_faces
257 <br><h2>Glue Faces</h2>
262 gg = salome.ImportComponentGUI("GEOM")
265 box1 = geompy.MakeBox(0,0,0,100,50,100)
266 box2 = geompy.MakeBox(100,0,0,250,50,100)
269 compound = geompy.MakeCompound([box1, box2])
271 # glue compound's faces
273 glue = geompy.MakeGlueFaces(compound, tolerance)
275 # add objects in study
276 id_box1 = geompy.addToStudy(box1, "Box1")
277 id_box2 = geompy.addToStudy(box2, "Box2")
278 id_compound = geompy.addToStudy(compound, "Compound")
279 id_glue = geompy.addToStudy(glue, "Glue faces")
282 gg.createAndDisplayGO(id_box1)
283 gg.setDisplayMode(id_box1,1)
284 gg.createAndDisplayGO(id_box2)
285 gg.setDisplayMode(id_box2,1)
286 gg.createAndDisplayGO(id_compound)
287 gg.setDisplayMode(id_compound,1)
288 gg.createAndDisplayGO(id_glue)
289 gg.setDisplayMode(id_glue,1)
292 \anchor tui_glue_edges
293 <br><h2>Glue Edges</h2>
298 gg = salome.ImportComponentGUI("GEOM")
301 box1 = geompy.MakeBox(0,0,0,100,50,100)
302 box2 = geompy.MakeBox(100,0,0,250,50,100)
305 compound = geompy.MakeCompound([box1, box2])
307 # glue all compound's edges
309 glue1 = geompy.MakeGlueEdges(compound, tolerance)
311 # glue some compound's edges
312 list_edges = geompy.GetGlueEdges(compound, tolerance)
313 glue2 = geompy.MakeGlueEdgesByList(compound, tolerance, [list_edges[0], list_edges[2]])
315 # add objects in study
316 geompy.addToStudy(box1, "Box1")
317 geompy.addToStudy(box2, "Box2")
318 geompy.addToStudy(compound, "Compound")
319 geompy.addToStudy(glue1, "Glue all edges")
320 geompy.addToStudy(glue2, "Glue two edges")
322 if salome.sg.hasDesktop():
323 salome.sg.updateObjBrowser(1)
326 \anchor tui_limit_tolerance
327 <br><h2>Limit Tolerance</h2>
331 gg = salome.ImportComponentGUI("GEOM")
333 # import initial topology
334 shape1 = geompy.ImportBREP("my_shape_1.brep")
335 shape2 = geompy.ImportBREP("my_shape_2.brep")
337 geompy.addToStudy(shape1, "Shape 1")
338 geompy.addToStudy(shape2, "Shape 2")
342 part = geompy.MakePartition([shape1, shape2])
346 shape1_lt = geompy.LimitTolerance(shape1, tolerance)
347 shape2_lt = geompy.LimitTolerance(shape2, tolerance)
350 good_shape1 = geompy.ProcessShape(shape1_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"])
351 good_shape2 = geompy.ProcessShape(shape2_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"])
353 geompy.addToStudy(good_shape1, "Shape 1 corrected")
354 geompy.addToStudy(good_shape2, "Shape 2 corrected")
356 # perform partition on corrected shapes
357 part = geompy.MakePartition([good_shape1, good_shape2])
360 geompy.addToStudy(part, "Partition")
363 \anchor tui_add_point_on_edge
364 <br><h2>Add Point on Edge</h2>
371 p1 = geompy.MakeVertex(0,0,50)
372 p2 = geompy.MakeVertex(60,0,50)
375 edge = geompy.MakeEdge(p1, p2) #geompy.GetSubShape(box, edge_ind)
378 divide = geompy.DivideEdge(edge, -1, 0.5, 0)
380 # add objects in the study
381 id_edge = geompy.addToStudy(edge, "Edge")
382 edge_points = geompy.SubShapeAllSortedCentres(edge, geompy.ShapeType["VERTEX"])
383 for point in edge_points:
384 geompy.addToStudyInFather(edge, point, "Edge's point")
386 id_divide = geompy.addToStudy(divide, "Divided edge")
387 edge_points = geompy.SubShapeAllSortedCentres(divide, geompy.ShapeType["VERTEX"])
388 for point in edge_points:
389 geompy.addToStudyInFather(divide, point, "Edge's point after divide")
391 salome.sg.updateObjBrowser(1)
394 \anchor tui_fuse_collinear_edges
395 <br><h2>Fuse Collinear Edges within a Wire</h2>
402 p1 = geompy.MakeVertex(0, 0, 0)
403 p2 = geompy.MakeVertex(70, 0, 0)
404 p3 = geompy.MakeVertex(70, 50, 0)
405 p4 = geompy.MakeVertex(70, 80, 0)
406 p5 = geompy.MakeVertex(50, 80, 0)
407 p6 = geompy.MakeVertex(20, 80, 0)
408 p7 = geompy.MakeVertex(0, 80, 0)
409 p8 = geompy.MakeVertex(0, 30, 0)
411 points = [p1, p2, p3, p4, p5, p6, p7, p8]
414 wire_1 = geompy.MakePolyline(points, True)
416 # suppress some vertices in the wire
417 wire_2 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p3])
418 wire_3 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p5, p6])
420 # suppress all suitable vertices in the wire
421 wire_4 = geompy.FuseCollinearEdgesWithinWire(wire_1, [])
423 wires = [wire_1, wire_2, wire_3, wire_4]
425 # add objects in the study
428 geompy.addToStudy(point, "p%d"%ii)
434 geompy.addToStudy(wire, "wire_%d"%ii)
435 wire_points = geompy.SubShapeAllSortedCentres(wire, geompy.ShapeType["VERTEX"])
437 for point in wire_points:
438 geompy.addToStudyInFather(wire, point, "point_%d"%jj)
444 salome.sg.updateObjBrowser(1)