From b78679f31c4a9e139fc9a1c50c1939032e69b417 Mon Sep 17 00:00:00 2001 From: akl Date: Wed, 20 Feb 2013 13:52:17 +0000 Subject: [PATCH] Fix example test scripts --- doc/salome/examples/Makefile.am | 4 +- doc/salome/examples/angle.py | 11 +++-- doc/salome/examples/complex_objs_ex06.py | 61 ++++++++++++------------ 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/doc/salome/examples/Makefile.am b/doc/salome/examples/Makefile.am index f6d1df44a..dc2264250 100644 --- a/doc/salome/examples/Makefile.am +++ b/doc/salome/examples/Makefile.am @@ -27,8 +27,6 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am pyexamplesdir = $(docdir)/examples/GEOM BAD_TESTS = \ - angle.py \ - complex_objs_ex06.py \ repairing_operations_ex09.py GOOD_TESTS = \ @@ -36,6 +34,7 @@ GOOD_TESTS = \ advanced_geom_objs_ex01.py \ advanced_geom_objs_ex02.py \ advanced_geom_objs_ex03.py \ + angle.py \ basic_geom_objs_ex01.py \ basic_geom_objs_ex02.py \ basic_geom_objs_ex03.py \ @@ -68,6 +67,7 @@ GOOD_TESTS = \ complex_objs_ex03.py \ complex_objs_ex04.py \ complex_objs_ex05.py \ + complex_objs_ex06.py \ complex_objs_ex07.py \ complex_objs_ex08.py \ complex_objs_ex09.py \ diff --git a/doc/salome/examples/angle.py b/doc/salome/examples/angle.py index 547db7184..324d72653 100644 --- a/doc/salome/examples/angle.py +++ b/doc/salome/examples/angle.py @@ -53,8 +53,11 @@ pnt1 = geompy.MakeVertex(0, 0, 0) pnt2 = geompy.MakeVertex(10, 0, 0) pnt3 = geompy.MakeVertex(20, 10, 0) arc = geompy.MakeArc(pnt1, pnt2, pnt3) -Angle = geompy.GetAngle(OX, arc) - -if (math.fabs(Angle + 1.0) > 1e-6 or geompy.MeasuOp.IsDone()): - print "Error. Angle must not be computed on curvilinear edges" +try: + Angle = geompy.GetAngle(OX, arc) + pass +except: + # It is a correct case, because GetAngle() must not be computed on curvilinear edges. pass + +assert (not geompy.MeasuOp.IsDone() ), 'Angle must not be computed on curvilinear edges.' diff --git a/doc/salome/examples/complex_objs_ex06.py b/doc/salome/examples/complex_objs_ex06.py index 8f6c4e35a..4a3dfe439 100644 --- a/doc/salome/examples/complex_objs_ex06.py +++ b/doc/salome/examples/complex_objs_ex06.py @@ -2,6 +2,7 @@ import geompy import salome +import math gg = salome.ImportComponentGUI("GEOM") # create path @@ -54,30 +55,30 @@ faces = [] w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0", [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = geompy.MakeArc(w,3,-1) -w = geompy.MakeWire([e1,e2,e3,arc]) +contour = geompy.CloseContour(w, [], isCommonVertex=False) +[e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"]) +w = geompy.MakeWire([e1,e2,e3,e4]) f1 = geompy.MakeFace(w,1) w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20", [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,-1) -w = geompy.MakeWire([e1,e2,e3,arc]) +contour = geompy.CloseContour(w, [], isCommonVertex=False) +[e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"]) +w = geompy.MakeWire([e1,e2,e3,e4]) f2 = geompy.MakeFace(w,1) w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20", [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,-1) -w = geompy.MakeWire([e1,e2,e3,arc]) +contour = geompy.CloseContour(w, [], isCommonVertex=False) +[e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"]) +w = geompy.MakeWire([e1,e2,e3,e4]) f3 = geompy.MakeFace(w,1) w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0", [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,-1) -w = geompy.MakeWire([e1,e2,e3,arc]) +contour = geompy.CloseContour(w, [], isCommonVertex=False) +[e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"]) +w = geompy.MakeWire([e1,e2,e3,e4]) f4 = geompy.MakeFace(w,1) faces.append(f1) @@ -99,30 +100,30 @@ nz = c3[2] - c2[2] w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0", [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,1) -w = geompy.MakeWire([e1,e2,e3,arc]) +contour = geompy.CloseContour(w, [], isCommonVertex=False) +[e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"]) +w = geompy.MakeWire([e1,e2,e3,e4]) f1 = geompy.MakeFace(w,1) w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20", [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,1) -w = geompy.MakeWire([e1,e2,e3,arc]) +contour = geompy.CloseContour(w, [], isCommonVertex=False) +[e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"]) +w = geompy.MakeWire([e1,e2,e3,e4]) f2 = geompy.MakeFace(w,1) w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20", [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,1) -w = geompy.MakeWire([e1,e2,e3,arc]) +contour = geompy.CloseContour(w, [], isCommonVertex=False) +[e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"]) +w = geompy.MakeWire([e1,e2,e3,e4]) f3 = geompy.MakeFace(w,1) w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0", [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,1) -w = geompy.MakeWire([e1,e2,e3,arc]) +contour = geompy.CloseContour(w, [], isCommonVertex=False) +[e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"]) +w = geompy.MakeWire([e1,e2,e3,e4]) f4 = geompy.MakeFace(w,1) faces.append(f1) @@ -168,19 +169,19 @@ fs.append(ff) aPartition = geompy.MakePartition(shellsph,fs) fs = geompy.SubShapeAllSortedCentres(aPartition, geompy.ShapeType["FACE"]) -faces.append(fs[0]) -faces.append(fs[1]) -faces.append(fs[2]) -faces.append(fs[3]) +for face in fs: + if ( 4 == geompy.NbShapes(face, geompy.ShapeType["VERTEX"]) ): + faces.append(face) + pass + pass shell = geompy.MakeSewing(faces,1.e-6) shells.append(shell) faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) - +subbases.append(faces[2]) #=========================================================== # Create Pipe #=========================================================== -subbases = [] Pipe = geompy.MakePipeWithShellSections(shells, subbases, theLocations, WirePath, theWithContact=0, theWithCorrection=0) -- 2.39.2