/[escript]/trunk/pycad/test/python/run_pycad_test.py
ViewVC logotype

Diff of /trunk/pycad/test/python/run_pycad_test.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 930 by gross, Thu Jan 18 08:12:58 2007 UTC revision 931 by gross, Fri Jan 19 03:06:33 2007 UTC
# Line 757  class Test_PyCAD_Primitives(unittest.Tes Line 757  class Test_PyCAD_Primitives(unittest.Tes
757          p3=Point(3,3,3,0.4)          p3=Point(3,3,3,0.4)
758          p4=Point(1,2,3)          p4=Point(1,2,3)
759    
760          self.failUnlessRaises(TypeError,Spline,p0)          self.failUnlessRaises(ValueError,Spline,p0)
761          c=Spline(p0,p1,p2,p3)          c=Spline(p0,p1,p2,p3)
762    
763          self.failUnless(len(c) == 4, "wrong spline curve length")          self.failUnless(len(c) == 4, "wrong spline curve length")
# Line 908  class Test_PyCAD_Primitives(unittest.Tes Line 908  class Test_PyCAD_Primitives(unittest.Tes
908          p3=Point(3,3,3,0.4)          p3=Point(3,3,3,0.4)
909          p4=Point(1,2,3)          p4=Point(1,2,3)
910    
911          self.failUnlessRaises(TypeError,BezierCurve,p0)          self.failUnlessRaises(ValueError,BezierCurve,p0)
912          c=BezierCurve(p0,p1,p2,p3)          c=BezierCurve(p0,p1,p2,p3)
913    
914          self.failUnless(len(c) == 4, "wrong spline curve length")          self.failUnless(len(c) == 4, "wrong spline curve length")
# Line 978  class Test_PyCAD_Primitives(unittest.Tes Line 978  class Test_PyCAD_Primitives(unittest.Tes
978          p3=Point(3,3,3,0.4)          p3=Point(3,3,3,0.4)
979          p4=Point(1,2,3)          p4=Point(1,2,3)
980    
981          self.failUnlessRaises(TypeError,BSpline,p0)          self.failUnlessRaises(ValueError,BSpline,p0)
982          c=BSpline(p0,p1,p2,p3)          c=BSpline(p0,p1,p2,p3)
983    
984          self.failUnless(len(c) == 4, "wrong spline curve length")          self.failUnless(len(c) == 4, "wrong spline curve length")
# Line 1396  class Test_PyCAD_Primitives(unittest.Tes Line 1396  class Test_PyCAD_Primitives(unittest.Tes
1396          ly=Line(p3,p1)          ly=Line(p3,p1)
1397    
1398          c=CurveLoop(l01,l12,l20)          c=CurveLoop(l01,l12,l20)
1399          c=CurveLoop(l01,l20,l12)          self.failUnlessRaises(ValueError,CurveLoop,l01,lx,l20)
1400          self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,lx,l20,msg="loop detected.")          self.failUnlessRaises(ValueError,CurveLoop,l01,l20,l20)
1401          self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,l20,l20,msg="douple not detected.")          self.failUnlessRaises(ValueError,CurveLoop,l01,l20,ly)
         self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,l20,ly,msg="loop detected.")  
