1 <!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
\r
6 <title>Repairing Operations</title>
\r
7 <meta http-equiv="content-type" content="text/html; charset=windows-1252">
\r
8 <meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com">
\r
9 <link rel="stylesheet" href="default_ns.css"><script type="text/javascript" language="JavaScript" title="WebHelpSplitCss">
\r
11 if (navigator.appName !="Netscape")
\r
12 { document.write("<link rel='stylesheet' href='default.css'>");}
\r
15 <style type="text/css">
\r
17 p.whs1 { font-family:'Lucida Console' , monospace; }
\r
18 p.whs2 { font-family:'Times New Roman' , serif; }
\r
20 </style><script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
\r
23 if (innerWidth != origWidth || innerHeight != origHeight)
\r
26 if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
\r
27 origWidth = innerWidth;
\r
28 origHeight = innerHeight;
\r
34 <style type="text/css">
\r
36 div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
\r
38 </style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
\r
39 <script type="text/javascript" language="javascript" src="whver.js"></script>
\r
40 <script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
\r
41 <script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
\r
42 <script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
\r
44 <body><script type="text/javascript" language="javascript1.2">
\r
46 if (window.gbWhTopic)
\r
48 if (window.addTocInfo)
\r
50 addTocInfo("Geometry module\nTUI Scripts\nTransformation\nRepairing Operations");
\r
51 addButton("show",BTN_TEXT,"Show","","","","",0,0,"","","");
\r
54 if (window.writeBtnStyle)
\r
57 if (window.writeIntopicBar)
\r
60 if (window.setRelStartPage)
\r
62 setRelStartPage("geom.htm");
\r
71 document.location.reload();
\r
74 <h1>Repairing Operations</h1>
\r
76 <h3><a name=bookmark>Shape Processing</a></h3>
\r
78 <p class="whs1">import geompy</p>
\r
80 <p class="whs1">import salome</p>
\r
82 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
86 <p># create vertices, an edge, an arc, a wire, a face and a prism</p>
\r
88 <p class="whs1">p1 = geompy.MakeVertex(0,0,0)</p>
\r
90 <p class="whs1">p2 = geompy.MakeVertex(200,0,0)</p>
\r
92 <p class="whs1">p3 = geompy.MakeVertex(100,150,0)</p>
\r
94 <p class="whs1">edge = geompy.MakeEdge(p1,p2)</p>
\r
96 <p class="whs1">arc =
\r
97 geompy.MakeArc(p1,p3,p2)</p>
\r
99 <p class="whs1">wire = geompy.MakeWire([edge,arc])</p>
\r
101 <p class="whs1">face = geompy.MakeFace(wire,
\r
104 <p class="whs1">theShape = geompy.MakePrismVecH(face,
\r
109 <p># check the shape at the beginning</p>
\r
111 <p class="whs1">print "Before
\r
112 ProcessShape:"</p>
\r
114 <p class="whs1">isValid = geompy.CheckShape(theShape)</p>
\r
116 <p class="whs1">if isValid == 0:</p>
\r
118 <p class="whs1"> print
\r
119 "The shape is not valid"</p>
\r
121 <p class="whs1">else:</p>
\r
123 <p class="whs1"> print
\r
124 "The shape seems to be valid"</p>
\r
126 <p class="whs1"> </p>
\r
128 <p># process the Shape</p>
\r
130 <p class="whs1">Operators = ["FixShape"]</p>
\r
132 <p class="whs1">Parameters = ["FixShape.Tolerance3d"]</p>
\r
134 <p class="whs1">Values = ["1e-7"]</p>
\r
136 <p class="whs1">PS = geompy.ProcessShape(theShape,
\r
137 Operators, Parameters, Values)</p>
\r
141 <p># check the shape at the end</p>
\r
143 <p class="whs1">print "After
\r
144 ProcessShape:"</p>
\r
146 <p class="whs1">isValid = geompy.CheckShape(PS)</p>
\r
148 <p class="whs1">if isValid == 0:</p>
\r
150 <p class="whs1"> print
\r
151 "The shape is not valid"</p>
\r
153 <p class="whs1"> raise
\r
154 RuntimeError, "It seems, that the ProcessShape() has failed"</p>
\r
156 <p class="whs1">else:</p>
\r
158 <p class="whs1"> print
\r
159 "The shape seems to be valid"</p>
\r
163 <p># add in the study and display</p>
\r
165 <p class="whs1">Id_Shape = geompy.addToStudy(theShape,
\r
166 "Invalid Shape")</p>
\r
168 <p class="whs1">Id_PS =
\r
169 geompy.addToStudy(PS, "Processed Shape")</p>
\r
171 <p class="whs1">gg.createAndDisplayGO(Id_Shape)</p>
\r
173 <p class="whs1">gg.setDisplayMode(Id_Shape,1)</p>
\r
175 <p class="whs1">gg.createAndDisplayGO(Id_PS)</p>
\r
177 <p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(Id_PS,1)</span>
\r
182 <h3><a name=bookmark1>Suppress Faces</a></h3>
\r
184 <p class="whs1">import geompy</p>
\r
186 <p class="whs1">import salome</p>
\r
188 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
192 <p># create a box</p>
\r
194 <p class="whs1">box = geompy.MakeBoxDXDYDZ(200,
\r
199 <p># The list of IDs (IDList) for suppress faces</p>
\r
201 <p class="whs1">sup_faces = []</p>
\r
203 <p class="whs1">sup_faces = geompy.SubShapeAllSorted(box,
\r
204 geompy.ShapeType["FACE"])</p>
\r
208 <p># get indices of the sub-shape </p>
\r
210 <p class="whs1">f1_id = geompy.GetSubShapeID(box,
\r
215 <p># remove faces from the given object (shape)</p>
\r
217 <p class="whs1">result = geompy.SuppressFaces(box,
\r
222 <p># add objects in the study</p>
\r
224 <p class="whs1">id_box = geompy.addToStudy(box,
\r
225 "Box")</p>
\r
227 <p class="whs1">id_result = geompy.addToStudy(result,
\r
228 "Result")</p>
\r
232 <p># display the results</p>
\r
234 <p class="whs1">gg.createAndDisplayGO(id_box)</p>
\r
236 <p class="whs1">gg.setDisplayMode(id_box,1)</p>
\r
238 <p class="whs1">gg.createAndDisplayGO(id_result)</p>
\r
240 <p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(id_result,1)</span>
\r
245 <h3><a name=bookmark2>Close Contour</a></h3>
\r
247 <p class="whs1">import geompy</p>
\r
249 <p class="whs1">import salome</p>
\r
251 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
255 <p># create vertices and vectors</p>
\r
257 <p class="whs1">p0 =
\r
258 geompy.MakeVertex( 0.,
\r
260 0.)</p>
\r
262 <p class="whs1">px =
\r
263 geompy.MakeVertex(100., 0.,
\r
264 0.)</p>
\r
266 <p class="whs1">py =
\r
267 geompy.MakeVertex( 0.,
\r
268 100., 0.)</p>
\r
270 <p class="whs1">py1 = geompy.MakeVertex(
\r
272 0.)</p>
\r
274 <p class="whs1">pz =
\r
275 geompy.MakeVertex( 0.,
\r
279 <p class="whs1">vxy = geompy.MakeVector(px,
\r
282 <p> </p>
\r
284 <p># create an arc</p>
\r
286 <p class="whs1">arc = geompy.MakeArc(py1,
\r
291 <p># create a wire</p>
\r
293 <p class="whs1">wire = geompy.MakeWire([vxy,
\r
298 <p># close an open wire by creation of an edge between ends</p>
\r
300 <p class="whs1">wire_close = geompy.CloseContour(wire,
\r
305 <p># add objects in the study</p>
\r
307 <p class="whs1">id_wire = geompy.addToStudy(wire,
\r
308 "Wire")</p>
\r
310 <p class="whs1">id_wire_close = geompy.addToStudy(wire_close,
\r
311 "Wire close")</p>
\r
315 <p># display the results</p>
\r
317 <p class="whs1">gg.createAndDisplayGO(id_wire)</p>
\r
319 <p><span style="font-family: 'Lucida Console', monospace;">gg.createAndDisplayGO(id_wire_close)</span>
\r
324 <h3><a name=bookmark3>Suppress Internal Wires</a></h3>
\r
326 <p class="whs1">import geompy</p>
\r
328 <p class="whs1">import salome</p>
\r
330 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
334 <p># create a vertex and a vector</p>
\r
336 <p class="whs1">p1 = geompy.MakeVertex(55,
\r
339 <p class="whs1">p2 = geompy.MakeVertex(55,
\r
342 <p class="whs1">v = geompy.MakeVector(p1,
\r
347 <p># create a cylinder</p>
\r
349 <p class="whs1">height = 100</p>
\r
351 <p class="whs1">radius1 = 40</p>
\r
353 <p class="whs1">cylinder = geompy.MakeCylinder(p1,
\r
354 v, radius1, height)</p>
\r
358 <p># create a box</p>
\r
360 <p class="whs1">box = geompy.MakeBoxDXDYDZ(100,
\r
365 <p># make a cut</p>
\r
367 <p class="whs1">cut = geompy.MakeCut(box,
\r
372 <p># suppress all internal wires</p>
\r
374 <p class="whs1">result = geompy.SuppressInternalWires(cut,
\r
379 <p># add objects in the study</p>
\r
381 <p class="whs1">id_cut = geompy.addToStudy(cut,
\r
382 "Cut")</p>
\r
384 <p class="whs1">id_result = geompy.addToStudy(result,
\r
385 "Result")</p>
\r
389 <p># display the results</p>
\r
391 <p class="whs1">gg.createAndDisplayGO(id_cut)</p>
\r
393 <p class="whs1">gg.setDisplayMode(id_cut,1)</p>
\r
395 <p class="whs1">gg.createAndDisplayGO(id_result)</p>
\r
397 <p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(id_result,1)</span>
\r
402 <h3><a name=bookmark4>Suppress Holes</a></h3>
\r
404 <p class="whs1">import geompy</p>
\r
406 <p class="whs1">import salome</p>
\r
408 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
412 <p># create a vertex and a vector</p>
\r
414 <p class="whs1">p1 = geompy.MakeVertex(35,
\r
417 <p class="whs1">p2 = geompy.MakeVertex(35,
\r
420 <p class="whs1">v = geompy.MakeVector(p1,
\r
425 <p># create a cylinder</p>
\r
427 <p class="whs1">height = 20</p>
\r
429 <p class="whs1">radius1 = 20</p>
\r
431 <p class="whs1">cylinder = geompy.MakeCylinder(p1,
\r
432 v, radius1, height)</p>
\r
436 <p># create a cone</p>
\r
438 <p class="whs1">cone = geompy.MakeCone(p1,
\r
443 <p># make a cut</p>
\r
445 <p class="whs1">cut = geompy.MakeCut(cone,
\r
450 <p># get faces as sub-shapes</p>
\r
452 <p class="whs1">faces = []</p>
\r
454 <p class="whs1">faces = geompy.SubShapeAllSorted(cut,
\r
455 geompy.ShapeType["FACE"])</p>
\r
457 <p class="whs1">f_2 = geompy.GetSubShapeID(cut,
\r
462 <p># remove one face from the shape</p>
\r
464 <p class="whs1">cut_without_f_2 =
\r
465 geompy.SuppressFaces(cut, [f_2])</p>
\r
469 <p># get wires as sub-shapes</p>
\r
471 <p class="whs1">wires = []</p>
\r
473 <p class="whs1">wires = geompy.SubShapeAllSorted(cut_without_f_2,
\r
474 geompy.ShapeType["WIRE"])</p>
\r
476 <p class="whs1">w_0 = geompy.GetSubShapeID(cut_without_f_2,
\r
481 <p># suppress the selected wire</p>
\r
483 <p class="whs1">result = geompy.SuppressHoles(cut_without_f_2,
\r
488 <p># add objects in the study</p>
\r
490 <p class="whs1">id_cut = geompy.addToStudy(cut,
\r
491 "Cut")</p>
\r
493 <p class="whs1">id_cut_without_f_2
\r
494 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")</p>
\r
496 <p class="whs1">id_result = geompy.addToStudy(result,
\r
497 "Result")</p>
\r
501 <p># display the results</p>
\r
503 <p class="whs1">gg.createAndDisplayGO(id_cut)</p>
\r
505 <p class="whs1">gg.setDisplayMode(id_cut,1)</p>
\r
507 <p class="whs1">gg.createAndDisplayGO(id_cut_without_f_2)</p>
\r
509 <p class="whs1">gg.setDisplayMode(id_cut_without_f_2,1)</p>
\r
511 <p class="whs1">gg.createAndDisplayGO(id_result)</p>
\r
513 <p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(id_result,1)</span>
\r
518 <h3><a name=bookmark5>Sewing</a></h3>
\r
520 <p class="whs1">import geompy</p>
\r
522 <p class="whs1">import salome</p>
\r
524 <p class="whs1">import math</p>
\r
526 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
530 <p># create base points</p>
\r
532 <p class="whs1">px = geompy.MakeVertex(100.,
\r
535 <p class="whs1">py = geompy.MakeVertex(0.,
\r
538 <p class="whs1">pz = geompy.MakeVertex(0.,
\r
543 <p># create base geometry 2D & 3D</p>
\r
545 <p class="whs1">vector = geompy.MakeVector(px,
\r
548 <p class="whs1">arc = geompy.MakeArc(py,
\r
553 <p># create base objects</p>
\r
555 <p class="whs1">angle = 45. * math.pi
\r
558 <p class="whs1">WantPlanarFace = 1
\r
561 <p class="whs1">wire = geompy.MakeWire([vector,
\r
564 <p class="whs1">face = geompy.MakeFace(wire,
\r
565 WantPlanarFace)</p>
\r
567 <p class="whs1">face_rot = geompy.MakeRotation(face,
\r
572 <p># make sewing</p>
\r
574 <p class="whs1">precision = 0.00001</p>
\r
576 <p class="whs1">sewing = geompy.MakeSewing([face,
\r
577 face_rot], precision)</p>
\r
581 <p># add objects in the study</p>
\r
583 <p class="whs1">id_face = geompy.addToStudy(face,
\r
584 "Face")</p>
\r
586 <p class="whs1">id_face_rot = geompy.addToStudy(face_rot,
\r
587 "Face rotation")</p>
\r
589 <p class="whs1">id_sewing = geompy.addToStudy(sewing,
\r
590 "Sewing")</p>
\r
594 <p># display the results</p>
\r
596 <p class="whs1">gg.createAndDisplayGO(id_face)</p>
\r
598 <p class="whs1">gg.setDisplayMode(id_face,1)</p>
\r
600 <p class="whs1">gg.createAndDisplayGO(id_face_rot)</p>
\r
602 <p class="whs1">gg.setDisplayMode(id_face_rot,1)</p>
\r
604 <p class="whs1">gg.createAndDisplayGO(id_sewing)</p>
\r
606 <p class="whs1">gg.setDisplayMode(id_sewing,1)
\r
609 <p class="whs1"> </p>
\r
611 <h3><a name=bookmark6>Glue Faces</a></h3>
\r
613 <p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
\r
616 <p class="whs1">import salome</p>
\r
618 <p class="whs1"> </p>
\r
620 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
622 <p class="whs1"> </p>
\r
624 <p class="whs2"># create boxes</p>
\r
626 <p class="whs1">box1 = geompy.MakeBox(0,0,0,100,50,100)</p>
\r
628 <p class="whs1">box2 = <span style="font-family: 'Lucida Console', monospace;">geompy.MakeBox(100,0,0,250,50,100)</span></p>
\r
630 <p class="whs1"> </p>
\r
632 <p class="whs2"># make compound</p>
\r
634 <p class="whs1">compound = geompy.MakeCompound([box1,
\r
637 <p class="whs1"> </p>
\r
639 <p class="whs2"># glue compound's faces</p>
\r
641 <p class="whs1">tolerance = 1e-5</p>
\r
643 <p class="whs1">glue = geompy.MakeGlueFaces(compound,
\r
646 <p class="whs1"> </p>
\r
648 <p class="whs2"># add objects in study</p>
\r
650 <p class="whs1">id_box1 = geompy.addToStudy(box1,
\r
651 "Box1")</p>
\r
653 <p class="whs1">id_box2 = geompy.addToStudy(box2,
\r
654 "Box2")</p>
\r
656 <p class="whs1">id_compound = geompy.addToStudy(compound,
\r
657 "Compound")</p>
\r
659 <p class="whs1">id_glue = geompy.addToStudy(glue,
\r
660 "Glue faces")</p>
\r
662 <p class="whs1"> </p>
\r
664 <p class="whs2"># display results</p>
\r
666 <p class="whs1">gg.createAndDisplayGO(id_box1)</p>
\r
668 <p class="whs1">gg.setDisplayMode(id_box1,1)</p>
\r
670 <p class="whs1">gg.createAndDisplayGO(id_box2)</p>
\r
672 <p class="whs1">gg.setDisplayMode(id_box2,1)</p>
\r
674 <p class="whs1">gg.createAndDisplayGO(id_compound)</p>
\r
676 <p class="whs1">gg.setDisplayMode(id_compound,1)</p>
\r
678 <p class="whs1">gg.createAndDisplayGO(id_glue)</p>
\r
680 <p class="whs1">gg.setDisplayMode(id_glue,1)
\r
683 <p class="whs1"> </p>
\r
685 <h3><a name=bookmark7>Add Point on Edge</a></h3>
\r
687 <p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
\r
690 <p class="whs1">import salome</p>
\r
692 <p class="whs1"> </p>
\r
694 <p class="whs2"># create vertices</p>
\r
696 <p class="whs1">p1 = geompy.MakeVertex(0,0,50)</p>
\r
698 <p class="whs1">p2 = geompy.MakeVertex(60,0,50)</p>
\r
700 <p class="whs1"> </p>
\r
702 <p class="whs2"># make an edge</p>
\r
704 <p class="whs1">edge = geompy.MakeEdge(p1,
\r
705 p2) #geompy.GetSubShape(box, edge_ind)</p>
\r
707 <p class="whs1"> </p>
\r
709 <p class="whs2"># divide an edge</p>
\r
711 <p class="whs1">divide = geompy.DivideEdge(edge,
\r
714 <p class="whs1"> </p>
\r
716 <p class="whs2"># add objects in the
\r
719 <p class="whs1">id_edge = geompy.addToStudy(edge,
\r
720 "Edge")</p>
\r
722 <p class="whs1">edge_points = geompy.SubShapeAllSorted(edge,
\r
723 geompy.ShapeType["VERTEX"])</p>
\r
725 <p class="whs1">for point in edge_points:</p>
\r
727 <p class="whs1"> geompy.addToStudyInFather(edge,
\r
728 point, "Edge's point")</p>
\r
730 <p class="whs1"> </p>
\r
732 <p class="whs1">id_divide = geompy.addToStudy(divide,
\r
733 "Divided edge")</p>
\r
735 <p class="whs1">edge_points = geompy.SubShapeAllSorted(divide,
\r
736 geompy.ShapeType["VERTEX"])</p>
\r
738 <p class="whs1">for point in edge_points:</p>
\r
740 <p class="whs1"> geompy.addToStudyInFather(divide,
\r
741 point, "Edge's point after divide")</p>
\r
743 <p class="whs1"> </p>
\r
745 <p class="whs1">salome.sg.updateObjBrowser(1)
\r
748 <p class="whs2"> </p>
\r
750 <h3><a name=bookmark8>Check Free Boundaries</a></h3>
\r
752 <p class="whs1">import os</p>
\r
754 <p class="whs1">import geompy</p>
\r
756 <p class="whs1">import salome</p>
\r
758 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
760 <p class="whs2"> </p>
\r
762 <p class="whs2"># create boxes</p>
\r
764 <p class="whs1">box1 = geompy.MakeBox(0,0,0,100,50,100)</p>
\r
766 <p class="whs1">box2 = geompy.MakeBox(100,0,0,250,50,100)</p>
\r
768 <p class="whs2"> </p>
\r
770 <p class="whs2"># make a compound</p>
\r
772 <p class="whs1">compound = geompy.MakeCompound([box1,
\r
775 <p class="whs2"> </p>
\r
777 <p class="whs2"># import from *.brep</p>
\r
779 <p class="whs1">ImportBREP = geompy.ImportBREP("<span
\r
780 style="font-family: 'Lucida Console', monospace;">os.getenv("DATA_DIR")+"/Shapes/Brep/flight_solid.brep")</span></p>
\r
782 <p class="whs2"> </p>
\r
784 <p class="whs2"># get a face</p>
\r
786 <p class="whs1">faces = geompy.SubShapeAllSorted(ImportBREP,
\r
787 geompy.ShapeType["FACE"])</p>
\r
789 <p class="whs2"> </p>
\r
791 <p class="whs2"># get the free boundary
\r
794 <p class="whs1">Res = geompy.GetFreeBoundary(faces[32])</p>
\r
796 <p class="whs1">isSuccess =
\r
799 <p class="whs1">ClosedWires = Res[1]</p>
\r
801 <p class="whs1">OpenWires =
\r
804 <p class="whs2"> </p>
\r
806 <p class="whs2">i<span style="font-family: 'Lucida Console', monospace;">f
\r
807 isSuccess == 1 :</span></p>
\r
809 <p class="whs1"> print
\r
810 "Checking free boudaries is OK."</p>
\r
812 <p class="whs1">else :</p>
\r
814 <p class="whs1"> print
\r
815 "Checking free boudaries is KO!"</p>
\r
817 <p class="whs1">print "len(ClosedWires)
\r
818 = ", len(ClosedWires)</p>
\r
820 <p class="whs1">i = 0</p>
\r
822 <p class="whs1">for wire in ClosedWires
\r
825 <p class="whs1"> wire_name
\r
826 = "Face 32 -> Close wires : WIRE %d"%(i+1)</p>
\r
828 <p class="whs1"> geompy.addToStudy(ClosedWires[i],
\r
831 <p class="whs1"> if
\r
832 i < len(ClosedWires) :</p>
\r
834 <p class="whs1"> i
\r
837 <p class="whs1">print "len(OpenWires)
\r
838 = ", len(OpenWires)</p>
\r
840 <p class="whs1">i = 0</p>
\r
842 <p class="whs1">for wire in OpenWires
\r
845 <p class="whs1"> wire_name
\r
846 = "Face 32 -> Open wires : WIRE %d"%(i+1)</p>
\r
848 <p class="whs1"> geompy.addToStudy(OpenWires[i],
\r
851 <p class="whs1"> if
\r
852 i < len(OpenWires) :</p>
\r
854 <p class="whs1"> i
\r
857 <p class="whs2"> </p>
\r
859 <p class="whs2"># get the free boundary
\r
862 <p class="whs1">Res = geompy.GetFreeBoundary(faces[41])</p>
\r
864 <p class="whs1">isSuccess =
\r
867 <p class="whs1">ClosedWires = Res[1]</p>
\r
869 <p class="whs1">OpenWires =
\r
872 <p class="whs1"> </p>
\r
874 <p class="whs1">if isSuccess == 1
\r
877 <p class="whs1"> print
\r
878 "Checking free boudaries is OK."</p>
\r
880 <p class="whs1">else :</p>
\r
882 <p class="whs1"> print
\r
883 "Checking free boudaries is KO!"</p>
\r
885 <p class="whs1">print "len(ClosedWires)
\r
886 = ", len(ClosedWires)</p>
\r
888 <p class="whs1">i = 0</p>
\r
890 <p class="whs1">for wire in ClosedWires
\r
893 <p class="whs1"> wire_name
\r
894 = "Face 41 -> Close wires : WIRE %d"%(i+1)</p>
\r
896 <p class="whs1"> geompy.addToStudy(ClosedWires[i],
\r
899 <p class="whs1"> if
\r
900 i < len(ClosedWires) :</p>
\r
902 <p class="whs1"> i
\r
905 <p class="whs1">print "len(OpenWires)
\r
906 = ", len(OpenWires)</p>
\r
908 <p class="whs1">i = 0</p>
\r
910 <p class="whs1">for wire in OpenWires
\r
913 <p class="whs1"> wire_name
\r
914 = "Face 41 -> Open wires : WIRE %d"%(i+1)</p>
\r
916 <p class="whs1"> geompy.addToStudy(OpenWires[i],
\r
919 <p class="whs1"> if
\r
920 i < len(OpenWires) :</p>
\r
922 <p class="whs1"> i
\r
925 <p class="whs2"> </p>
\r
927 <p class="whs2"># add the imported object
\r
930 <p class="whs1">id_ImportBREP = geompy.addToStudy(ImportBREP,
\r
931 "ImportBREP")</p>
\r
933 <p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
\r
936 <p class="whs2"> </p>
\r
938 <h3><a name=bookmark9>Check Free Faces</a></h3>
\r
940 <p class="whs1">import geompy</p>
\r
942 <p class="whs1">import salome</p>
\r
944 <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
\r
948 <p># create a vertex and a vector</p>
\r
950 <p class="whs1">p1 = geompy.MakeVertex(35,
\r
953 <p class="whs1">p2 = geompy.MakeVertex(35,
\r
956 <p class="whs1">v = geompy.MakeVector(p1,
\r
961 <p># create a cylinder</p>
\r
963 <p class="whs1">cylinder = geompy.MakeCone(p1,
\r
968 <p># create a cone</p>
\r
970 <p class="whs1">cone = geompy.MakeCone(p1,
\r
977 <p class="whs1">cut = geompy.MakeCut(cone,
\r
982 <p># get faces as sub-shapes</p>
\r
984 <p class="whs1">faces = []</p>
\r
986 <p class="whs1">faces = geompy.SubShapeAllSorted(cut,
\r
987 geompy.ShapeType["FACE"])</p>
\r
989 <p class="whs1">f_2 = geompy.GetSubShapeID(cut,
\r
994 <p># remove one face from the shape</p>
\r
996 <p class="whs1">cut_without_f_2 =
\r
997 geompy.SuppressFaces(cut, [f_2])</p>
\r
1001 <p># suppress the specified wire</p>
\r
1003 <p class="whs1">result = geompy.GetFreeFacesIDs(cut_without_f_2)</p>
\r
1005 <p class="whs1">print "A number
\r
1006 of free faces is ", len(result)</p>
\r
1010 <p># add objects in the study</p>
\r
1012 <p class="whs1">all_faces = geompy.SubShapeAllSorted(cut_without_f_2,
\r
1013 geompy.ShapeType["FACE"])</p>
\r
1015 <p class="whs1">for face in all_faces
\r
1018 <p class="whs1"> sub_shape_id
\r
1019 = geompy.GetSubShapeID(cut_without_f_2, face)</p>
\r
1021 <p class="whs1"> if
\r
1022 result.count(sub_shape_id) > 0 :</p>
\r
1024 <p class="whs1"> face_name
\r
1025 = "Free face %d"%(sub_shape_id)</p>
\r
1027 <p class="whs1"> geompy.addToStudy(face,
\r
1032 <p># in this example all faces from cut_without_f_2 are free</p>
\r
1034 <p class="whs1">id_cut_without_f_2
\r
1035 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")</p>
\r
1039 <p># display the results</p>
\r
1041 <p class="whs1">gg.createAndDisplayGO(id_cut_without_f_2)</p>
\r
1043 <p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(id_cut_without_f_2,1)</span>
\r
1046 <script type="text/javascript" language="javascript1.2">
\r
1048 if (window.writeIntopicBar)
\r
1049 writeIntopicBar(0);
\r