Back to index

salome-geom  6.5.0
Functions
GEOM_TestHealing Namespace Reference

Functions

def TestProcessShape
def TestSuppressFaces
def TestSuppressInternalWires
def TestCloseContour
def TestSuppressHoles
def TestMakeSewing
def TestDivideEdge
def TestHealingOperations

Function Documentation

Definition at line 164 of file GEOM_TestHealing.py.

00164 
00165 def TestCloseContour (geompy):
00166 
00167   ##Load shape from BREP file
00168   #import os
00169   #datadir = os.getenv("GEOM_TEST")
00170   #if datadir != 0:
00171   #  datadir = datadir + "/Resources/"
00172   #else:
00173   #  "Please, define GEOM_TEST variable !"
00174   #
00175   #print "Import ", datadir + "open_cont.brep"
00176   #Shape = geompy.Import(datadir + "open_cont.brep", "BREP")
00177 
00178   p0   = geompy.MakeVertex(0.  , 0.  , 0.  )
00179   py   = geompy.MakeVertex(0.  , 100., 0.  )
00180   pz   = geompy.MakeVertex(0.  , 0.  , 100.)
00181   p200 = geompy.MakeVertex(200., 200., 200.)
00182 
00183   Shape = geompy.MakePolyline([p0, pz, py, p200])
00184 
00185   #Check shape
00186   print "Before closing contour:"
00187   isValid = geompy.CheckShape(Shape)
00188   if isValid == 0:
00189     print "The shape is not valid"
00190   else:
00191     print "The shape seems to be valid"
00192 
00193   #Close Contour
00194   IsCommonVertex = 0 # false
00195 
00196   shape_wires = geompy.SubShapeAll(Shape, geompy.ShapeType["WIRE"])
00197   Wires = []
00198   wi = 0
00199 
00200   for wire in shape_wires:
00201     Wires.append(geompy.GetSubShapeID(Shape, shape_wires[wi]))
00202     wi = wi + 1
00203 
00204   CC = geompy.CloseContour(Shape, Wires, IsCommonVertex)
00205 
00206   #Check shape
00207   print "After closing contour:"
00208   isValid = geompy.CheckShape(CC)
00209   if isValid == 0:
00210     print "The shape is not valid"
00211     raise RuntimeError, "It seems, that the contour was not closed"
00212   else:
00213     print "The shape seems to be valid"
00214 
00215   #Add In Study
00216   Id_Shape = geompy.addToStudy(Shape, "Shape with open wire")
00217   Id_CC    = geompy.addToStudy(CC, "Shape with closed wire")

Here is the caller graph for this function:

Definition at line 312 of file GEOM_TestHealing.py.

00312 
00313 def TestDivideEdge (geompy):
00314 
00315   #Create Box
00316   Box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
00317 
00318   #Divide Edge
00319   box_edges = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["EDGE"])
00320   edge_ind = geompy.GetSubShapeID(Box, box_edges[1])
00321 
00322   Divide = geompy.DivideEdge(Box, edge_ind, 0.5, 1) # Obj, ind, param, is_curve_param
00323 
00324   #Add In Study
00325   Id_Box    = geompy.addToStudy(Box, "Box")
00326   Id_Divide = geompy.addToStudy(Divide, "Box with Divided Edge")

Here is the caller graph for this function:

def GEOM_TestHealing.TestHealingOperations (   geompy,
  math 
)

Definition at line 327 of file GEOM_TestHealing.py.

00327 
00328 def TestHealingOperations (geompy, math):
00329 
00330   TestMakeSewing(geompy, math)
00331   TestDivideEdge(geompy)
00332   TestSuppressHoles(geompy)
00333   TestSuppressInternalWires(geompy)
00334   TestCloseContour(geompy)
00335   TestSuppressFaces(geompy)
00336   TestProcessShape(geompy)

Here is the call graph for this function:

def GEOM_TestHealing.TestMakeSewing (   geompy,
  math 
)

Definition at line 286 of file GEOM_TestHealing.py.

00286 
00287 def TestMakeSewing (geompy, math):
00288 
00289   #Create base points
00290   px = geompy.MakeVertex(100., 0., 0.)
00291   py = geompy.MakeVertex(0., 100., 0.)
00292   pz = geompy.MakeVertex(0., 0., 100.)
00293 
00294   #Create base geometry 2D & 3D
00295   Vector = geompy.MakeVector(px, py)
00296   Arc    = geompy.MakeArc(py, pz, px)
00297 
00298   #Create base objects
00299   angle     = 45. * math.pi / 180
00300   WantPlanarFace = 1 #True
00301 
00302   Wire = geompy.MakeWire([Vector, Arc])
00303   Face = geompy.MakeFace(Wire, WantPlanarFace)
00304   S    = geompy.MakeRotation(Face, Vector, angle)
00305 
00306   #Make Sewing
00307   precision = 0.00001
00308   Sewing = geompy.MakeSewing([Face, S], precision)
00309 
00310   #Add In Study
00311   id_Sewing = geompy.addToStudy(Sewing, "Sewing")

