mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-12 00:29:18 +05:00
f505d638da
Preparation of 3.2.0a1
1056 lines
24 KiB
HTML
Executable File
1056 lines
24 KiB
HTML
Executable File
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
<title>Repairing Operations</title>
|
|
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
|
|
<meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com">
|
|
<link rel="stylesheet" href="default_ns.css"><script type="text/javascript" language="JavaScript" title="WebHelpSplitCss">
|
|
<!--
|
|
if (navigator.appName !="Netscape")
|
|
{ document.write("<link rel='stylesheet' href='default.css'>");}
|
|
//-->
|
|
</script>
|
|
<style type="text/css">
|
|
<!--
|
|
p.whs1 { font-family:'Lucida Console' , monospace; }
|
|
p.whs2 { font-family:'Times New Roman' , serif; }
|
|
-->
|
|
</style><script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
|
|
<!--
|
|
function reDo() {
|
|
if (innerWidth != origWidth || innerHeight != origHeight)
|
|
location.reload();
|
|
}
|
|
if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
|
|
origWidth = innerWidth;
|
|
origHeight = innerHeight;
|
|
onresize = reDo;
|
|
}
|
|
onerror = null;
|
|
//-->
|
|
</script>
|
|
<style type="text/css">
|
|
<!--
|
|
div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
|
|
-->
|
|
</style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
|
|
<script type="text/javascript" language="javascript" src="whver.js"></script>
|
|
<script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
|
|
<script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
|
|
<script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
|
|
</head>
|
|
<body><script type="text/javascript" language="javascript1.2">
|
|
<!--
|
|
if (window.gbWhTopic)
|
|
{
|
|
if (window.addTocInfo)
|
|
{
|
|
addTocInfo("GEOM module\nTUI Scripts\nTransformation\nRepairing Operations");
|
|
addButton("show",BTN_TEXT,"Show","","","","",0,0,"","","");
|
|
|
|
}
|
|
if (window.writeBtnStyle)
|
|
writeBtnStyle();
|
|
|
|
if (window.writeIntopicBar)
|
|
writeIntopicBar(1);
|
|
|
|
if (window.setRelStartPage)
|
|
{
|
|
setRelStartPage("geom.htm");
|
|
|
|
autoSync(1);
|
|
sendSyncInfo();
|
|
sendAveInfoOut();
|
|
}
|
|
}
|
|
else
|
|
if (window.gbIE4)
|
|
document.location.reload();
|
|
//-->
|
|
</script>
|
|
<h1>Repairing Operations</h1>
|
|
|
|
<h3><a name=bookmark>Shape Processing</a></h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create vertices, an edge, an arc, a wire, a face and a prism</p>
|
|
|
|
<p class="whs1">p1 = geompy.MakeVertex(0,0,0)</p>
|
|
|
|
<p class="whs1">p2 = geompy.MakeVertex(200,0,0)</p>
|
|
|
|
<p class="whs1">p3 = geompy.MakeVertex(100,150,0)</p>
|
|
|
|
<p class="whs1">edge = geompy.MakeEdge(p1,p2)</p>
|
|
|
|
<p class="whs1">arc =
|
|
geompy.MakeArc(p1,p3,p2)</p>
|
|
|
|
<p class="whs1">wire = geompy.MakeWire([edge,arc])</p>
|
|
|
|
<p class="whs1">face = geompy.MakeFace(wire,
|
|
1)</p>
|
|
|
|
<p class="whs1">theShape = geompy.MakePrismVecH(face,
|
|
edge, 130)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># check the shape at the beginning</p>
|
|
|
|
<p class="whs1">print "Before
|
|
ProcessShape:"</p>
|
|
|
|
<p class="whs1">isValid = geompy.CheckShape(theShape)</p>
|
|
|
|
<p class="whs1">if isValid == 0:</p>
|
|
|
|
<p class="whs1"> print
|
|
"The shape is not valid"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"The shape seems to be valid"</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p># process the Shape</p>
|
|
|
|
<p class="whs1">Operators = ["FixShape"]</p>
|
|
|
|
<p class="whs1">Parameters = ["FixShape.Tolerance3d"]</p>
|
|
|
|
<p class="whs1">Values = ["1e-7"]</p>
|
|
|
|
<p class="whs1">PS = geompy.ProcessShape(theShape,
|
|
Operators, Parameters, Values)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># check the shape at the end</p>
|
|
|
|
<p class="whs1">print "After
|
|
ProcessShape:"</p>
|
|
|
|
<p class="whs1">isValid = geompy.CheckShape(PS)</p>
|
|
|
|
<p class="whs1">if isValid == 0:</p>
|
|
|
|
<p class="whs1"> print
|
|
"The shape is not valid"</p>
|
|
|
|
<p class="whs1"> raise
|
|
RuntimeError, "It seems, that the ProcessShape() has failed"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"The shape seems to be valid"</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># add in the study and display</p>
|
|
|
|
<p class="whs1">Id_Shape = geompy.addToStudy(theShape,
|
|
"Invalid Shape")</p>
|
|
|
|
<p class="whs1">Id_PS =
|
|
geompy.addToStudy(PS, "Processed Shape")</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(Id_Shape)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(Id_Shape,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(Id_PS)</p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(Id_PS,1)</span>
|
|
</p>
|
|
|
|
<p> </p>
|
|
|
|
<h3><a name=bookmark1>Suppress Faces</a></h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(200,
|
|
200, 200)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># The list of IDs (IDList) for suppress faces</p>
|
|
|
|
<p class="whs1">sup_faces = []</p>
|
|
|
|
<p class="whs1">sup_faces = geompy.SubShapeAllSorted(box,
|
|
geompy.ShapeType["FACE"])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># get indices of the sub-shape </p>
|
|
|
|
<p class="whs1">f1_id = geompy.GetSubShapeID(box,
|
|
sup_faces[3])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># remove faces from the given object (shape)</p>
|
|
|
|
<p class="whs1">result = geompy.SuppressFaces(box,
|
|
[f1_id])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># add objects in the study</p>
|
|
|
|
<p class="whs1">id_box = geompy.addToStudy(box,
|
|
"Box")</p>
|
|
|
|
<p class="whs1">id_result = geompy.addToStudy(result,
|
|
"Result")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># display the results</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_box)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_box,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_result)</p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(id_result,1)</span>
|
|
</p>
|
|
|
|
<p> </p>
|
|
|
|
<h3><a name=bookmark2>Close Contour</a></h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create vertices and vectors</p>
|
|
|
|
<p class="whs1">p0 =
|
|
geompy.MakeVertex( 0.,
|
|
0.,
|
|
0.)</p>
|
|
|
|
<p class="whs1">px =
|
|
geompy.MakeVertex(100., 0.,
|
|
0.)</p>
|
|
|
|
<p class="whs1">py =
|
|
geompy.MakeVertex( 0.,
|
|
100., 0.)</p>
|
|
|
|
<p class="whs1">py1 = geompy.MakeVertex(
|
|
0., 140.,
|
|
0.)</p>
|
|
|
|
<p class="whs1">pz =
|
|
geompy.MakeVertex( 0.,
|
|
0.,
|
|
100.)</p>
|
|
|
|
<p class="whs1">vxy = geompy.MakeVector(px,
|
|
py)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create an arc</p>
|
|
|
|
<p class="whs1">arc = geompy.MakeArc(py1,
|
|
pz, px)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a wire</p>
|
|
|
|
<p class="whs1">wire = geompy.MakeWire([vxy,
|
|
arc])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># close an open wire by creation of an edge between ends</p>
|
|
|
|
<p class="whs1">wire_close = geompy.CloseContour(wire,
|
|
[1], 0)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># add objects in the study</p>
|
|
|
|
<p class="whs1">id_wire = geompy.addToStudy(wire,
|
|
"Wire")</p>
|
|
|
|
<p class="whs1">id_wire_close = geompy.addToStudy(wire_close,
|
|
"Wire close")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># display the results</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_wire)</p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;">gg.createAndDisplayGO(id_wire_close)</span>
|
|
</p>
|
|
|
|
<p> </p>
|
|
|
|
<h3><a name=bookmark3>Suppress Internal Wires</a></h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a vertex and a vector</p>
|
|
|
|
<p class="whs1">p1 = geompy.MakeVertex(55,
|
|
65, 50)</p>
|
|
|
|
<p class="whs1">p2 = geompy.MakeVertex(55,
|
|
0, 50)</p>
|
|
|
|
<p class="whs1">v = geompy.MakeVector(p1,
|
|
p2)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a cylinder</p>
|
|
|
|
<p class="whs1">height = 100</p>
|
|
|
|
<p class="whs1">radius1 = 40</p>
|
|
|
|
<p class="whs1">cylinder = geompy.MakeCylinder(p1,
|
|
v, radius1, height)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,
|
|
100, 100)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># make a cut</p>
|
|
|
|
<p class="whs1">cut = geompy.MakeCut(box,
|
|
cylinder)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># suppress all internal wires</p>
|
|
|
|
<p class="whs1">result = geompy.SuppressInternalWires(cut,
|
|
[])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># add objects in the study</p>
|
|
|
|
<p class="whs1">id_cut = geompy.addToStudy(cut,
|
|
"Cut")</p>
|
|
|
|
<p class="whs1">id_result = geompy.addToStudy(result,
|
|
"Result")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># display the results</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_cut)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_cut,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_result)</p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(id_result,1)</span>
|
|
</p>
|
|
|
|
<p> </p>
|
|
|
|
<h3><a name=bookmark4>Suppress Holes</a></h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a vertex and a vector</p>
|
|
|
|
<p class="whs1">p1 = geompy.MakeVertex(35,
|
|
35, 0)</p>
|
|
|
|
<p class="whs1">p2 = geompy.MakeVertex(35,
|
|
35, 50)</p>
|
|
|
|
<p class="whs1">v = geompy.MakeVector(p1,
|
|
p2)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a cylinder</p>
|
|
|
|
<p class="whs1">height = 20</p>
|
|
|
|
<p class="whs1">radius1 = 20</p>
|
|
|
|
<p class="whs1">cylinder = geompy.MakeCylinder(p1,
|
|
v, radius1, height)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a cone</p>
|
|
|
|
<p class="whs1">cone = geompy.MakeCone(p1,
|
|
v, 70, 0, 80)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># make a cut</p>
|
|
|
|
<p class="whs1">cut = geompy.MakeCut(cone,
|
|
cylinder)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># get faces as sub-shapes</p>
|
|
|
|
<p class="whs1">faces = []</p>
|
|
|
|
<p class="whs1">faces = geompy.SubShapeAllSorted(cut,
|
|
geompy.ShapeType["FACE"])</p>
|
|
|
|
<p class="whs1">f_2 = geompy.GetSubShapeID(cut,
|
|
faces[2])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># remove one face from the shape</p>
|
|
|
|
<p class="whs1">cut_without_f_2 =
|
|
geompy.SuppressFaces(cut, [f_2])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># get wires as sub-shapes</p>
|
|
|
|
<p class="whs1">wires = []</p>
|
|
|
|
<p class="whs1">wires = geompy.SubShapeAllSorted(cut_without_f_2,
|
|
geompy.ShapeType["WIRE"])</p>
|
|
|
|
<p class="whs1">w_0 = geompy.GetSubShapeID(cut_without_f_2,
|
|
wires[0])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># suppress the selected wire</p>
|
|
|
|
<p class="whs1">result = geompy.SuppressHoles(cut_without_f_2,
|
|
[w_0])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># add objects in the study</p>
|
|
|
|
<p class="whs1">id_cut = geompy.addToStudy(cut,
|
|
"Cut")</p>
|
|
|
|
<p class="whs1">id_cut_without_f_2
|
|
= geompy.addToStudy(cut_without_f_2, "Cut without f_2")</p>
|
|
|
|
<p class="whs1">id_result = geompy.addToStudy(result,
|
|
"Result")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># display the results</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_cut)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_cut,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_cut_without_f_2)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_cut_without_f_2,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_result)</p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(id_result,1)</span>
|
|
</p>
|
|
|
|
<p> </p>
|
|
|
|
<h3><a name=bookmark5>Sewing</a></h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create base points</p>
|
|
|
|
<p class="whs1">px = geompy.MakeVertex(100.,
|
|
0., 0.)</p>
|
|
|
|
<p class="whs1">py = geompy.MakeVertex(0.,
|
|
100., 0.)</p>
|
|
|
|
<p class="whs1">pz = geompy.MakeVertex(0.,
|
|
0., 100.)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create base geometry 2D & 3D</p>
|
|
|
|
<p class="whs1">vector = geompy.MakeVector(px,
|
|
py)</p>
|
|
|
|
<p class="whs1">arc = geompy.MakeArc(py,
|
|
pz, px)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create base objects</p>
|
|
|
|
<p class="whs1">angle = 45. * math.pi
|
|
/ 180</p>
|
|
|
|
<p class="whs1">WantPlanarFace = 1
|
|
#True</p>
|
|
|
|
<p class="whs1">wire = geompy.MakeWire([vector,
|
|
arc])</p>
|
|
|
|
<p class="whs1">face = geompy.MakeFace(wire,
|
|
WantPlanarFace)</p>
|
|
|
|
<p class="whs1">face_rot = geompy.MakeRotation(face,
|
|
vector, angle)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># make sewing</p>
|
|
|
|
<p class="whs1">precision = 0.00001</p>
|
|
|
|
<p class="whs1">sewing = geompy.MakeSewing([face,
|
|
face_rot], precision)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># add objects in the study</p>
|
|
|
|
<p class="whs1">id_face = geompy.addToStudy(face,
|
|
"Face")</p>
|
|
|
|
<p class="whs1">id_face_rot = geompy.addToStudy(face_rot,
|
|
"Face rotation")</p>
|
|
|
|
<p class="whs1">id_sewing = geompy.addToStudy(sewing,
|
|
"Sewing")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># display the results</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_face)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_face,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_face_rot)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_face_rot,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_sewing)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_sewing,1)
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3><a name=bookmark6>Glue Faces</a></h3>
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
geompy</span></p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create boxes</p>
|
|
|
|
<p class="whs1">box1 = geompy.MakeBox(0,0,0,100,50,100)</p>
|
|
|
|
<p class="whs1">box2 = </p>
|
|
|
|
<p class="whs1">geompy.MakeBox(100,0,0,250,50,100)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># make compound</p>
|
|
|
|
<p class="whs1">compound = geompy.MakeCompound([box1,
|
|
box2])</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># glue compound's faces</p>
|
|
|
|
<p class="whs1">tolerance = 1e-5</p>
|
|
|
|
<p class="whs1">glue = geompy.MakeGlueFaces(compound,
|
|
tolerance)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add objects in study</p>
|
|
|
|
<p class="whs1">id_box1 = geompy.addToStudy(box1,
|
|
"Box1")</p>
|
|
|
|
<p class="whs1">id_box2 = geompy.addToStudy(box2,
|
|
"Box2")</p>
|
|
|
|
<p class="whs1">id_compound = geompy.addToStudy(compound,
|
|
"Compound")</p>
|
|
|
|
<p class="whs1">id_glue = geompy.addToStudy(glue,
|
|
"Glue faces")</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># display results</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_box1)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_box1,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_box2)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_box2,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_compound)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_compound,1)</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_glue)</p>
|
|
|
|
<p class="whs1">gg.setDisplayMode(id_glue,1)
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3><a name=bookmark7>Add Point on Edge</a></h3>
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
geompy</span></p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create vertices</p>
|
|
|
|
<p class="whs1">p1 = geompy.MakeVertex(0,0,50)</p>
|
|
|
|
<p class="whs1">p2 = geompy.MakeVertex(60,0,50)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># make an edge</p>
|
|
|
|
<p class="whs1">edge = geompy.MakeEdge(p1,
|
|
p2) #geompy.GetSubShape(box, edge_ind)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># divide an edge</p>
|
|
|
|
<p class="whs1">divide = geompy.DivideEdge(edge,
|
|
-1, 0.5, 0)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add objects in the
|
|
study</p>
|
|
|
|
<p class="whs1">id_edge = geompy.addToStudy(edge,
|
|
"Edge")</p>
|
|
|
|
<p class="whs1">edge_points = geompy.SubShapeAllSorted(edge,
|
|
geompy.ShapeType["VERTEX"])</p>
|
|
|
|
<p class="whs1">for point in edge_points:</p>
|
|
|
|
<p class="whs1"> geompy.addToStudyInFather(edge,
|
|
point, "Edge's point")</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">id_divide = geompy.addToStudy(divide,
|
|
"Divided edge")</p>
|
|
|
|
<p class="whs1">edge_points = geompy.SubShapeAllSorted(divide,
|
|
geompy.ShapeType["VERTEX"])</p>
|
|
|
|
<p class="whs1">for point in edge_points:</p>
|
|
|
|
<p class="whs1"> geompy.addToStudyInFather(divide,
|
|
point, "Edge's point after divide")</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<h3><a name=bookmark8>Check Free Boundaries</a></h3>
|
|
|
|
<p class="whs1">import os</p>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># create boxes</p>
|
|
|
|
<p class="whs1">box1 = geompy.MakeBox(0,0,0,100,50,100)</p>
|
|
|
|
<p class="whs1">box2 = geompy.MakeBox(100,0,0,250,50,100)</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># make a compound</p>
|
|
|
|
<p class="whs1">compound = geompy.MakeCompound([box1,
|
|
box2])</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># import from *.brep</p>
|
|
|
|
<p class="whs1">ImportBREP = geompy.ImportBREP("ImportBREP
|
|
= <span style="font-family: 'Lucida Console', monospace;">geompy.ImportBREP(os.getenv("DATA_DIR")+"/Shapes/Brep/flight_solid.brep")</span></p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># get a face</p>
|
|
|
|
<p class="whs1">faces = geompy.SubShapeAllSorted(ImportBREP,
|
|
geompy.ShapeType["FACE"])</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># get the free boundary
|
|
for face 32</p>
|
|
|
|
<p class="whs1">Res = geompy.GetFreeBoundary(faces[32])</p>
|
|
|
|
<p class="whs1">isSuccess =
|
|
Res[0]</p>
|
|
|
|
<p class="whs1">ClosedWires = Res[1]</p>
|
|
|
|
<p class="whs1">OpenWires =
|
|
Res[2]</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2">i<span style="font-family: 'Lucida Console', monospace;">f
|
|
isSuccess == 1 :</span></p>
|
|
|
|
<p class="whs1"> print
|
|
"Checking free boudaries is OK."</p>
|
|
|
|
<p class="whs1">else :</p>
|
|
|
|
<p class="whs1"> print
|
|
"Checking free boudaries is KO!"</p>
|
|
|
|
<p class="whs1">print "len(ClosedWires)
|
|
= ", len(ClosedWires)</p>
|
|
|
|
<p class="whs1">i = 0</p>
|
|
|
|
<p class="whs1">for wire in ClosedWires
|
|
:</p>
|
|
|
|
<p class="whs1"> wire_name
|
|
= "Face 32 -> Close wires : WIRE %d"%(i+1)</p>
|
|
|
|
<p class="whs1"> geompy.addToStudy(ClosedWires[i],
|
|
wire_name)</p>
|
|
|
|
<p class="whs1"> if
|
|
i < len(ClosedWires) :</p>
|
|
|
|
<p class="whs1"> i
|
|
= i+ 1</p>
|
|
|
|
<p class="whs1">print "len(OpenWires)
|
|
= ", len(OpenWires)</p>
|
|
|
|
<p class="whs1">i = 0</p>
|
|
|
|
<p class="whs1">for wire in OpenWires
|
|
:</p>
|
|
|
|
<p class="whs1"> wire_name
|
|
= "Face 32 -> Open wires : WIRE %d"%(i+1)</p>
|
|
|
|
<p class="whs1"> geompy.addToStudy(OpenWires[i],
|
|
wire_name)</p>
|
|
|
|
<p class="whs1"> if
|
|
i < len(OpenWires) :</p>
|
|
|
|
<p class="whs1"> i
|
|
= i+ 1</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># get the free boundary
|
|
for face 41</p>
|
|
|
|
<p class="whs1">Res = geompy.GetFreeBoundary(faces[41])</p>
|
|
|
|
<p class="whs1">isSuccess =
|
|
Res[0]</p>
|
|
|
|
<p class="whs1">ClosedWires = Res[1]</p>
|
|
|
|
<p class="whs1">OpenWires =
|
|
Res[2]</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">if isSuccess == 1
|
|
:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Checking free boudaries is OK."</p>
|
|
|
|
<p class="whs1">else :</p>
|
|
|
|
<p class="whs1"> print
|
|
"Checking free boudaries is KO!"</p>
|
|
|
|
<p class="whs1">print "len(ClosedWires)
|
|
= ", len(ClosedWires)</p>
|
|
|
|
<p class="whs1">i = 0</p>
|
|
|
|
<p class="whs1">for wire in ClosedWires
|
|
:</p>
|
|
|
|
<p class="whs1"> wire_name
|
|
= "Face 41 -> Close wires : WIRE %d"%(i+1)</p>
|
|
|
|
<p class="whs1"> geompy.addToStudy(ClosedWires[i],
|
|
wire_name)</p>
|
|
|
|
<p class="whs1"> if
|
|
i < len(ClosedWires) :</p>
|
|
|
|
<p class="whs1"> i
|
|
= i+ 1</p>
|
|
|
|
<p class="whs1">print "len(OpenWires)
|
|
= ", len(OpenWires)</p>
|
|
|
|
<p class="whs1">i = 0</p>
|
|
|
|
<p class="whs1">for wire in OpenWires
|
|
:</p>
|
|
|
|
<p class="whs1"> wire_name
|
|
= "Face 41 -> Open wires : WIRE %d"%(i+1)</p>
|
|
|
|
<p class="whs1"> geompy.addToStudy(OpenWires[i],
|
|
wire_name)</p>
|
|
|
|
<p class="whs1"> if
|
|
i < len(OpenWires) :</p>
|
|
|
|
<p class="whs1"> i
|
|
= i+ 1</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># add the imported object
|
|
to the study</p>
|
|
|
|
<p class="whs1">id_ImportBREP = geompy.addToStudy(ImportBREP,
|
|
"ImportBREP")</p>
|
|
|
|
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<h3><a name=bookmark9>Check Free Faces</a></h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a vertex and a vector</p>
|
|
|
|
<p class="whs1">p1 = geompy.MakeVertex(35,
|
|
35, 0)</p>
|
|
|
|
<p class="whs1">p2 = geompy.MakeVertex(35,
|
|
35, 50)</p>
|
|
|
|
<p class="whs1">v = geompy.MakeVector(p1,
|
|
p2)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a cylinder</p>
|
|
|
|
<p class="whs1">cylinder = geompy.MakeCone(p1,
|
|
v, 30, 20, 20)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a cone</p>
|
|
|
|
<p class="whs1">cone = geompy.MakeCone(p1,
|
|
v, 70, 40, 60)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># make cut</p>
|
|
|
|
<p class="whs1">cut = geompy.MakeCut(cone,
|
|
cylinder)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># get faces as sub-shapes</p>
|
|
|
|
<p class="whs1">faces = []</p>
|
|
|
|
<p class="whs1">faces = geompy.SubShapeAllSorted(cut,
|
|
geompy.ShapeType["FACE"])</p>
|
|
|
|
<p class="whs1">f_2 = geompy.GetSubShapeID(cut,
|
|
faces[0])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># remove one face from the shape</p>
|
|
|
|
<p class="whs1">cut_without_f_2 =
|
|
geompy.SuppressFaces(cut, [f_2])</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># suppress the specified wire</p>
|
|
|
|
<p class="whs1">result = geompy.GetFreeFacesIDs(cut_without_f_2)</p>
|
|
|
|
<p class="whs1">print "A number
|
|
of free faces is ", len(result)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># add objects in the study</p>
|
|
|
|
<p class="whs1">all_faces = geompy.SubShapeAllSorted(cut_without_f_2,
|
|
geompy.ShapeType["FACE"])</p>
|
|
|
|
<p class="whs1">for face in all_faces
|
|
:</p>
|
|
|
|
<p class="whs1"> sub_shape_id
|
|
= geompy.GetSubShapeID(cut_without_f_2, face)</p>
|
|
|
|
<p class="whs1"> if
|
|
result.count(sub_shape_id) > 0 :</p>
|
|
|
|
<p class="whs1"> face_name
|
|
= "Free face %d"%(sub_shape_id)</p>
|
|
|
|
<p class="whs1"> geompy.addToStudy(face,
|
|
face_name)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># in this example all faces from cut_without_f_2 are free</p>
|
|
|
|
<p class="whs1">id_cut_without_f_2
|
|
= geompy.addToStudy(cut_without_f_2, "Cut without f_2")</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># display the results</p>
|
|
|
|
<p class="whs1">gg.createAndDisplayGO(id_cut_without_f_2)</p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;">gg.setDisplayMode(id_cut_without_f_2,1)</span>
|
|
</p>
|
|
|
|
<script type="text/javascript" language="javascript1.2">
|
|
<!--
|
|
if (window.writeIntopicBar)
|
|
writeIntopicBar(0);
|
|
//-->
|
|
</script>
|
|
</body>
|
|
</html>
|