1402    
1403            c=CurveLoop(l01,l20,l12)
1404          self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")          self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1405          self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")          self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1406    
# Line 1597  class Test_PyCAD_Primitives(unittest.Tes Line 1597  class Test_PyCAD_Primitives(unittest.Tes
1597          cl2=CurveLoop(l01,l12_2_1,l12_2_2,l20)          cl2=CurveLoop(l01,l12_2_1,l12_2_2,l20)
1598          cl3=CurveLoop(l01,l12_3,l20)          cl3=CurveLoop(l01,l12_3,l20)
1599    
1600          self.failUnlessRaises(TypeError,ValueError,RuledSurface,l01,msg="non CurveLoop argument accepted.")          self.failUnlessRaises(TypeError,RuledSurface,l01)
1601    
1602          s=RuledSurface(cl1)          s=RuledSurface(cl1)
1603    
# Line 1738  class Test_PyCAD_Primitives(unittest.Tes Line 1738  class Test_PyCAD_Primitives(unittest.Tes
1738          cl2=CurveLoop(l01,l12_2_1,l12_2_2,l20)          cl2=CurveLoop(l01,l12_2_1,l12_2_2,l20)
1739          cl3=CurveLoop(l01,l12_3,l20)          cl3=CurveLoop(l01,l12_3,l20)
1740    
1741          self.failUnlessRaises(TypeError,ValueError,RuledSurface,l01,msg="non CurveLoop argument accepted.")          self.failUnlessRaises(TypeError,RuledSurface,l01)
1742    
1743          CC0=RuledSurface(cl1)          CC0=RuledSurface(cl1)
1744          s=-CC0          s=-CC0
# Line 1896  class Test_PyCAD_Primitives(unittest.Tes Line 1896  class Test_PyCAD_Primitives(unittest.Tes
1896          cl_a=CurveLoop(a1,l1,l2)          cl_a=CurveLoop(a1,l1,l2)
1897          h_a=CurveLoop(a2,l6,l4)          h_a=CurveLoop(a2,l6,l4)
1898    
1899          self.failUnlessRaises(TypeError,ValueError,PlaneSurface,l4,msg="non CurveLoop argument accepted.")          self.failUnlessRaises(TypeError,PlaneSurface,l4)
1900          self.failUnlessRaises(TypeError,ValueError,PlaneSurface,cl_a,h,msg="CurveLoop with no line curves accepted.")          self.failUnlessRaises(TypeError,PlaneSurface,cl_a,h)
1901          self.failUnlessRaises(TypeError,ValueError,PlaneSurface,cl,[h_a],msg="CurveLoop with no line curves as holes accepted.")          self.failUnlessRaises(TypeError,PlaneSurface,cl,[h_a])
1902    
1903          s=PlaneSurface(cl,holes=[h])          s=PlaneSurface(cl,holes=[h])
1904    
# Line 2113  class Test_PyCAD_Primitives(unittest.Tes Line 2113  class Test_PyCAD_Primitives(unittest.Tes
2113          cl_a=CurveLoop(a1,l1,l2)          cl_a=CurveLoop(a1,l1,l2)
2114          h_a=CurveLoop(a2,l6,l4)          h_a=CurveLoop(a2,l6,l4)
2115    
2116          self.failUnlessRaises(TypeError,ValueError,PlaneSurface,l4,msg="non CurveLoop argument accepted.")          self.failUnlessRaises(TypeError,PlaneSurface,l4)
2117          self.failUnlessRaises(TypeError,ValueError,PlaneSurface,cl_a,h,msg="CurveLoop with no line curves accepted.")          self.failUnlessRaises(TypeError,PlaneSurface,cl_a,h)
2118          self.failUnlessRaises(TypeError,ValueError,PlaneSurface,cl,[h_a],msg="CurveLoop with no line curves as holes accepted.")          self.failUnlessRaises(TypeError,PlaneSurface,cl,[h_a])
2119    
2120          CC0=PlaneSurface(cl,holes=[h])          CC0=PlaneSurface(cl,holes=[h])
2121          s=-CC0          s=-CC0
# Line 2296  class Test_PyCAD_Primitives(unittest.Tes Line 2296  class Test_PyCAD_Primitives(unittest.Tes
2296          self.failUnless(p5 in cp, "inplace dilation must use p5")          self.failUnless(p5 in cp, "inplace dilation must use p5")
2297          self.failUnless(p6 in cp, "inplace dilation must use p6")          self.failUnless(p6 in cp, "inplace dilation must use p6")
2298    
2299     def stest_SurfaceLoop(self):     def test_SurfaceLoop(self):
2300          p0=Point( 0, 0, 0,0.1)          p0=Point( 0, 0, 0,0.1)
2301          p1=Point(10, 0, 0,0.1)          p1=Point(10, 0, 0,0.1)
2302          p2=Point( 0,10, 0,0.1)          p2=Point( 0,10, 0,0.1)
# Line 2338  class Test_PyCAD_Primitives(unittest.Tes Line 2338  class Test_PyCAD_Primitives(unittest.Tes
2338          m76=Line(q7,q6)          m76=Line(q7,q6)
2339          m62=Line(q6,q2)          m62=Line(q6,q2)
2340    
2341            m02=Line(q0,q2)
2342            m13=Line(q1,q3)
2343            m46=Line(q4,q6)
2344            m57=Line(q5,q7)
2345    
2346          cl_l1=CurveLoop(l01,l15,l54,l04)          cl_l1=CurveLoop(l01,l15,l54,l04)
2347          cl_m1=CurveLoop(m01,m15,m54,m40)          cl_m1=CurveLoop(m01,m15,m54,m40)
2348          s1=PlaneSurface(cl_l1,holes=[cl_m1])          s1=PlaneSurface(cl_l1,holes=[cl_m1])
2349            s1_v=PlaneSurface(cl_l1)
2350    
2351          cl_l2=CurveLoop(-l15,l13,l37,l75)          cl_l2=CurveLoop(-l15,l13,l37,l75)
2352          s2=PlaneSurface(cl_l2)          s2=PlaneSurface(cl_l2)
# Line 2348  class Test_PyCAD_Primitives(unittest.Tes Line 2354  class Test_PyCAD_Primitives(unittest.Tes
2354          cl_l3=CurveLoop(l32,-l37,l67,l26)          cl_l3=CurveLoop(l32,-l37,l67,l26)
2355          cl_m3=CurveLoop(-m23,-m37,-m76,-m62)          cl_m3=CurveLoop(-m23,-m37,-m76,-m62)
2356          s3=PlaneSurface(cl_l3,holes=[cl_m3])          s3=PlaneSurface(cl_l3,holes=[cl_m3])
2357            s3_v=PlaneSurface(cl_l3)
2358        
2359            
2360          cl_l4=CurveLoop(l20,-l26,l46,-l04)          cl_l4=CurveLoop(l20,-l26,l46,-l04)
2361          s4=PlaneSurface(cl_l4)          s4=PlaneSurface(cl_l4)
# Line 2358  class Test_PyCAD_Primitives(unittest.Tes Line 2366  class Test_PyCAD_Primitives(unittest.Tes
2366          cl_l6=CurveLoop(l67,l75,l54,l46)          cl_l6=CurveLoop(l67,l75,l54,l46)
2367          s6=PlaneSurface(-cl_l6)          s6=PlaneSurface(-cl_l6)
2368    
2369          x=SurfaceLoop(s1,s2,s3,s4,s5)          cl_m7=CurveLoop(m13,m37,-m57,-m15)
2370          print x          s7=PlaneSurface(cl_m7)
2371          print "X"          
2372          self.failUnlessRaises(TypeError,SurfaceLoop,s1,s2,s3,s4,s5,msg="broken loop not detecred.")          cl_m8=CurveLoop(m57,m76,-m46,-m54)
2373          s=SurfaceLoop(s1,s2,s3,s4,s5,s6)          s8=PlaneSurface(cl_m8)
2374    
2375            cl_m9=CurveLoop(m46,m62,-m02,-m40)
2376            s9=PlaneSurface(cl_m9)
2377    
2378            cl_m10=CurveLoop(-m01,m02,m23,-m13)
2379            s10=PlaneSurface(cl_m10)
2380    
2381            self.failUnlessRaises(ValueError,SurfaceLoop,s1,s3)
2382            self.failUnlessRaises(ValueError,SurfaceLoop,s1,s2,s3,s4,s5)
2383            self.failUnlessRaises(ValueError,SurfaceLoop,s1,s2,s3,s4,s5,s5)
2384            s=SurfaceLoop(s1,s2,s3,s4,s5,s6,-s7,-s8,-s9,-s10)
2385    
2386            self.failUnless(s.hasSameOrientation(s),"has not same orientation like itself")
2387            self.failUnless(not s.hasSameOrientation(-s),"has same orientation like -itself")
2388    
2389            cc=s.getSurfaces()
2390            self.failUnless(len(cc) == 10, "too many curves.")
2391            self.failUnless(s1 in cc, "s1 is missing")
2392            self.failUnless(s2 in cc, "s2 is missing")
2393            self.failUnless(s3 in cc, "s3 is missing")
2394            self.failUnless(s4 in cc, "s4 is missing")
2395            self.failUnless(s5 in cc, "s5 is missing")
2396            self.failUnless(s6 in cc, "s6 is missing")
2397            self.failUnless(s7 in cc, "s7 is missing")
2398            self.failUnless(s8 in cc, "s8 is missing")
2399            self.failUnless(s9 in cc, "s9 is missing")
2400            self.failUnless(s10 in cc, "s10 is missing")
2401    
2402            code=s.getGmshCommand()
2403            self.failUnless(code == "Surface Loop(68) = {43, 46, 49, 52, 54, 56, -58, -60, -62, -64};", "gmsh command wrong.")
2404    
2405            self.failUnless(not s.isColocated(p4),"SurfaceLoop is colocated with point.")
2406            self.failUnless(s.isColocated(s),"SurfaceLoop is not colocated with its self.")
2407            self.failUnless(s.isColocated(-s),"SurfaceLoop is not colocated with its reverse.")
2408            self.failUnless(s.isColocated(SurfaceLoop(s1,s2,s3,s4,s5,s6,-s7,-s8,-s9,-s10)),"SurfaceLoop is not colocated with its copy.")
2409            self.failUnless(s.isColocated(SurfaceLoop(-s10, s1,s2,s3,s4,s5,s6,-s7,-s8,-s9)),"SurfaceLoop is not colocated with its copy with shifted points.")
2410            self.failUnless(s.isColocated(SurfaceLoop(s1, -s7, s2, -s9, s3, -s8, s4, -s10, s5,s6)),"SurfaceLoop is not colocated with its copy with shuffled points.")
2411            self.failUnless(not s.isColocated(SurfaceLoop(s1_v,s2,s3_v,s4,s5,s6)),"SurfaceLoop is colocated with different SurfaceLoop.")
2412    
2413            self.failUnless(len(s) == 10, "wrong length")
2414    
2415            s.setLocalScale(3.)
2416            self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
2417            self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
2418            self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
2419            self.failUnless(p3.getLocalScale()==3., "p3 has wrong local scale.")
2420            self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
2421            self.failUnless(p5.getLocalScale()==3., "p5 has wrong local scale.")
2422            self.failUnless(p6.getLocalScale()==3., "p6 has wrong local scale.")
2423            self.failUnless(p7.getLocalScale()==3., "p7 has wrong local scale.")
2424    
2425            p=s.getPrimitives()
2426            self.failUnless(len(p) == 63, "too many primitives.")
2427            self.failUnless(s in p, "s is missing")
2428            self.failUnless(p0 in p, "p0 is missing")
2429            self.failUnless(p1 in p, "p1 is missing")
2430            self.failUnless(p2 in p, "p2 is missing")
2431            self.failUnless(p3 in p, "p3 is missing")
2432            self.failUnless(p4 in p, "p4 is missing")
2433            self.failUnless(p5 in p, "p5 is missing")
2434            self.failUnless(p6 in p, "p6 is missing")
2435            self.failUnless(p7 in p, "p7 is missing")
2436            self.failUnless(q0 in p, "q0 is missing")
2437            self.failUnless(q1 in p, "q1 is missing")
2438            self.failUnless(q2 in p, "q2 is missing")
2439            self.failUnless(q3 in p, "q3 is missing")
2440            self.failUnless(q4 in p, "q4 is missing")
2441            self.failUnless(q5 in p, "q5 is missing")
2442            self.failUnless(q6 in p, "q6 is missing")
2443            self.failUnless(q7 in p, "q7 is missing")
2444            self.failUnless(l01 in p, "l01 is missing")
2445            self.failUnless(l15 in p, "l15 is missing")
2446            self.failUnless(l54 in p, "l54 is missing")
2447            self.failUnless(l04 in p, "l04 is missing")
2448            self.failUnless(l13 in p, "l13 is missing")
2449            self.failUnless(l37 in p, "l37 is missing")
2450            self.failUnless(l75 in p, "l75 is missing")
2451            self.failUnless(l67 in p, "l67 is missing")
2452            self.failUnless(l26 in p, "l26 is missing")
2453            self.failUnless(l32 in p, "l32 is missing")
2454            self.failUnless(l20 in p, "l20 is missing")
2455            self.failUnless(l46 in p, "l46 is missing")
2456            self.failUnless(m01 in p, "m01 is missing")
2457            self.failUnless(m15 in p, "m15 is missing")
2458            self.failUnless(m54 in p, "m54 is missing")
2459            self.failUnless(m40 in p, "m40 is missing")
2460            self.failUnless(m23 in p, "m23 is missing")
2461            self.failUnless(m37 in p, "m37 is missing")
2462            self.failUnless(m76 in p, "m76 is missing")
2463            self.failUnless(m62 in p, "m62 is missing")
2464            self.failUnless(m02 in p, "m02 is missing")
2465            self.failUnless(m13 in p, "m13 is missing")
2466            self.failUnless(m46 in p, "m46 is missing")
2467            self.failUnless(m57 in p, "m57 is missing")
2468            self.failUnless(cl_l1 in p, "cl_l1 is missing")
2469            self.failUnless(cl_m1 in p, "cl_m1 is missing")
2470            self.failUnless(s1 in p, "s1 is missing")
2471            self.failUnless(cl_l2 in p, "cl_l2 is missing")
2472            self.failUnless(s2 in p, "s2 is missing")
2473            self.failUnless(cl_l3 in p, "cl_l3 is missing")
2474            self.failUnless(cl_m3 in p, "cl_m3 is missing")
2475            self.failUnless(s3 in p, "s3 is missing")
2476            self.failUnless(cl_l4 in p, "cl_l4 is missing")
2477            self.failUnless(s4 in p, "s4 is missing")
2478            self.failUnless(cl_l5 in p, "cl_l5 is missing")
2479            self.failUnless(s5 in p, "s5 is missing")
2480            self.failUnless(cl_l6 in p, "cl_l6 is missing")
2481            self.failUnless(s6 in p, "s6 is missing")
2482            self.failUnless(cl_m7 in p, "cl_m7 is missing")
2483            self.failUnless(s7 in p, "s7 is missing")
2484            self.failUnless(cl_m8 in p, "cl_m8 is missing")
2485            self.failUnless(s8 in p, "s8 is missing")
2486            self.failUnless(cl_m9 in p, "cl_m9 is missing")
2487            self.failUnless(s9 in p, "s9 is missing")
2488            self.failUnless(cl_m10 in p, "cl_m10 is missing")
2489            self.failUnless(s10 in p, "s10 is missing")
2490    
2491            cp=s.copy()
2492            self.failUnless(isinstance(cp,SurfaceLoop), "copy returns is not an arc.")
2493            self.failUnless(not cp == s, "copy equals source")
2494            self.failUnless(cp.isColocated(s),"copy is not colocated with its source.")
2495            cc=cp.getSurfaces()
2496            self.failUnless(len(cc) == 10, "too many primitives in copy.")
2497            self.failUnless(not s1 in cc,"copy uses s1.")
2498            self.failUnless(not s2 in cc,"copy uses s2.")
2499            self.failUnless(not s3 in cc,"copy uses s3.")
2500            self.failUnless(not s4 in cc,"copy uses s4.")
2501            self.failUnless(not s5 in cc,"copy uses s5.")
2502            self.failUnless(not s6 in cc,"copy uses s6.")
2503            self.failUnless(not s7 in cc,"copy uses s7.")
2504            self.failUnless(not s8 in cc,"copy uses s8.")
2505            self.failUnless(not s9 in cc,"copy uses s9.")
2506            self.failUnless(not s10 in cc,"copy uses s10.")
2507    
2508            #=================================================================================
2509            p0_m=Point( 0, 0, 0,0.1)
2510            p1_m=Point(-10, 0, 0,0.1)
2511            p2_m=Point( 0,-10, 0,0.1)
2512            p3_m=Point(-10,-10, 0,0.1)
2513            p4_m=Point( 0, 0,-10,0.1)
2514            p5_m=Point(-10, 0,-10,0.1)
2515            p6_m=Point( 0,-10,-10,0.1)
2516            p7_m=Point(-10,-10,-10,0.1)
2517            q0_m=Point( -4, 0, -4,0.1)
2518            q1_m=Point( -6, 0, -4,0.1)
2519            q2_m=Point( -4,-10, -4,0.1)
2520            q3_m=Point( -6,-10, -4,0.1)
2521            q4_m=Point( -4, 0, -6,0.1)
2522            q5_m=Point( -6, 0, -6,0.1)
2523            q6_m=Point( -4,-10, -6,0.1)
2524            q7_m=Point( -6,-10, -6,0.1)
2525            l01_m=Line(p0_m,p1_m)
2526            l15_m=Line(p1_m,p5_m)
2527            l54_m=Line(p5_m,p4_m)
2528            l04_m=Line(p4_m,p0_m)
2529            l13_m=Line(p1_m,p3_m)
2530            l37_m=Line(p3_m,p7_m)
2531            l75_m=Line(p7_m,p5_m)
2532            l67_m=Line(p6_m,p7_m)
2533            l26_m=Line(p2_m,p6_m)
2534            l32_m=Line(p3_m,p2_m)
2535            l20_m=Line(p2_m,p0_m)
2536            l46_m=Line(p4_m,p6_m)
2537            m01_m=Line(q0_m,q1_m)
2538            m15_m=Line(q1_m,q5_m)
2539            m54_m=Line(q5_m,q4_m)
2540            m40_m=Line(q4_m,q0_m)
2541            m23_m=Line(q2_m,q3_m)
2542            m37_m=Line(q3_m,q7_m)
2543            m76_m=Line(q7_m,q6_m)
2544            m62_m=Line(q6_m,q2_m)
2545            m02_m=Line(q0_m,q2_m)
2546            m13_m=Line(q1_m,q3_m)
2547            m46_m=Line(q4_m,q6_m)
2548            m57_m=Line(q5_m,q7_m)
2549            cl_l1_m=CurveLoop(l01_m,l15_m,l54_m,l04_m)
2550            cl_m1_m=CurveLoop(m01_m,m15_m,m54_m,m40_m)
2551            s1_m=PlaneSurface(cl_l1_m,holes=[cl_m1_m])
2552            cl_l2_m=CurveLoop(-l15_m,l13_m,l37_m,l75_m)
2553            s2_m=PlaneSurface(cl_l2_m)
2554            cl_l3_m=CurveLoop(l32_m,-l37_m,l67_m,l26_m)
2555            cl_m3_m=CurveLoop(-m23_m,-m37_m,-m76_m,-m62_m)
2556            s3_m=PlaneSurface(cl_l3_m,holes=[cl_m3_m])
2557            cl_l4_m=CurveLoop(l20_m,-l26_m,l46_m,-l04_m)
2558            s4_m=PlaneSurface(cl_l4_m)
2559            cl_l5_m=CurveLoop(l32_m,l20_m,l01_m,l13_m)
2560            s5_m=PlaneSurface(-cl_l5_m)
2561            cl_l6_m=CurveLoop(l67_m,l75_m,l54_m,l46_m)
2562            s6_m=PlaneSurface(-cl_l6_m)
2563            cl_m7_m=CurveLoop(m13_m,m37_m,-m57_m,-m15_m)
2564            s7_m=PlaneSurface(cl_m7_m)
2565            cl_m8_m=CurveLoop(m57_m,m76_m,-m46_m,-m54_m)
2566            s8_m=PlaneSurface(cl_m8_m)
2567            cl_m9_m=CurveLoop(m46_m,m62_m,-m02_m,-m40_m)
2568            s9_m=PlaneSurface(cl_m9_m)
2569            cl_m10_m=CurveLoop(-m01_m,m02_m,m23_m,-m13_m)
2570            s10_m=PlaneSurface(cl_m10_m)
2571            s_m=SurfaceLoop(s1_m,s2_m,s3_m,s4_m,s5_m,s6_m,-s7_m,-s8_m,-s9_m,-s10_m)
2572            #_m=================================================================================
2573            dc=s.apply(Dilation(-1.))
2574            self.failUnless(dc.isColocated(s_m),"dilation is wrong.")
2575            cc=dc.getSurfaces()
2576            self.failUnless(len(cc) == 10, "too many surfaces in copy.")
2577            self.failUnless(not s1 in cc,"dilation uses s1.")
2578            self.failUnless(not s2 in cc,"dilation uses s2.")
2579            self.failUnless(not s3 in cc,"dilation uses s3.")
2580            self.failUnless(not s4 in cc,"dilation uses s4.")
2581            self.failUnless(not s5 in cc,"dilation uses s5.")
2582            self.failUnless(not s6 in cc,"dilation uses s6.")
2583            self.failUnless(not s7 in cc,"dilation uses s7.")
2584            self.failUnless(not s8 in cc,"dilation uses s8.")
2585            self.failUnless(not s9 in cc,"dilation uses s9.")
2586            self.failUnless(not s10 in cc,"dilation uses s10.")
2587    
2588            s.modifyBy(Dilation(-1.))
2589            self.failUnless(s.isColocated(s_m),"inplace dilation is wrong.")
2590            cc=s.getSurfaces()
2591            self.failUnless(len(cc) == 10, "too many primitives in modified object.")
2592            self.failUnless(s1 in cc,"dilation misses s1.")
2593            self.failUnless(cc[cc.index(s1)].hasSameOrientation(s1),"s1 in modified object has wrong orientation.")
2594            self.failUnless(s1.isColocated(s1_m),"s1 in modified object as wrong location.")
2595            self.failUnless(s2 in cc,"dilation misses s2.")
2596            self.failUnless(cc[cc.index(s2)].hasSameOrientation(s2),"s2 in modified object has wrong orientation.")
2597            self.failUnless(s2.isColocated(s2_m),"s2 in modified object as wrong location.")
2598            self.failUnless(s3 in cc,"dilation misses s3.")
2599            self.failUnless(cc[cc.index(s3)].hasSameOrientation(s3),"s3 in modified object has wrong orientation.")
2600            self.failUnless(s3.isColocated(s3_m),"s3 in modified object as wrong location.")
2601            self.failUnless(s4 in cc,"dilation misses s4.")
2602            self.failUnless(cc[cc.index(s4)].hasSameOrientation(s4),"s4 in modified object has wrong orientation.")
2603            self.failUnless(s4.isColocated(s4_m),"s4 in modified object as wrong location.")
2604            self.failUnless(s5 in cc,"dilation misses s5.")
2605            self.failUnless(cc[cc.index(s5)].hasSameOrientation(s5),"s5 in modified object has wrong orientation.")
2606            self.failUnless(s5.isColocated(s5_m),"s5 in modified object as wrong location.")
2607            self.failUnless(s6 in cc,"dilation misses s6.")
2608            self.failUnless(cc[cc.index(s6)].hasSameOrientation(s6),"s6 in modified object has wrong orientation.")
2609            self.failUnless(s6.isColocated(s6_m),"s6 in modified object as wrong location.")
2610            self.failUnless(s7 in cc,"dilation misses s7.")
2611            self.failUnless(cc[cc.index(s7)].hasSameOrientation(-s7),"s7 in modified object has wrong orientation.")
2612            self.failUnless(s7.isColocated(s7_m),"s7 in modified object as wrong location.")
2613            self.failUnless(s8 in cc,"dilation misses s8.")
2614            self.failUnless(cc[cc.index(s8)].hasSameOrientation(-s8),"s8 in modified object has wrong orientation.")
2615            self.failUnless(s8.isColocated(s8_m),"s8 in modified object as wrong location.")
2616            self.failUnless(s9 in cc,"dilation misses s9.")
2617            self.failUnless(cc[cc.index(s9)].hasSameOrientation(-s9),"s9 in modified object has wrong orientation.")
2618            self.failUnless(s9.isColocated(s9_m),"s9 in modified object as wrong location.")
2619            self.failUnless(s10 in cc,"dilation misses s10.")
2620            self.failUnless(cc[cc.index(s10)].hasSameOrientation(-s10),"s10 in modified object has wrong orientation.")
2621            self.failUnless(s10.isColocated(s10_m),"s10 in modified object as wrong location.")
2622    
2623       def test_ReverseSurfaceLoop(self):
2624            p0=Point( 0, 0, 0,0.1)
2625            p1=Point(10, 0, 0,0.1)
2626            p2=Point( 0,10, 0,0.1)
2627            p3=Point(10,10, 0,0.1)
2628            p4=Point( 0, 0,10,0.1)
2629            p5=Point(10, 0,10,0.1)
2630            p6=Point( 0,10,10,0.1)
2631            p7=Point(10,10,10,0.1)
2632    
2633            q0=Point( 4, 0, 4,0.1)
2634            q1=Point( 6, 0, 4,0.1)
2635            q2=Point( 4,10, 4,0.1)
2636            q3=Point( 6,10, 4,0.1)
2637            q4=Point( 4, 0, 6,0.1)
2638            q5=Point( 6, 0, 6,0.1)
2639            q6=Point( 4,10, 6,0.1)
2640            q7=Point( 6,10, 6,0.1)
2641    
2642            l01=Line(p0,p1)
2643            l15=Line(p1,p5)
2644            l54=Line(p5,p4)
2645            l04=Line(p4,p0)
2646    
2647            l13=Line(p1,p3)
2648            l37=Line(p3,p7)
2649            l75=Line(p7,p5)
2650            l67=Line(p6,p7)
2651            l26=Line(p2,p6)
2652            l32=Line(p3,p2)
2653            l20=Line(p2,p0)
2654            l46=Line(p4,p6)
2655    
2656            m01=Line(q0,q1)
2657            m15=Line(q1,q5)
2658            m54=Line(q5,q4)
2659            m40=Line(q4,q0)
2660            m23=Line(q2,q3)
2661            m37=Line(q3,q7)
2662            m76=Line(q7,q6)
2663            m62=Line(q6,q2)
2664    
2665            m02=Line(q0,q2)
2666            m13=Line(q1,q3)
2667            m46=Line(q4,q6)
2668            m57=Line(q5,q7)
2669    
2670            cl_l1=CurveLoop(l01,l15,l54,l04)
2671            cl_m1=CurveLoop(m01,m15,m54,m40)
2672            s1=PlaneSurface(cl_l1,holes=[cl_m1])
2673            s1_v=PlaneSurface(cl_l1)
2674    
2675            cl_l2=CurveLoop(-l15,l13,l37,l75)
2676            s2=PlaneSurface(cl_l2)
2677    
2678            cl_l3=CurveLoop(l32,-l37,l67,l26)
2679            cl_m3=CurveLoop(-m23,-m37,-m76,-m62)
2680            s3=PlaneSurface(cl_l3,holes=[cl_m3])
2681            s3_v=PlaneSurface(cl_l3)
2682        
2683        
2684            cl_l4=CurveLoop(l20,-l26,l46,-l04)
2685            s4=PlaneSurface(cl_l4)
2686    
2687            cl_l5=CurveLoop(l32,l20,l01,l13)
2688            s5=PlaneSurface(-cl_l5)
2689    
2690            cl_l6=CurveLoop(l67,l75,l54,l46)
2691            s6=PlaneSurface(-cl_l6)
2692    
2693            cl_m7=CurveLoop(m13,m37,-m57,-m15)
2694            s7=PlaneSurface(cl_m7)
2695            
2696            cl_m8=CurveLoop(m57,m76,-m46,-m54)
2697            s8=PlaneSurface(cl_m8)
2698    
2699            cl_m9=CurveLoop(m46,m62,-m02,-m40)
2700            s9=PlaneSurface(cl_m9)
2701    
2702            cl_m10=CurveLoop(-m01,m02,m23,-m13)
2703            s10=PlaneSurface(cl_m10)
2704    
2705            self.failUnlessRaises(ValueError,SurfaceLoop,s1,s3)
2706            self.failUnlessRaises(ValueError,SurfaceLoop,s1,s2,s3,s4,s5)
2707            self.failUnlessRaises(ValueError,SurfaceLoop,s1,s2,s3,s4,s5,s5)
2708    
2709            
2710            CC0=SurfaceLoop(s1,s2,s3,s4,s5,s6,-s7,-s8,-s9,-s10)
2711            s=-CC0
2712    
2713            self.failUnless(s.hasSameOrientation(s),"has not same orientation like itself")
2714            self.failUnless(not s.hasSameOrientation(-s),"has same orientation like -itself")
2715    
2716            cc=s.getSurfaces()
2717            self.failUnless(len(cc) == 10, "too many curves.")
2718            self.failUnless(s1 in cc, "s1 is missing")
2719            self.failUnless(s2 in cc, "s2 is missing")
2720            self.failUnless(s3 in cc, "s3 is missing")
2721            self.failUnless(s4 in cc, "s4 is missing")
2722            self.failUnless(s5 in cc, "s5 is missing")
2723            self.failUnless(s6 in cc, "s6 is missing")
2724            self.failUnless(s7 in cc, "s7 is missing")
2725            self.failUnless(s8 in cc, "s8 is missing")
2726            self.failUnless(s9 in cc, "s9 is missing")
2727            self.failUnless(s10 in cc, "s10 is missing")
2728    
2729            code=s.getGmshCommand()
2730            self.failUnless(code == "Surface Loop(68) = {43, 46, 49, 52, 54, 56, -58, -60, -62, -64};", "gmsh command wrong.")
2731    
2732            self.failUnless(not s.isColocated(p4),"SurfaceLoop is colocated with point.")
2733            self.failUnless(s.isColocated(s),"SurfaceLoop is not colocated with its self.")
2734            self.failUnless(s.isColocated(-s),"SurfaceLoop is not colocated with its reverse.")
2735            self.failUnless(s.isColocated(SurfaceLoop(s1,s2,s3,s4,s5,s6,-s7,-s8,-s9,-s10)),"SurfaceLoop is not colocated with its copy.")
2736            self.failUnless(s.isColocated(SurfaceLoop(-s10, s1,s2,s3,s4,s5,s6,-s7,-s8,-s9)),"SurfaceLoop is not colocated with its copy with shifted points.")
2737            self.failUnless(s.isColocated(SurfaceLoop(s1, -s7, s2, -s9, s3, -s8, s4, -s10, s5,s6)),"SurfaceLoop is not colocated with its copy with shuffled points.")
2738            self.failUnless(not s.isColocated(SurfaceLoop(s1_v,s2,s3_v,s4,s5,s6)),"SurfaceLoop is colocated with different SurfaceLoop.")
2739    
2740            self.failUnless(len(s) == 10, "wrong length")
2741    
2742            s.setLocalScale(3.)
2743            self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
2744            self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
2745            self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
2746            self.failUnless(p3.getLocalScale()==3., "p3 has wrong local scale.")
2747            self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
2748            self.failUnless(p5.getLocalScale()==3., "p5 has wrong local scale.")
2749            self.failUnless(p6.getLocalScale()==3., "p6 has wrong local scale.")
2750            self.failUnless(p7.getLocalScale()==3., "p7 has wrong local scale.")
2751    
2752            p=s.getPrimitives()
2753            self.failUnless(len(p) == 63, "too many primitives.")
2754            self.failUnless(s in p, "s is missing")
2755            self.failUnless(p0 in p, "p0 is missing")
2756            self.failUnless(p1 in p, "p1 is missing")
2757            self.failUnless(p2 in p, "p2 is missing")
2758            self.failUnless(p3 in p, "p3 is missing")
2759            self.failUnless(p4 in p, "p4 is missing")
2760            self.failUnless(p5 in p, "p5 is missing")
2761            self.failUnless(p6 in p, "p6 is missing")
2762            self.failUnless(p7 in p, "p7 is missing")
2763            self.failUnless(q0 in p, "q0 is missing")
2764            self.failUnless(q1 in p, "q1 is missing")
2765            self.failUnless(q2 in p, "q2 is missing")
2766            self.failUnless(q3 in p, "q3 is missing")
2767            self.failUnless(q4 in p, "q4 is missing")
2768            self.failUnless(q5 in p, "q5 is missing")
2769            self.failUnless(q6 in p, "q6 is missing")
2770            self.failUnless(q7 in p, "q7 is missing")
2771            self.failUnless(l01 in p, "l01 is missing")
2772            self.failUnless(l15 in p, "l15 is missing")
2773            self.failUnless(l54 in p, "l54 is missing")
2774            self.failUnless(l04 in p, "l04 is missing")
2775            self.failUnless(l13 in p, "l13 is missing")
2776            self.failUnless(l37 in p, "l37 is missing")
2777            self.failUnless(l75 in p, "l75 is missing")
2778            self.failUnless(l67 in p, "l67 is missing")
2779            self.failUnless(l26 in p, "l26 is missing")
2780            self.failUnless(l32 in p, "l32 is missing")
2781            self.failUnless(l20 in p, "l20 is missing")
2782            self.failUnless(l46 in p, "l46 is missing")
2783            self.failUnless(m01 in p, "m01 is missing")
2784            self.failUnless(m15 in p, "m15 is missing")
2785            self.failUnless(m54 in p, "m54 is missing")
2786            self.failUnless(m40 in p, "m40 is missing")
2787            self.failUnless(m23 in p, "m23 is missing")
2788            self.failUnless(m37 in p, "m37 is missing")
2789            self.failUnless(m76 in p, "m76 is missing")
2790            self.failUnless(m62 in p, "m62 is missing")
2791            self.failUnless(m02 in p, "m02 is missing")
2792            self.failUnless(m13 in p, "m13 is missing")
2793            self.failUnless(m46 in p, "m46 is missing")
2794            self.failUnless(m57 in p, "m57 is missing")
2795            self.failUnless(cl_l1 in p, "cl_l1 is missing")
2796            self.failUnless(cl_m1 in p, "cl_m1 is missing")
2797            self.failUnless(s1 in p, "s1 is missing")
2798            self.failUnless(cl_l2 in p, "cl_l2 is missing")
2799            self.failUnless(s2 in p, "s2 is missing")
2800            self.failUnless(cl_l3 in p, "cl_l3 is missing")
2801            self.failUnless(cl_m3 in p, "cl_m3 is missing")
2802            self.failUnless(s3 in p, "s3 is missing")
2803            self.failUnless(cl_l4 in p, "cl_l4 is missing")
2804            self.failUnless(s4 in p, "s4 is missing")
2805            self.failUnless(cl_l5 in p, "cl_l5 is missing")
2806            self.failUnless(s5 in p, "s5 is missing")
2807            self.failUnless(cl_l6 in p, "cl_l6 is missing")
2808            self.failUnless(s6 in p, "s6 is missing")
2809            self.failUnless(cl_m7 in p, "cl_m7 is missing")
2810            self.failUnless(s7 in p, "s7 is missing")
2811            self.failUnless(cl_m8 in p, "cl_m8 is missing")
2812            self.failUnless(s8 in p, "s8 is missing")
2813            self.failUnless(cl_m9 in p, "cl_m9 is missing")
2814            self.failUnless(s9 in p, "s9 is missing")
2815            self.failUnless(cl_m10 in p, "cl_m10 is missing")
2816            self.failUnless(s10 in p, "s10 is missing")
2817    
2818            cp=s.copy()
2819            self.failUnless(isinstance(cp,ReverseSurfaceLoop), "copy returns is not ReverseSurfaceLoop.")
2820            self.failUnless(not cp == s, "copy equals source")
2821            self.failUnless(cp.isColocated(s),"copy is not colocated with its source.")
2822            cc=cp.getSurfaces()
2823            self.failUnless(len(cc) == 10, "too many primitives in copy.")
2824            self.failUnless(not s1 in cc,"copy uses s1.")
2825            self.failUnless(not s2 in cc,"copy uses s2.")
2826            self.failUnless(not s3 in cc,"copy uses s3.")
2827            self.failUnless(not s4 in cc,"copy uses s4.")
2828            self.failUnless(not s5 in cc,"copy uses s5.")
2829            self.failUnless(not s6 in cc,"copy uses s6.")
2830            self.failUnless(not s7 in cc,"copy uses s7.")
2831            self.failUnless(not s8 in cc,"copy uses s8.")
2832            self.failUnless(not s9 in cc,"copy uses s9.")
2833            self.failUnless(not s10 in cc,"copy uses s10.")
2834    
2835            #=================================================================================
2836            p0_m=Point( 0, 0, 0,0.1)
2837            p1_m=Point(-10, 0, 0,0.1)
2838            p2_m=Point( 0,-10, 0,0.1)
2839            p3_m=Point(-10,-10, 0,0.1)
2840            p4_m=Point( 0, 0,-10,0.1)
2841            p5_m=Point(-10, 0,-10,0.1)
2842            p6_m=Point( 0,-10,-10,0.1)
2843            p7_m=Point(-10,-10,-10,0.1)
2844            q0_m=Point( -4, 0, -4,0.1)
2845            q1_m=Point( -6, 0, -4,0.1)
2846            q2_m=Point( -4,-10, -4,0.1)
2847            q3_m=Point( -6,-10, -4,0.1)
2848            q4_m=Point( -4, 0, -6,0.1)
2849            q5_m=Point( -6, 0, -6,0.1)
2850            q6_m=Point( -4,-10, -6,0.1)
2851            q7_m=Point( -6,-10, -6,0.1)
2852            l01_m=Line(p0_m,p1_m)
2853            l15_m=Line(p1_m,p5_m)
2854            l54_m=Line(p5_m,p4_m)
2855            l04_m=Line(p4_m,p0_m)
2856            l13_m=Line(p1_m,p3_m)
2857            l37_m=Line(p3_m,p7_m)
2858            l75_m=Line(p7_m,p5_m)
2859            l67_m=Line(p6_m,p7_m)
2860            l26_m=Line(p2_m,p6_m)
2861            l32_m=Line(p3_m,p2_m)
2862            l20_m=Line(p2_m,p0_m)
2863            l46_m=Line(p4_m,p6_m)
2864            m01_m=Line(q0_m,q1_m)
2865            m15_m=Line(q1_m,q5_m)
2866            m54_m=Line(q5_m,q4_m)
2867            m40_m=Line(q4_m,q0_m)
2868            m23_m=Line(q2_m,q3_m)
2869            m37_m=Line(q3_m,q7_m)
2870            m76_m=Line(q7_m,q6_m)
2871            m62_m=Line(q6_m,q2_m)
2872            m02_m=Line(q0_m,q2_m)
2873            m13_m=Line(q1_m,q3_m)
2874            m46_m=Line(q4_m,q6_m)
2875            m57_m=Line(q5_m,q7_m)
2876            cl_l1_m=CurveLoop(l01_m,l15_m,l54_m,l04_m)
2877            cl_m1_m=CurveLoop(m01_m,m15_m,m54_m,m40_m)
2878            s1_m=PlaneSurface(cl_l1_m,holes=[cl_m1_m])
2879            cl_l2_m=CurveLoop(-l15_m,l13_m,l37_m,l75_m)
2880            s2_m=PlaneSurface(cl_l2_m)
2881            cl_l3_m=CurveLoop(l32_m,-l37_m,l67_m,l26_m)
2882            cl_m3_m=CurveLoop(-m23_m,-m37_m,-m76_m,-m62_m)
2883            s3_m=PlaneSurface(cl_l3_m,holes=[cl_m3_m])
2884            cl_l4_m=CurveLoop(l20_m,-l26_m,l46_m,-l04_m)
2885            s4_m=PlaneSurface(cl_l4_m)
2886            cl_l5_m=CurveLoop(l32_m,l20_m,l01_m,l13_m)
2887            s5_m=PlaneSurface(-cl_l5_m)
2888            cl_l6_m=CurveLoop(l67_m,l75_m,l54_m,l46_m)
2889            s6_m=PlaneSurface(-cl_l6_m)
2890            cl_m7_m=CurveLoop(m13_m,m37_m,-m57_m,-m15_m)
2891            s7_m=PlaneSurface(cl_m7_m)
2892            cl_m8_m=CurveLoop(m57_m,m76_m,-m46_m,-m54_m)
2893            s8_m=PlaneSurface(cl_m8_m)
2894            cl_m9_m=CurveLoop(m46_m,m62_m,-m02_m,-m40_m)
2895            s9_m=PlaneSurface(cl_m9_m)
2896            cl_m10_m=CurveLoop(-m01_m,m02_m,m23_m,-m13_m)
2897            s10_m=PlaneSurface(cl_m10_m)
2898            s_m=SurfaceLoop(s1_m,s2_m,s3_m,s4_m,s5_m,s6_m,-s7_m,-s8_m,-s9_m,-s10_m)
2899            #_m=================================================================================
2900            dc=s.apply(Dilation(-1.))
2901            self.failUnless(dc.isColocated(s_m),"dilation is wrong.")
2902            cc=dc.getSurfaces()
2903            self.failUnless(len(cc) == 10, "too many surfaces in copy.")
2904            self.failUnless(not s1 in cc,"dilation uses s1.")
2905            self.failUnless(not s2 in cc,"dilation uses s2.")
2906            self.failUnless(not s3 in cc,"dilation uses s3.")
2907            self.failUnless(not s4 in cc,"dilation uses s4.")
2908            self.failUnless(not s5 in cc,"dilation uses s5.")
2909            self.failUnless(not s6 in cc,"dilation uses s6.")
2910            self.failUnless(not s7 in cc,"dilation uses s7.")
2911            self.failUnless(not s8 in cc,"dilation uses s8.")
2912            self.failUnless(not s9 in cc,"dilation uses s9.")
2913            self.failUnless(not s10 in cc,"dilation uses s10.")
2914    
2915            s.modifyBy(Dilation(-1.))
2916            self.failUnless(s.isColocated(s_m),"inplace dilation is wrong.")
2917            cc=s.getSurfaces()
2918            self.failUnless(len(cc) == 10, "too many primitives in modified object.")
2919            self.failUnless(s1 in cc,"dilation misses s1.")
2920            self.failUnless(cc[cc.index(s1)].hasSameOrientation(-s1),"s1 in modified object has wrong orientation.")
2921            self.failUnless(s1.isColocated(s1_m),"s1 in modified object as wrong location.")
2922            self.failUnless(s2 in cc,"dilation misses s2.")
2923            self.failUnless(cc[cc.index(s2)].hasSameOrientation(-s2),"s2 in modified object has wrong orientation.")
2924            self.failUnless(s2.isColocated(s2_m),"s2 in modified object as wrong location.")
2925            self.failUnless(s3 in cc,"dilation misses s3.")
2926            self.failUnless(cc[cc.index(s3)].hasSameOrientation(-s3),"s3 in modified object has wrong orientation.")
2927            self.failUnless(s3.isColocated(s3_m),"s3 in modified object as wrong location.")
2928            self.failUnless(s4 in cc,"dilation misses s4.")
2929            self.failUnless(cc[cc.index(s4)].hasSameOrientation(-s4),"s4 in modified object has wrong orientation.")
2930            self.failUnless(s4.isColocated(s4_m),"s4 in modified object as wrong location.")
2931            self.failUnless(s5 in cc,"dilation misses s5.")
2932            self.failUnless(cc[cc.index(s5)].hasSameOrientation(-s5),"s5 in modified object has wrong orientation.")
2933            self.failUnless(s5.isColocated(s5_m),"s5 in modified object as wrong location.")
2934            self.failUnless(s6 in cc,"dilation misses s6.")
2935            self.failUnless(cc[cc.index(s6)].hasSameOrientation(-s6),"s6 in modified object has wrong orientation.")
2936            self.failUnless(s6.isColocated(s6_m),"s6 in modified object as wrong location.")
2937            self.failUnless(s7 in cc,"dilation misses s7.")
2938            self.failUnless(cc[cc.index(s7)].hasSameOrientation(s7),"s7 in modified object has wrong orientation.")
2939            self.failUnless(s7.isColocated(s7_m),"s7 in modified object as wrong location.")
2940            self.failUnless(s8 in cc,"dilation misses s8.")
2941            self.failUnless(cc[cc.index(s8)].hasSameOrientation(s8),"s8 in modified object has wrong orientation.")
2942            self.failUnless(s8.isColocated(s8_m),"s8 in modified object as wrong location.")
2943            self.failUnless(s9 in cc,"dilation misses s9.")
2944            self.failUnless(cc[cc.index(s9)].hasSameOrientation(s9),"s9 in modified object has wrong orientation.")
2945            self.failUnless(s9.isColocated(s9_m),"s9 in modified object as wrong location.")
2946            self.failUnless(s10 in cc,"dilation misses s10.")
2947            self.failUnless(cc[cc.index(s10)].hasSameOrientation(s10),"s10 in modified object has wrong orientation.")
2948            self.failUnless(s10.isColocated(s10_m),"s10 in modified object as wrong location.")
2949    
2950       def test_Volume(self):
2951            p0=Point(-2,-2,-2,0.1)
2952            p1=Point(2,-2,-2,0.1)
2953            p2=Point(-2,2,-2,0.1)
2954            p3=Point(2,2,-2,0.1)
2955            p4=Point(-2,-2,2,0.1)
2956            p5=Point(2,-2,2,0.1)
2957            p6=Point(-2,2,2,0.1)
2958            p7=Point(2,2,2,0.1)
2959            l01=Line(p0,p1)
2960            l15=Line(p1,p5)
2961            l54=Line(p5,p4)
2962            l40=Line(p4,p0)
2963            l23=Line(p2,p3)
2964            l37=Line(p3,p7)
2965            l76=Line(p7,p6)
2966            l62=Line(p6,p2)
2967            l13=Line(p1,p3)
2968            l57=Line(p5,p7)
2969            l02=Line(p0,p2)
2970            l46=Line(p4,p6)
2971            cl1=CurveLoop(l01,l15,l54,l40)
2972            s1=PlaneSurface(cl1)
2973            cl2=CurveLoop(l23,l37,l76,l62)
2974            s2=PlaneSurface(-cl2)
2975            cl3=CurveLoop(l13,l37,-l57,-l15)
2976            s3=PlaneSurface(cl3)
2977            cl4=CurveLoop(l46,l62,-l02,-l40)
2978            s4=PlaneSurface(-cl4)
2979            cl5=CurveLoop(-l01,l02,l23,-l13)
2980            s5=PlaneSurface(-cl5)
2981            cl6=CurveLoop(-l54,l57,l76,-l46)
2982            s6=PlaneSurface(-cl6)
2983            s_out=SurfaceLoop(s1,s2,s3,s4,s5,s6)
2984    
2985            p0_i=Point(-1,-1,-1,0.1)
2986            p1_i=Point(1,-1,-1,0.1)
2987            p2_i=Point(-1,1,-1,0.1)
2988            p3_i=Point(1,1,-1,0.1)
2989            p4_i=Point(-1,-1,1,0.1)
2990            p5_i=Point(1,-1,1,0.1)
2991            p6_i=Point(-1,1,1,0.1)
2992            p7_i=Point(1,1,1,0.1)
2993            l01_i=Line(p0_i,p1_i)
2994            l15_i=Line(p1_i,p5_i)
2995            l54_i=Line(p5_i,p4_i)
2996            l40_i=Line(p4_i,p0_i)
2997            l23_i=Line(p2_i,p3_i)
2998            l37_i=Line(p3_i,p7_i)
2999            l76_i=Line(p7_i,p6_i)
3000            l62_i=Line(p6_i,p2_i)
3001            l13_i=Line(p1_i,p3_i)
3002            l57_i=Line(p5_i,p7_i)
3003            l02_i=Line(p0_i,p2_i)
3004            l46_i=Line(p4_i,p6_i)
3005            cl1_i=CurveLoop(l01_i,l15_i,l54_i,l40_i)
3006            s1_i=PlaneSurface(cl1_i)
3007            cl2_i=CurveLoop(l23_i,l37_i,l76_i,l62_i)
3008            s2_i=PlaneSurface(-cl2_i)
3009            cl3_i=CurveLoop(l13_i,l37_i,-l57_i,-l15_i)
3010            s3_i=PlaneSurface(cl3_i)
3011            cl4_i=CurveLoop(l46_i,l62_i,-l02_i,-l40_i)
3012            s4_i=PlaneSurface(-cl4_i)
3013            cl5_i=CurveLoop(-l01_i,l02_i,l23_i,-l13_i)
3014            s5_i=PlaneSurface(-cl5_i)
3015            cl6_i=CurveLoop(-l54_i,l57_i,l76_i,-l46_i)
3016            s6_i=PlaneSurface(-cl6_i)
3017            s_inner=SurfaceLoop(s1_i,s2_i,s3_i,s4_i,s5_i,s6_i)
3018    
3019    
3020            self.failUnlessRaises(TypeError,Volume,s1)
3021            self.failUnlessRaises(TypeError,Volume,s_out,[s1])
3022            v=Volume(s_out,holes=[s_inner])
3023    
3024            self.failUnlessRaises(NotImplementedError,v.__neg__)
3025            
3026            cl2=v.getSurfaceLoop()
3027            self.failUnless(s_out == cl2, " wrong boundary loops")
3028            self.failUnless(s_out.hasSameOrientation(cl2),"cl has incorrect orientation.")
3029    
3030            hs=v.getHoles()
3031            self.failUnless(len(hs) == 1, "one holes expected.")
3032            self.failUnless(s_inner==hs[0], "h is not defined as hole.")
3033            self.failUnless(hs[0].hasSameOrientation(s_inner),"hs has incorrect orientation.")
3034    
3035            cc=v.getBoundary()
3036            self.failUnless(len(cc) == 12, "too many curves.")
3037            self.failUnless(s1 in cc, "s1 is missing")
3038            self.failUnless(s2 in cc, "s2 is missing")
3039            self.failUnless(s3 in cc, "s3 is missing")
3040            self.failUnless(s4 in cc, "s4 is missing")
3041            self.failUnless(s5 in cc, "s5 is missing")
3042            self.failUnless(s6 in cc, "s6 is missing")
3043            self.failUnless(s1_i in cc, "s1_i is missing")
3044            self.failUnless(s2_i in cc, "s2_i is missing")
3045            self.failUnless(s3_i in cc, "s3_i is missing")
3046            self.failUnless(s4_i in cc, "s4_i is missing")
3047            self.failUnless(s5_i in cc, "s5_i is missing")
3048            self.failUnless(s6_i in cc, "s6_i is missing")
3049    
3050            code=v.getGmshCommand()
3051            self.failUnless(code == "Volume(67) = {33, 66};", "gmsh command wrong.")
3052    
3053            self.failUnless(not v.isColocated(p4),"Volume is colocated with point.")
3054            self.failUnless(v.isColocated(v),"Volume is not colocated with its self.")
3055            self.failUnless(v.isColocated(Volume(s_out,holes=[s_inner])),"Volume is not colocated with its copy.")
3056            self.failUnless(not v.isColocated(Volume(s_out,holes=[0.3*s_inner])),"Volume is not colocated with volume of modifies volume .")
3057    
3058            v.setLocalScale(3.)
3059            self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
3060            self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
3061            self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
3062            self.failUnless(p3.getLocalScale()==3., "p3 has wrong local scale.")
3063            self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
3064            self.failUnless(p5.getLocalScale()==3., "p5 has wrong local scale.")
3065            self.failUnless(p6.getLocalScale()==3., "p6 has wrong local scale.")
3066            self.failUnless(p7.getLocalScale()==3., "p7 has wrong local scale.")
3067            self.failUnless(p0_i.getLocalScale()==3., "p0_i has wrong local scale.")
3068            self.failUnless(p1_i.getLocalScale()==3., "p1_i has wrong local scale.")
3069            self.failUnless(p2_i.getLocalScale()==3., "p2_i has wrong local scale.")
3070            self.failUnless(p3_i.getLocalScale()==3., "p3_i has wrong local scale.")
3071            self.failUnless(p4_i.getLocalScale()==3., "p4_i has wrong local scale.")
3072            self.failUnless(p5_i.getLocalScale()==3., "p5_i has wrong local scale.")
3073            self.failUnless(p6_i.getLocalScale()==3., "p6_i has wrong local scale.")
3074            self.failUnless(p7_i.getLocalScale()==3., "p7_i has wrong local scale.")
3075    
3076            p=v.getPrimitives()
3077            self.failUnless(len(p) == 67, "too many primitives.")
3078            self.failUnless(v in p, "v is missing")
3079            self.failUnless(p0 in p, "p0 is missing")
3080            self.failUnless(p1 in p, "p1 is missing")
3081            self.failUnless(p2 in p, "p2 is missing")
3082            self.failUnless(p3 in p, "p3 is missing")
3083            self.failUnless(p4 in p, "p4 is missing")
3084            self.failUnless(p5 in p, "p5 is missing")
3085            self.failUnless(p6 in p, "p6 is missing")
3086            self.failUnless(p7 in p, "p7 is missing")
3087            self.failUnless(l01 in p, "l01 is missing")
3088            self.failUnless(l15 in p, "l15 is missing")
3089            self.failUnless(l54 in p, "l54 is missing")
3090            self.failUnless(l40 in p, "l40 is missing")
3091            self.failUnless(l23 in p, "l23 is missing")
3092            self.failUnless(l37 in p, "l37 is missing")
3093            self.failUnless(l76 in p, "l76 is missing")
3094            self.failUnless(l62 in p, "l62 is missing")
3095            self.failUnless(l13 in p, "l13 is missing")
3096            self.failUnless(l57 in p, "l57 is missing")
3097            self.failUnless(l02 in p, "l02 is missing")
3098            self.failUnless(l46 in p, "l46 is missing")
3099            self.failUnless(cl1 in p, "cl1 is missing")
3100            self.failUnless(s1 in p, "s1 is missing")
3101            self.failUnless(cl2 in p, "cl2 is missing")
3102            self.failUnless(s2 in p, "s2 is missing")
3103            self.failUnless(cl3 in p, "cl3  is missing")
3104            self.failUnless(s3 in p, "s3  is missing")
3105            self.failUnless(cl4 in p, "cl4  is missing")
3106            self.failUnless(s4 in p, "s4  is missing")
3107            self.failUnless(cl5 in p, "cl5  is missing")
3108            self.failUnless(s5 in p, "s5  is missing")
3109            self.failUnless(cl6 in p, "cl6  is missing")
3110            self.failUnless(s6 in p, "s6  is missing")
3111            self.failUnless(s_out in p, "s_out is missing")
3112            self.failUnless(p0_i in p, "p0_i is missing")
3113            self.failUnless(p1_i in p, "p1_i is missing")
3114            self.failUnless(p2_i in p, "p2_i is missing")
3115            self.failUnless(p3_i in p, "p3_i is missing")
3116            self.failUnless(p4_i in p, "p4_i is missing")
3117            self.failUnless(p5_i in p, "p5_i is missing")
3118            self.failUnless(p6_i in p, "p6_i is missing")
3119            self.failUnless(p7_i in p, "p7_i is missing")
3120            self.failUnless(l01_i in p, "l01_i is missing")
3121            self.failUnless(l15_i in p, "l15_i is missing")
3122            self.failUnless(l54_i in p, "l54_i is missing")
3123            self.failUnless(l40_i in p, "l40_i is missing")
3124            self.failUnless(l23_i in p, "l23_i is missing")
3125            self.failUnless(l37_i in p, "l37_i is missing")
3126            self.failUnless(l76_i in p, "l76_i is missing")
3127            self.failUnless(l62_i in p, "l62_i is missing")
3128            self.failUnless(l13_i in p, "l13_i is missing")
3129            self.failUnless(l57_i in p, "l57_i is missing")
3130            self.failUnless(l02_i in p, "l02_i is missing")
3131            self.failUnless(l46_i in p, "l46_i is missing")
3132            self.failUnless(cl1_i in p, "cl1_i is missing")
3133            self.failUnless(s1_i in p, "s1_i is missing")
3134            self.failUnless(cl2_i in p, "cl2_i is missing")
3135            self.failUnless(s2_i in p, "s2_i is missing")
3136            self.failUnless(cl3_i in p, "cl3_i  is missing")
3137            self.failUnless(s3_i in p, "s3_i  is missing")
3138            self.failUnless(cl4_i in p, "cl4_i  is missing")
3139            self.failUnless(s4_i in p, "s4_i  is missing")
3140            self.failUnless(cl5_i in p, "cl5_i  is missing")
3141            self.failUnless(s5_i in p, "s5_i  is missing")
3142            self.failUnless(cl6_i in p, "cl6_i  is missing")
3143            self.failUnless(s6_i in p, "s6_i  is missing")
3144            self.failUnless(s_inner in p, "s_inner  is missing")
3145    
3146            cp=v.copy()
3147            self.failUnless(isinstance(cp,Volume), "copy returns is not an arc.")
3148            self.failUnless(not cp == v, "copy equals source")
3149            self.failUnless(cp.isColocated(v),"copy is not colocated with its source.")
3150            cl2=cp.getSurfaceLoop()
3151            self.failUnless(not s_out == cl2, "copy uses s_out")
3152            hs=cp.getHoles()
3153            self.failUnless(len(hs) == 1, "copy: one holes expected.")
3154            self.failUnless(not s_inner==hs[0], "copy: uses s_inner.")
3155            cc=cp.getBoundary()
3156            self.failUnless(len(cc) == 12, "too many primitives in copy.")
3157            self.failUnless(not s1 in cc,"copy uses s1.")
3158            self.failUnless(not s2 in cc,"copy uses s2.")
3159            self.failUnless(not s3 in cc,"copy uses s3.")
3160            self.failUnless(not s4 in cc,"copy uses s4.")
3161            self.failUnless(not s5 in cc,"copy uses s5.")
3162            self.failUnless(not s6 in cc,"copy uses s6.")
3163            self.failUnless(not s1_i in cc,"copy uses s1_i.")
3164            self.failUnless(not s2_i in cc,"copy uses s2_i.")
3165            self.failUnless(not s3_i in cc,"copy uses s3_i.")
3166            self.failUnless(not s4_i in cc,"copy uses s4_i.")
3167            self.failUnless(not s5_i in cc,"copy uses s5_i.")
3168            self.failUnless(not s6_i in cc,"copy uses s6_i.")
3169    
3170            #=================================================================================
3171            p0_m=Point(2,2,2,0.1)
3172            p1_m=Point(-2,2,2,0.1)
3173            p2_m=Point(2,-2,2,0.1)
3174            p3_m=Point(-2,-2,2,0.1)
3175            p4_m=Point(2,2,-2,0.1)
3176            p5_m=Point(-2,2,-2,0.1)
3177            p6_m=Point(2,-2,-2,0.1)
3178            p7_m=Point(-2,-2,-2,0.1)
3179            l01_m=Line(p0_m,p1_m)
3180            l15_m=Line(p1_m,p5_m)
3181            l54_m=Line(p5_m,p4_m)
3182            l40_m=Line(p4_m,p0_m)
3183            l23_m=Line(p2_m,p3_m)
3184            l37_m=Line(p3_m,p7_m)
3185            l76_m=Line(p7_m,p6_m)
3186            l62_m=Line(p6_m,p2_m)
3187            l13_m=Line(p1_m,p3_m)
3188            l57_m=Line(p5_m,p7_m)
3189            l02_m=Line(p0_m,p2_m)
3190            l46_m=Line(p4_m,p6_m)
3191            cl1_m=CurveLoop(l01_m,l15_m,l54_m,l40_m)
3192            s1_m=PlaneSurface(cl1_m)
3193            cl2_m=CurveLoop(l23_m,l37_m,l76_m,l62_m)
3194            s2_m=PlaneSurface(-cl2_m)
3195            cl3_m=CurveLoop(l13_m,l37_m,-l57_m,-l15_m)
3196            s3_m=PlaneSurface(cl3_m)
3197            cl4_m=CurveLoop(l46_m,l62_m,-l02_m,-l40_m)
3198            s4_m=PlaneSurface(-cl4_m)
3199            cl5_m=CurveLoop(-l01_m,l02_m,l23_m,-l13_m)
3200            s5_m=PlaneSurface(-cl5_m)
3201            cl6_m=CurveLoop(-l54_m,l57_m,l76_m,-l46_m)
3202            s6_m=PlaneSurface(-cl6_m)
3203            s_out_m=SurfaceLoop(s1_m,s2_m,s3_m,s4_m,s5_m,s6_m)
3204            p0_i_m=Point(1,1,1,0.1)
3205            p1_i_m=Point(-1,1,1,0.1)
3206            p2_i_m=Point(1,-1,1,0.1)
3207            p3_i_m=Point(-1,-1,1,0.1)
3208            p4_i_m=Point(1,1,-1,0.1)
3209            p5_i_m=Point(-1,1,-1,0.1)
3210            p6_i_m=Point(1,-1,-1,0.1)
3211            p7_i_m=Point(-1,-1,-1,0.1)
3212            l01_i_m=Line(p0_i_m,p1_i_m)
3213            l15_i_m=Line(p1_i_m,p5_i_m)
3214            l54_i_m=Line(p5_i_m,p4_i_m)
3215            l40_i_m=Line(p4_i_m,p0_i_m)
3216            l23_i_m=Line(p2_i_m,p3_i_m)
3217            l37_i_m=Line(p3_i_m,p7_i_m)
3218            l76_i_m=Line(p7_i_m,p6_i_m)
3219            l62_i_m=Line(p6_i_m,p2_i_m)
3220            l13_i_m=Line(p1_i_m,p3_i_m)
3221            l57_i_m=Line(p5_i_m,p7_i_m)
3222            l02_i_m=Line(p0_i_m,p2_i_m)
3223            l46_i_m=Line(p4_i_m,p6_i_m)
3224            cl1_i_m=CurveLoop(l01_i_m,l15_i_m,l54_i_m,l40_i_m)
3225            s1_i_m=PlaneSurface(cl1_i_m)
3226            cl2_i_m=CurveLoop(l23_i_m,l37_i_m,l76_i_m,l62_i_m)
3227            s2_i_m=PlaneSurface(-cl2_i_m)
3228            cl3_i_m=CurveLoop(l13_i_m,l37_i_m,-l57_i_m,-l15_i_m)
3229            s3_i_m=PlaneSurface(cl3_i_m)
3230            cl4_i_m=CurveLoop(l46_i_m,l62_i_m,-l02_i_m,-l40_i_m)
3231            s4_i_m=PlaneSurface(-cl4_i_m)
3232            cl5_i_m=CurveLoop(-l01_i_m,l02_i_m,l23_i_m,-l13_i_m)
3233            s5_i_m=PlaneSurface(-cl5_i_m)
3234            cl6_i_m=CurveLoop(-l54_i_m,l57_i_m,l76_i_m,-l46_i_m)
3235            s6_i_m=PlaneSurface(-cl6_i_m)
3236            s_inner_m=SurfaceLoop(s1_i_m,s2_i_m,s3_i_m,s4_i_m,s5_i_m,s6_i_m)
3237            v_m=Volume(s_out_m,holes=[s_inner_m])
3238            #===========================================================================================================
3239            dc=v.apply(Dilation(-1.))
3240            self.failUnless(dc.isColocated(v),"dilation is wrong.")
3241            cl2=cp.getSurfaceLoop()
3242            self.failUnless(not s_out == cl2, "copy uses s_out")
3243            hs=cp.getHoles()
3244            self.failUnless(len(hs) == 1, "copy: one holes expected.")
3245            self.failUnless(not s_inner==hs[0], "copy: uses s_inner.")
3246            cc=cp.getBoundary()
3247            self.failUnless(len(cc) == 12, "too many primitives in copy.")
3248            self.failUnless(not s1 in cc,"copy uses s1.")
3249            self.failUnless(not s2 in cc,"copy uses s2.")
3250            self.failUnless(not s3 in cc,"copy uses s3.")
3251            self.failUnless(not s4 in cc,"copy uses s4.")
3252            self.failUnless(not s5 in cc,"copy uses s5.")
3253            self.failUnless(not s6 in cc,"copy uses s6.")
3254            self.failUnless(not s1_i in cc,"copy uses s1_i.")
3255            self.failUnless(not s2_i in cc,"copy uses s2_i.")
3256            self.failUnless(not s3_i in cc,"copy uses s3_i.")
3257            self.failUnless(not s4_i in cc,"copy uses s4_i.")
3258            self.failUnless(not s5_i in cc,"copy uses s5_i.")
3259            self.failUnless(not s6_i in cc,"copy uses s6_i.")
3260    
3261            v.modifyBy(Dilation(-1.))
3262            self.failUnless(v.isColocated(v_m),"inplace dilation is wrong.")
3263            cl2=v.getSurfaceLoop()
3264            self.failUnless(s_out == cl2, "inplace dilation does not s_out")
3265            hs=v.getHoles()
3266            self.failUnless(len(hs) == 1, "inplace dilation: one holes expected.")
3267            self.failUnless(s_inner==hs[0], "inplace dilation does not s_inner as hole")
3268            cc=v.getBoundary()
3269            self.failUnless(len(cc) == 12, "too many primitives in copy.")
3270            self.failUnless(s1 in cc,"inplace dilation does not use s1.")
3271            self.failUnless(cc[cc.index(s1)].hasSameOrientation(s1),"s1 in modified object has wrong orientation.")
3272            self.failUnless(s1.isColocated(s1_m),"s1 in dilated object as wrong location.")
3273            self.failUnless(s2 in cc,"inplace dilation does not use s2.")
3274            self.failUnless(cc[cc.index(s2)].hasSameOrientation(s2),"s2 in modified object has wrong orientation.")
3275            self.failUnless(s2.isColocated(s2_m),"s2 in dilated object as wrong location.")
3276            self.failUnless(s3 in cc,"inplace dilation does not use s3.")
3277            self.failUnless(cc[cc.index(s3)].hasSameOrientation(s3),"s3 in modified object has wrong orientation.")
3278            self.failUnless(s3.isColocated(s3_m),"s3 in dilated object as wrong location.")
3279            self.failUnless(s4 in cc,"inplace dilation does not use s4.")
3280            self.failUnless(cc[cc.index(s4)].hasSameOrientation(s4),"s4 in modified object has wrong orientation.")
3281            self.failUnless(s4.isColocated(s4_m),"s4 in dilated object as wrong location.")
3282            self.failUnless(s5 in cc,"inplace dilation does not use s5.")
3283            self.failUnless(cc[cc.index(s5)].hasSameOrientation(s5),"s5 in modified object has wrong orientation.")
3284            self.failUnless(s5.isColocated(s5_m),"s5 in dilated object as wrong location.")
3285            self.failUnless(s6 in cc,"inplace dilation does not use s6.")
3286            self.failUnless(cc[cc.index(s6)].hasSameOrientation(s6),"s6 in modified object has wrong orientation.")
3287            self.failUnless(s6.isColocated(s6_m),"s6 in dilated object as wrong location.")
3288            self.failUnless(s1_i in cc,"inplace dilation does not use s1_i.")
3289            self.failUnless(cc[cc.index(s1_i)].hasSameOrientation(s1_i),"s1_i in modified object has wrong orientation.")
3290            self.failUnless(s1_i.isColocated(s1_i_m),"s1_i in dilated object as wrong location.")
3291            self.failUnless(s2_i in cc,"inplace dilation does not use s2_i.")
3292            self.failUnless(cc[cc.index(s2_i)].hasSameOrientation(s2_i),"s2_i in modified object has wrong orientation.")
3293            self.failUnless(s2_i.isColocated(s2_i_m),"s2_i in dilated object as wrong location.")
3294            self.failUnless(s3_i in cc,"inplace dilation does not use s3_i.")
3295            self.failUnless(cc[cc.index(s3_i)].hasSameOrientation(s3_i),"s3_i in modified object has wrong orientation.")
3296            self.failUnless(s3_i.isColocated(s3_i_m),"s3_i in dilated object as wrong location.")
3297            self.failUnless(s4_i in cc,"inplace dilation does not use s4_i.")
3298            self.failUnless(cc[cc.index(s4_i)].hasSameOrientation(s4_i),"s4_i in modified object has wrong orientation.")
3299            self.failUnless(s4_i.isColocated(s4_i_m),"s4_i in dilated object as wrong location.")
3300            self.failUnless(s5_i in cc,"inplace dilation does not use s5_i.")
3301            self.failUnless(cc[cc.index(s5_i)].hasSameOrientation(s5_i),"s5_i in modified object has wrong orientation.")
3302            self.failUnless(s5_i.isColocated(s5_i_m),"s5_i in dilated object as wrong location.")
3303            self.failUnless(s6_i in cc,"inplace dilation does not use s6_i.")
3304            self.failUnless(cc[cc.index(s6_i)].hasSameOrientation(s6_i),"s6_i in modified object has wrong orientation.")
3305            self.failUnless(s6_i.isColocated(s6_i_m),"s6_i in dilated object as wrong location.")
3306    
3307  if __name__ == '__main__':  if __name__ == '__main__':
3308     suite = unittest.TestSuite()     suite = unittest.TestSuite()
3309     suite.addTest(unittest.makeSuite(Test_PyCAD_Transformations))     suite.addTest(unittest.makeSuite(Test_PyCAD_Transformations))

Legend:
Removed from v.930  
changed lines
  Added in v.931

  ViewVC Help
Powered by ViewVC 1.1.26