Here is the caller graph for this function:

Definition at line 30 of file GEOM_TestHealing.py.

00030 
00031 def TestProcessShape (geompy):
00032 
00033   ##Load shape from BREP file
00034   #import os
00035   #datadir = os.getenv("GEOM_TEST")
00036   #if datadir != 0:
00037   #  datadir = datadir + "/Resources/"
00038   #else:
00039   #  "Please, define GEOM_TEST variable !"
00040   #
00041   #print "Import ", datadir + "aze2.brep"
00042   #Shape = batchmode_geompy.Import(datadir + "aze2.brep", "BREP")
00043 
00044   p1 = geompy.MakeVertex(0,0,0)
00045   p2 = geompy.MakeVertex(200,0,0)
00046   p3 = geompy.MakeVertex(100,150,0)
00047 
00048   edge = geompy.MakeEdge(p1,p2)
00049   arc  = geompy.MakeArc(p1,p3,p2)
00050   wire = geompy.MakeWire([edge,arc])
00051   face = geompy.MakeFace(wire, 1)
00052 
00053   theShape = geompy.MakePrismVecH(face, edge, 130)
00054 
00055   #Check shape
00056   print "Before ProcessShape:"
00057   isValid = geompy.CheckShape(theShape)
00058   if isValid == 0:
00059     print "The shape is not valid"
00060   else:
00061     print "The shape seems to be valid"
00062 
00063   #Process Shape
00064   Operators = ["FixShape"]
00065   Parameters = ["FixShape.Tolerance3d"]
00066   Values = ["1e-7"]
00067 
00068   PS = geompy.ProcessShape(theShape, Operators, Parameters, Values)
00069 
00070   #Check shape
00071   print "After ProcessShape:"
00072   isValid = geompy.CheckShape(PS)
00073   if isValid == 0:
00074     print "The shape is not valid"
00075     raise RuntimeError, "It seems, that the ProcessShape() has failed"
00076   else:
00077     print "The shape seems to be valid"
00078 
00079   #Add In Study
00080   Id_Shape = geompy.addToStudy(theShape, "Invalid Shape")
00081   Id_PS    = geompy.addToStudy(PS, "Processed Shape")

Here is the caller graph for this function:

Definition at line 82 of file GEOM_TestHealing.py.

00082 
00083 def TestSuppressFaces (geompy):
00084 
00085   #Create base geometry 3D
00086   Box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
00087 
00088   #IDList for SuppHole
00089   faces = []
00090   faces = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"])
00091 
00092   f_glob_id = geompy.GetSubShapeID(Box, faces[5])
00093 
00094   #Transform objects
00095   SuppFace = geompy.SuppressFaces(Box, [f_glob_id])
00096 
00097   #Add In Study
00098   Id_SuppFace = geompy.addToStudy(SuppFace, "SuppFace")

Here is the caller graph for this function:

Definition at line 218 of file GEOM_TestHealing.py.

00218 
00219 def TestSuppressHoles (geompy):
00220 
00221   #Create base Variables
00222   radius = 50.
00223   height = 300.
00224 
00225   #Create base points
00226   p1 = geompy.MakeVertex(100., 100., 50.)
00227 
00228   #Create base directions
00229   vz = geompy.MakeVectorDXDYDZ(0., 0., 100.)
00230 
00231   #Create base geometry 3D
00232   Box      = geompy.MakeBoxDXDYDZ(200., 200., 200.)
00233   Cylinder = geompy.MakeCylinder(p1, vz, radius, height)
00234 
00235   #Boolean (Cut)
00236   Cut = geompy.MakeBoolean(Box, Cylinder, 2)
00237   idCut = geompy.addToStudy(Cut, "CUT")
00238 
00239   #IDList for SuppressFaces
00240   faces = []
00241   faces = geompy.SubShapeAllSortedCentres(Cut, geompy.ShapeType["FACE"])
00242   ind = 0
00243   for face in faces:
00244       f_name = "FACE %d"%(ind)
00245       f_id = geompy.addToStudyInFather(Cut, face, f_name)
00246 
00247       f_glob_id = geompy.GetSubShapeID(Cut, face)
00248       print "face ", ind, " global index = ", f_glob_id
00249       ind = ind + 1
00250 
00251   f_glob_id_0 = geompy.GetSubShapeID(Cut, faces[0])
00252   cut_without_f_0 = geompy.SuppressFaces(Cut, [f_glob_id_0])
00253   geompy.addToStudy(cut_without_f_0, "Cut without face 0")
00254 
00255   faces1 = []
00256   faces1 = geompy.SubShapeAllSortedCentres(cut_without_f_0, geompy.ShapeType["FACE"])
00257   ind = 0
00258   for face in faces1:
00259       f_name = "FACE %d"%(ind)
00260       f_id = geompy.addToStudyInFather(cut_without_f_0, face, f_name)
00261 
00262       f_glob_id = geompy.GetSubShapeID(cut_without_f_0, face)
00263       print "face ", ind, " global index = ", f_glob_id
00264       ind = ind + 1
00265 
00266   f_glob_id_3 = geompy.GetSubShapeID(cut_without_f_0, faces1[3])
00267   cut_without_f_0_3 = geompy.SuppressFaces(cut_without_f_0, [f_glob_id_3])
00268   cut_without_f_0_3_id = geompy.addToStudy(cut_without_f_0_3, "Cut without faces 0 and 3")
00269 
00270   #IDList for SuppHole
00271   wires = []
00272   wires = geompy.SubShapeAllSortedCentres(cut_without_f_0_3, geompy.ShapeType["WIRE"])
00273   ind = 0
00274   for wire in wires:
00275       w_name = "WIRE %d"%(ind)
00276       w_id = geompy.addToStudyInFather(cut_without_f_0_3, wire, w_name)
00277 
00278       w_glob_id = geompy.GetSubShapeID(cut_without_f_0_3, wire)
00279       print "wire ", ind, " global index = ", w_glob_id
00280       ind = ind + 1
00281 
00282   w_3 = geompy.GetSubShapeID(cut_without_f_0_3, wires[3])
00283 
00284   SuppHole3 = geompy.SuppressHoles(cut_without_f_0_3, [w_3])
00285   SuppHole3_id = geompy.addToStudy(SuppHole3, "Supp Hole 3")

