mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-04-26 18:20:47 +05:00
839 lines
20 KiB
HTML
Executable File
839 lines
20 KiB
HTML
Executable File
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
<title>Measurement Tools</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; }
|
|
p.WebHelpNavBar { text-align:right; }
|
|
-->
|
|
</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>
|
|
<script type="text/javascript" language="javascript1.2">
|
|
<!--
|
|
if (window.gbWhTopic)
|
|
{
|
|
if (window.setRelStartPage)
|
|
{
|
|
addTocInfo("Geometry module\nTUI Scripts\nMeasurement Tools");
|
|
addButton("show",BTN_IMG,"Show","","","","",0,0,"whd_show0.gif","whd_show2.gif","whd_show1.gif");
|
|
addButton("hide",BTN_IMG,"Hide","","","","",0,0,"whd_hide0.gif","whd_hide2.gif","whd_hide1.gif");
|
|
|
|
}
|
|
|
|
|
|
if (window.setRelStartPage)
|
|
{
|
|
setRelStartPage("index.htm");
|
|
|
|
autoSync(1);
|
|
sendSyncInfo();
|
|
sendAveInfoOut();
|
|
}
|
|
|
|
}
|
|
else
|
|
if (window.gbIE4)
|
|
document.location.reload();
|
|
//-->
|
|
</script>
|
|
</head>
|
|
<body><script type="text/javascript" language="javascript1.2">
|
|
<!--
|
|
if (window.writeIntopicBar)
|
|
writeIntopicBar(4);
|
|
//-->
|
|
</script>
|
|
<h1>Measurement Tools</h1>
|
|
|
|
<h3>Point Coordinates</h3>
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create a point</p>
|
|
|
|
<p class="whs1">point = geompy.MakeVertex(15.,
|
|
23., 80.)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># get the coordinates
|
|
of the point and check its values</p>
|
|
|
|
<p class="whs1">coords = geompy.PointCoordinates(point)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># check the obtained
|
|
coordinate values </p>
|
|
|
|
<p class="whs1">tolerance = 1.e-07</p>
|
|
|
|
<p class="whs1">def IsEqual(val1,
|
|
val2): return (math.fabs(val1 - val2) < tolerance)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">if IsEqual(coords[0],
|
|
15.) and IsEqual(coords[1], 23.) and IsEqual(coords[2], 80.):</p>
|
|
|
|
<p class="whs1"> print
|
|
"All values are OK."</p>
|
|
|
|
<p class="whs1">else :</p>
|
|
|
|
<p class="whs1"> print
|
|
"Coordinates of point must be (15, 23, 80), but returned (",</p>
|
|
|
|
<p class="whs1"> print
|
|
coords[0], ", ", coords[1], ", ", coords[2], ")"</p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;"> pass</span>
|
|
</p>
|
|
|
|
<h3>Basic Properties</h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
<p class="whs1">props = geompy.BasicProperties(box)</p>
|
|
|
|
<p class="whs1">print "\nBox
|
|
100x30x100 Basic Properties:"</p>
|
|
|
|
<p class="whs1">print " Wires
|
|
length: ", props[0]</p>
|
|
|
|
<p class="whs1">print " Surface
|
|
area: ", props[1]</p>
|
|
|
|
<p class="whs1">print " Volume
|
|
:
|
|
", props[2]</p>
|
|
|
|
<p class="whs1">length = math.sqrt((props[0]
|
|
- 1840)*(props[0] - 1840))</p>
|
|
|
|
<p class="whs1">area = math.sqrt((props[1]
|
|
- 32000)*(props[1] - 32000))</p>
|
|
|
|
<p class="whs1">volume = math.sqrt((props[2]
|
|
- 300000)*(props[2] - 300000))</p>
|
|
|
|
<p class="whs1">if length > 1e-7
|
|
or area > 1e-7 or volume > 1e-7:</p>
|
|
|
|
<p class="whs1"> print
|
|
"While must be:"</p>
|
|
|
|
<p class="whs1"> print
|
|
" Wires length: ", 1840</p>
|
|
|
|
<p class="whs1"> print
|
|
" Surface area: ", 32000</p>
|
|
|
|
<p class="whs1"> print
|
|
" Volume :
|
|
", 300000.</p>
|
|
|
|
<h3>Center of masses</h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
<p class="whs1">cm = geompy.MakeCDG(box)</p>
|
|
|
|
<p class="whs1">if cm is None:</p>
|
|
|
|
<p class="whs1"> raise
|
|
RuntimeError, "MakeCDG(box) failed"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"\nCentre of gravity of box has been successfully obtained:"</p>
|
|
|
|
<p class="whs1"> coords
|
|
= geompy.PointCoordinates(cm)</p>
|
|
|
|
<p class="whs1"> print
|
|
"(", coords[0], ", ", coords[1], ", ", coords[2],
|
|
")"</p>
|
|
|
|
<p class="whs1"> dx
|
|
= math.sqrt((coords[0] - 50)*(coords[0] - 50))</p>
|
|
|
|
<p class="whs1"> dy
|
|
= math.sqrt((coords[1] - 15)*(coords[1] - 15))</p>
|
|
|
|
<p class="whs1"> dz
|
|
= math.sqrt((coords[2] - 50)*(coords[2] - 50))</p>
|
|
|
|
<p class="whs1"> if
|
|
dx > 1e-7 or dy > 1e-7 or dz > 1e-7:</p>
|
|
|
|
<p class="whs1"> print
|
|
"But must be (50, 15, 50)" </p>
|
|
|
|
<h3>Inertia</h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
<p class="whs1">In = geompy.Inertia(box)</p>
|
|
|
|
<p class="whs1">print "\nInertia
|
|
matrix of box 100x30x100:"</p>
|
|
|
|
<p class="whs1">print " (",
|
|
In[0], ", ", In[1], ", ", In[2], ")"</p>
|
|
|
|
<p class="whs1">print " (",
|
|
In[3], ", ", In[4], ", ", In[5], ")"</p>
|
|
|
|
<p class="whs1">print " (",
|
|
In[6], ", ", In[7], ", ", In[8], ")"</p>
|
|
|
|
<p class="whs1">print "Main moments
|
|
of inertia of box 100x30x100:"</p>
|
|
|
|
<p class="whs1">print " Ix =
|
|
", In[9], ", Iy = ", In[10], ", Iz = ", In[11]
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3>Check Free Boundaries</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("<span
|
|
style="font-family: 'Lucida Console', monospace;">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>Check Free Faces</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>
|
|
|
|
<h3>Bounding Box</h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
<p class="whs1">bb = geompy.BoundingBox(box)</p>
|
|
|
|
<p class="whs1">print "\nBounding
|
|
Box of box 100x30x100:"</p>
|
|
|
|
<p class="whs1">print " Xmin
|
|
= ", bb[0], ", Xmax = ", bb[1]</p>
|
|
|
|
<p class="whs1">print " Ymin
|
|
= ", bb[2], ", Ymax = ", bb[3]</p>
|
|
|
|
<p class="whs1">print " Zmin
|
|
= ", bb[4], ", Zmax = ", bb[5] </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3>Minimal Distance </h3>
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
geompy</span></p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create boxes</p>
|
|
|
|
<p class="whs1">box1 = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
<p class="whs1">box2 = geompy.MakeBox(105,0,0,200,30,100)</p>
|
|
|
|
<p class="whs1">min_dist = geompy.MinDistance(box1,box2)</p>
|
|
|
|
<p class="whs1">print "\nMinimal
|
|
distance between box1 and box2 = ", min_dist </p>
|
|
|
|
<h3>Angle</h3>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">salome.salome_init()</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">geompy.init_geom(salome.myStudy)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p class="whs1">OX =
|
|
geompy.MakeVectorDXDYDZ(10, 0,0)</p>
|
|
|
|
<p class="whs1">OXY = geompy.MakeVectorDXDYDZ(10,10,0)</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># in one plane</p>
|
|
|
|
<p class="whs1">Angle = geompy.GetAngle(OX,
|
|
OXY)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">print "\nAngle
|
|
between OX and OXY = ", Angle</p>
|
|
|
|
<p class="whs1">if math.fabs(Angle
|
|
- 45.0) > 1e-05:</p>
|
|
|
|
<p class="whs1"> print
|
|
" Error:
|
|
returned angle is", Angle, "while must be 45.0"</p>
|
|
|
|
<p class="whs1"> pass</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># not in one plane</p>
|
|
|
|
<p class="whs1">OXY_shift = geompy.MakeTranslation(OXY,10,-10,20)</p>
|
|
|
|
<p class="whs1">Angle = geompy.GetAngle(OX,
|
|
OXY_shift)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">print "Angle
|
|
between OX and OXY_shift = ", Angle</p>
|
|
|
|
<p class="whs1">if math.fabs(Angle
|
|
- 45.0) > 1e-05:</p>
|
|
|
|
<p class="whs1"> print
|
|
" Error:
|
|
returned angle is", Angle, "while must be 45.0"</p>
|
|
|
|
<p class="whs1"> pass</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># not linear</p>
|
|
|
|
<p class="whs1">pnt1 = geompy.MakeVertex(0,
|
|
0, 0)</p>
|
|
|
|
<p class="whs1">pnt2 = geompy.MakeVertex(10,
|
|
0, 0)</p>
|
|
|
|
<p class="whs1">pnt3 = geompy.MakeVertex(20,
|
|
10, 0)</p>
|
|
|
|
<p class="whs1">arc =
|
|
geompy.MakeArc(pnt1, pnt2, pnt3)</p>
|
|
|
|
<p class="whs1">Angle = geompy.GetAngle(OX,
|
|
arc)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">if (math.fabs(Angle
|
|
+ 1.0) > 1e-6 or geompy.MeasuOp.IsDone()):</p>
|
|
|
|
<p class="whs1"> print
|
|
"Error. Angle must not be computed on curvilinear edges"</p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;"> pass</span>
|
|
</p>
|
|
|
|
<h3>Tolerance</h3>
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
geompy</span></p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
<p class="whs1">Toler = geompy.Tolerance(box)</p>
|
|
|
|
<p class="whs1">print "\nBox
|
|
100x30x100 tolerance:"</p>
|
|
|
|
<p class="whs1">print " Face
|
|
min. tolerance: ", Toler[0]</p>
|
|
|
|
<p class="whs1">print " Face
|
|
max. tolerance: ", Toler[1]</p>
|
|
|
|
<p class="whs1">print " Edge
|
|
min. tolerance: ", Toler[2]</p>
|
|
|
|
<p class="whs1">print " Edge
|
|
max. tolerance: ", Toler[3]</p>
|
|
|
|
<p class="whs1">print " Vertex
|
|
min. tolerance: ", Toler[4]</p>
|
|
|
|
<p class="whs1">print " Vertex
|
|
max. tolerance: ", Toler[5] </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3>What Is</h3>
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
geompy</span></p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
<p class="whs1">Descr = geompy.WhatIs(box)</p>
|
|
|
|
<p class="whs1">print "\nBox
|
|
100x30x100 description:"</p>
|
|
|
|
<p class="whs1">print Descr </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3>Check Shape</h3>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
<p class="whs1">IsValid = geompy.CheckShape(box)</p>
|
|
|
|
<p class="whs1">if IsValid == 0:</p>
|
|
|
|
<p class="whs1"> raise
|
|
RuntimeError, "Invalid box created"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"\nBox is valid" </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3>Check Compound of Blocks</h3>
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
geompy</span></p>
|
|
|
|
<p class="whs1">import salome</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 = geompy.MakeBox(100,0,0,250,50,100)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># make a compound</p>
|
|
|
|
<p class="whs1">compound = geompy.MakeCompound([box1,
|
|
box2])</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># glue the faces of the
|
|
compound</p>
|
|
|
|
<p class="whs1">tolerance = 1e-5</p>
|
|
|
|
<p class="whs1">glue = geompy.MakeGlueFaces(compound,
|
|
tolerance)</p>
|
|
|
|
<p class="whs1">IsValid = geompy.CheckCompoundOfBlocks(glue)</p>
|
|
|
|
<p class="whs1">if IsValid == 0:</p>
|
|
|
|
<p class="whs1"> raise
|
|
RuntimeError, "Invalid compound created"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"\nCompound is valid" </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<script type="text/javascript" language="javascript1.2">
|
|
<!--
|
|
if (window.writeIntopicBar)
|
|
writeIntopicBar(0);
|
|
//-->
|
|
</script>
|
|
</body>
|
|
</html>
|