Here is the caller graph for this function:

Definition at line 99 of file GEOM_TestHealing.py.

00099 
00100 def TestSuppressInternalWires (geompy):
00101 
00102   #Create Face with hole
00103   p11 = geompy.MakeVertex( 0,  0, 0)
00104   p12 = geompy.MakeVertex(30,  0, 0)
00105   p13 = geompy.MakeVertex(30, 30, 0)
00106   p14 = geompy.MakeVertex( 0, 30, 0)
00107 
00108   p21 = geompy.MakeVertex(10, 10, 0)
00109   p22 = geompy.MakeVertex(20, 10, 0)
00110   p23 = geompy.MakeVertex(20, 20, 0)
00111   p24 = geompy.MakeVertex(10, 20, 0)
00112 
00113   e11 = geompy.MakeEdge(p11, p12)
00114   e12 = geompy.MakeEdge(p12, p13)
00115   e13 = geompy.MakeEdge(p13, p14)
00116   e14 = geompy.MakeEdge(p14, p11)
00117 
00118   e21 = geompy.MakeEdge(p21, p22)
00119   e22 = geompy.MakeEdge(p22, p23)
00120   e23 = geompy.MakeEdge(p23, p24)
00121   e24 = geompy.MakeEdge(p24, p21)
00122 
00123   w1 = geompy.MakeWire([e11, e12, e13, e14])
00124   w2 = geompy.MakeWire([e21, e22, e23, e24])
00125 
00126   id_w1 = geompy.addToStudy(w1, "Outside Wire")
00127   id_w2 = geompy.addToStudy(w2, "Inside Wire")
00128 
00129   f12 = geompy.MakeFaceWires([w1, w2], 0)
00130   id_f12 = geompy.addToStudy(f12, "Face WO + WI")
00131 
00132   #Get Free Boundary
00133   Res1 = geompy.GetFreeBoundary(f12)
00134   isSuccess1   = Res1[0]
00135   ClosedWires1 = Res1[1]
00136   OpenWires1   = Res1[2]
00137   nbw1 = 0
00138 
00139   for wire in ClosedWires1:
00140     nbw1 = nbw1 + 1
00141 
00142   if nbw1 != 2:
00143     raise RuntimeError, "GetFreeBoundary(f12) must return 2 closed wires, but returned ", nbw1
00144 
00145   #SuppressInternalWires
00146   face = geompy.SuppressInternalWires(f12, [])
00147 
00148   #Get Free Boundary
00149   Res2 = geompy.GetFreeBoundary(face)
00150   isSuccess2   = Res2[0]
00151   ClosedWires2 = Res2[1]
00152   OpenWires2   = Res2[2]
00153   nbw2 = 0
00154 
00155   for wire in ClosedWires2:
00156     nbw2 = nbw2 + 1
00157 
00158   if nbw2 != 1:
00159     print "GetFreeBoundary(face) must return 1 closed wires, but returned ", nbw2
00160     raise RuntimeError, "SuppressInternalWires() works not correctly"
00161 
00162   #Add In Study
00163   Id_face = geompy.addToStudy(face, "Face without internal wires")

Here is the caller graph for this function: