/[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 928 by gross, Tue Jan 16 08:36:03 2007 UTC revision 929 by gross, Wed Jan 17 07:41:13 2007 UTC
# Line 598  class Test_PyCAD_Primitives(unittest.Tes Line 598  class Test_PyCAD_Primitives(unittest.Tes
598     def setUp(self):     def setUp(self):
599           resetGlobalPrimitiveIdCounter()           resetGlobalPrimitiveIdCounter()
600    
601     def test_baseclass(self):     def test_Primitive(self):
602           p=Primitive()           p=Primitive()
603    
604           id=p.getID()           id=p.getID()
605           self.failUnless(isinstance(id,int),"id number is not an integer")           self.failUnless(isinstance(id,int),"id number is not an integer")
606           self.failUnless(not id==Primitive().getID(),"id number is not unique")           self.failUnless(not id==Primitive().getID(),"id number is not unique")
             
          hs=p.getPrimitives()  
          self.failUnless(len(hs)==0,"history should be empty.")  
607    
608           ps=p.getConstructionPoints()           self.failUnless(p==p.getUnderlyingPrimitive(),"getUnderlyingPrimitive does not return self.")
          self.failUnless(len(ps)==0,"point set should be empty.")  
609    
610     def test_point(self):     def test_ReversePrimitive(self):
611             p=Primitive()
612          
613             rp=ReversePrimitive(p)
614             self.failUnless(p.getID()==rp.getID(),"reverse primitive does not have same id like source")
615             self.failUnless(p==rp.getUnderlyingPrimitive(),"getUnderlyingPrimitive does return source.")
616             self.failUnless(p == -rp,"reverse or reverse does not return source.")
617              
618       def test_Point(self):
619         p=Point(1.,2.,3.,local_scale=9.)         p=Point(1.,2.,3.,local_scale=9.)
620                
621         id=p.getID()         id=p.getID()
622         self.failUnless(isinstance(id,int),"id number is not an integer")         self.failUnless(isinstance(id,int),"id number is not an integer")
623         self.failUnless(not id==Primitive().getID(),"id number is not unique")         self.failUnless(not id==Primitive().getID(),"id number is not unique")
624                        
625           # check reverse point
626           self.failUnless(p == -p,"reverse is not working.")
627          
628         # check history:         # check history:
629         hs=p.getPrimitives()         hs=p.getPrimitives()
630         self.failUnless(len(hs)==1,"history must have length 1.")         self.failUnless(len(hs)==1,"history must have length 1.")
# Line 743  class Test_PyCAD_Primitives(unittest.Tes Line 750  class Test_PyCAD_Primitives(unittest.Tes
750         code=p.getGmshCommand(2.)         code=p.getGmshCommand(2.)
751         self.failUnless("Point(1) = {8.0 , 16.0, 24.0 , 6.0 };"== code, "wrong gmsh code")         self.failUnless("Point(1) = {8.0 , 16.0, 24.0 , 6.0 };"== code, "wrong gmsh code")
752    
753     def test_spline(self):     def test_Spline(self):
754          p0=Point(0,0,0,0.1)          p0=Point(0,0,0,0.1)
755          p1=Point(1,1,1,0.2)          p1=Point(1,1,1,0.2)
756          p2=Point(2,2,2,0.3)          p2=Point(2,2,2,0.3)
# Line 809  class Test_PyCAD_Primitives(unittest.Tes Line 816  class Test_PyCAD_Primitives(unittest.Tes
816          dccp=dc.getControlPoints()          dccp=dc.getControlPoints()
817          self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")          self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
818          self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")          self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
819            self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
820          self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")          self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
821            self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
822          self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")          self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
823            self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
824          self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")          self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
825            self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
826        
827       def test_ReverseSpline(self):
828            p0=Point(0,0,0,0.1)
829            p1=Point(1,1,1,0.2)
830            p2=Point(2,2,2,0.3)
831            p3=Point(3,3,3,0.4)
832            p4=Point(1,2,3)
833    
834            CC0=Spline(p0,p1,p2,p3)
835            c=-CC0
836    
837            self.failUnless(len(c) == 4, "wrong reverse spline curve length")
838            self.failUnless(c.getStartPoint()==p3, "wrong start point of reverse spline curve")
839            self.failUnless(c.getEndPoint()==p0, "wrong end point of reverse spline curve")
840    
841            self.failUnless(not c.isColocated(p1),"reverse spline is colocated with point.")
842            self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"reverse spline is colocated with spline of different length.")
843            self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"reverse spline is colocated with spline with different point.")
844            self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"reverse spline is not colocated with spline with same points but opposite direction.")
845            self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"reverse spline is not colocated with spline with same points.")
846            self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
847    
848            co=c.getControlPoints()
849            self.failUnless(co[0]==p3, "1st control point is wrong.")
850            self.failUnless(co[1]==p2, "2nd control point is wrong.")
851            self.failUnless(co[2]==p1, "3rd control point is wrong.")
852            self.failUnless(co[3]==p0, "4th control point is wrong.")
853    
854            c.setLocalScale(3.)
855            co=c.getControlPoints()
856            self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
857            self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
858            self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
859            self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
860    
861            code=c.getGmshCommand()
862            self.failUnless(code == "Spline(6) = {1, 2, 3, 4};", "gmsh command wrong.")
863    
864            h=c.getPrimitives()
865            self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
866            self.failUnless(p0 in h, "missing p0 in history.")
867            self.failUnless(p1 in h, "missing p1 in history.")
868            self.failUnless(p2 in h, "missing p2 in history.")
869            self.failUnless(p3 in h, "missing p3 in history.")
870            self.failUnless(CC0 in h, "missing spline curve in history.")
871    
872            cp=c.copy()
873            cpcp=cp.getControlPoints()
874            self.failUnless(not cp == c, "copy returns same spline curve.")
875            self.failUnless(not cp == CC0, "copy returns same spline curve.")
876            self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
877            self.failUnless(not p3 == cpcp[0],"1st point of deep copy and souce are the same.")
878            self.failUnless(not p2 == cpcp[1],"2st point of deep copy and source are the same.")
879            self.failUnless(not p1 == cpcp[2],"3st point of deep copy and source are the same.")
880            self.failUnless(not p0 == cpcp[3],"4st point of deep copy and source are the same.")
881    
882            c.modifyBy(Dilation(-1.))
883            cp=c.getControlPoints()
884            self.failUnless(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
885            self.failUnless(p3 == cp[0],"1st new point after Dilation.")
886            self.failUnless(p2 == cp[1],"2nd new point after Dilation.")
887            self.failUnless(p1 == cp[2],"3rd new point after Dilation.")
888            self.failUnless(p0 == cp[3],"4th new point after Dilation.")
889    
890            dc=c.apply(Dilation(-1.))
891            dccp=dc.getControlPoints()
892            self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
893            self.failUnless(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
894            self.failUnless(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
895            self.failUnless(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
896            self.failUnless(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
897    
898     def test_BezierCurve(self):     def test_BezierCurve(self):
899          p0=Point(0,0,0,0.1)          p0=Point(0,0,0,0.1)
# Line 950  class Test_PyCAD_Primitives(unittest.Tes Line 1031  class Test_PyCAD_Primitives(unittest.Tes
1031          dccp=dc.getControlPoints()          dccp=dc.getControlPoints()
1032          self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")          self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1033          self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")          self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1034            self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1035            self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1036            self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1037            self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1038            self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1039            self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1040            self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1041    
1042       def test_ReverseBSpline(self):
1043            p0=Point(0,0,0,0.1)
1044            p1=Point(1,1,1,0.2)
1045            p2=Point(2,2,2,0.3)
1046            p3=Point(3,3,3,0.4)
1047            p4=Point(1,2,3)
1048    
1049            CC0=BSpline(p0,p1,p2,p3)
1050            c=-CC0
1051    
1052            self.failUnless(len(c) == 4, "wrong spline curve length")
1053            self.failUnless(c.getStartPoint()==p3, "wrong start point of spline curve")
1054            self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve")
1055    
1056            self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
1057            self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
1058            self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
1059            self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
1060            self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1061            self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
1062    
1063            co=c.getControlPoints()
1064            self.failUnless(co[0]==p3, "1st control point is wrong.")
1065            self.failUnless(co[1]==p2, "2nd control point is wrong.")
1066            self.failUnless(co[2]==p1, "3rd control point is wrong.")
1067            self.failUnless(co[3]==p0, "4th control point is wrong.")
1068    
1069            c.setLocalScale(3.)
1070            co=c.getControlPoints()
1071            self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1072            self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1073            self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1074            self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1075    
1076            code=c.getGmshCommand()
1077            self.failUnless(code == "BSpline(6) = {1, 2, 3, 4};", "gmsh command wrong.")
1078    
1079            h=c.getPrimitives()
1080            self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
1081            self.failUnless(p0 in h, "missing p0 in history.")
1082            self.failUnless(p1 in h, "missing p1 in history.")
1083            self.failUnless(p2 in h, "missing p2 in history.")
1084            self.failUnless(p3 in h, "missing p3 in history.")
1085            self.failUnless(CC0 in h, "missing spline curve in history.")
1086    
1087            cp=c.copy()
1088            cpcp=cp.getControlPoints()
1089            self.failUnless(not cp == c, "copy returns same spline curve.")
1090            self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1091            self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1092            self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1093            self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1094            self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1095    
1096            c.modifyBy(Dilation(-1.))
1097            cp=c.getControlPoints()
1098            self.failUnless(c.isColocated(BSpline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
1099            self.failUnless(p3 == cp[0],"1st new point after Dilation.")
1100            self.failUnless(p2 == cp[1],"2nd new point after Dilation.")
1101            self.failUnless(p1 == cp[2],"3rd new point after Dilation.")
1102            self.failUnless(p0 == cp[3],"4th new point after Dilation.")
1103    
1104            dc=c.apply(Dilation(-1.))
1105            dccp=dc.getControlPoints()
1106            self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1107            self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1108            self.failUnless(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1109          self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")          self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1110            self.failUnless(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1111          self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")          self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1112            self.failUnless(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1113          self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")          self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1114            self.failUnless(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1115    
1116     def test_LineSegment(self):     def test_LineSegment(self):
1117          p0=Point(0,0,0,0.1)          p0=Point(0,0,0,0.1)
# Line 1009  class Test_PyCAD_Primitives(unittest.Tes Line 1168  class Test_PyCAD_Primitives(unittest.Tes
1168          dccp=dc.getControlPoints()          dccp=dc.getControlPoints()
1169          self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")          self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1170          self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")          self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1171            self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1172            self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1173            self.failUnless(dccp[1].isColocated(Point(1,1,1)),"2st point of Dilation is is wrongly located.")
1174    
1175       def test_ReverseLineSegment(self):
1176            p0=Point(0,0,0,0.1)
1177            p1=Point(1,1,1,0.2)
1178            p4=Point(1,2,3)
1179    
1180            self.failUnlessRaises(TypeError,Line,p0)
1181            self.failUnlessRaises(TypeError,Line,p0,p1,p4)
1182    
1183            CC0=Line(p0,p1)
1184            c=-CC0
1185    
1186            self.failUnless(len(c) == 2, "wrong spline curve length")
1187            self.failUnless(c.getStartPoint()==p1, "wrong start point of spline curve")
1188            self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve")
1189    
1190            self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
1191            self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1192            self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1193            self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1194            self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1195    
1196            co=c.getControlPoints()
1197            self.failUnless(co[0]==p1, "1st control point is wrong.")
1198            self.failUnless(co[1]==p0, "2nd control point is wrong.")
1199    
1200            c.setLocalScale(3.)
1201            co=c.getControlPoints()
1202            self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1203            self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1204    
1205            code=c.getGmshCommand()
1206            self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.")
1207    
1208            h=c.getPrimitives()
1209            self.failUnless(len(h) == 3, "number of primitives in history is wrong.")
1210            self.failUnless(p0 in h, "missing p0 in history.")
1211            self.failUnless(p1 in h, "missing p1 in history.")
1212            self.failUnless(CC0 in h, "missing spline curve in history.")
1213    
1214            cp=c.copy()
1215            cpcp=cp.getControlPoints()
1216            self.failUnless(not cp == c, "copy returns same spline curve.")
1217            self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1218            self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1219            self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1220    
1221            c.modifyBy(Dilation(-1.))
1222            cp=c.getControlPoints()
1223            self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1224            self.failUnless(p1 == cp[0],"1st new point after Dilation.")
1225            self.failUnless(p0 == cp[1],"2nd new point after Dilation.")
1226    
1227            dc=c.apply(Dilation(-1.))
1228            dccp=dc.getControlPoints()
1229            self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1230            self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1231            self.failUnless(dccp[0].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1232          self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")          self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1233            self.failUnless(dccp[1].isColocated(Point(0,0,0)),"2st point of Dilation is is wrongly located.")
1234    
1235     def test_arc(self):     def test_Arc(self):
1236          center=Point(0,0,0,0.1)          center=Point(0,0,0,0.1)
1237          p_start=Point(1,1,1,0.2)          p_start=Point(1,1,1,0.2)
1238          p_end=Point(1,2,3)          p_end=Point(1,2,3)
# Line 1066  class Test_PyCAD_Primitives(unittest.Tes Line 1287  class Test_PyCAD_Primitives(unittest.Tes
1287          dc=c.apply(Dilation(-1.))          dc=c.apply(Dilation(-1.))
1288          self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")          self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1289          self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")          self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1290            self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1291            self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1292            self.failUnless(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.")
1293            self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1294            self.failUnless(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.")
1295    
1296       def test_ReverseArc(self):
1297            center=Point(0,0,0,0.1)
1298            p_start=Point(1,1,1,0.2)
1299            p_end=Point(1,2,3)
1300            p4=Point(10,2,3)
1301    
1302            self.failUnlessRaises(TypeError,Arc,Primitive())
1303    
1304            CC0=Arc(center,p_start,p_end)
1305            c=-CC0
1306    
1307            self.failUnless(c.getCenterPoint()==center, "wrong center point")
1308            self.failUnless(c.getStartPoint()==p_end, "wrong start point")
1309            self.failUnless(c.getEndPoint()==p_start, "wrong end point")
1310    
1311            code=c.getGmshCommand()
1312            self.failUnless(code == "Circle(6) = {2, 1, 3};", "gmsh command wrong.")
1313    
1314            self.failUnless(not c.isColocated(p4),"spline is colocated with point.")
1315            self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1316            self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1317            self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1318            self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1319            self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1320            self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1321    
1322            h=c.getPrimitives()
1323            self.failUnless(len(h) == 4, "number of primitives in history is wrong.")
1324            self.failUnless(center in h, "missing center in history.")
1325            self.failUnless(p_start in h, "missing p_start in history.")
1326            self.failUnless(p_end in h, "missing p_end in history.")
1327            self.failUnless(CC0 in h, "missing spline curve in history.")
1328    
1329    
1330            c.setLocalScale(3.)
1331            self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1332            self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1333            self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1334    
1335            cp=c.copy()
1336            self.failUnless(isinstance(cp,ReverseArc), "copy returns is not an arc.")
1337            self.failUnless(not cp == c, "copy returns same arc.")
1338            self.failUnless(cp.isColocated(Arc(center,p_end,p_start)),"arc is not colocated with its copy.")
1339            self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1340            self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1341            self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1342    
1343            c.modifyBy(Dilation(-1.))
1344            self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1345            self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.")
1346            self.failUnless(c.getStartPoint() == p_end,"wrong start point after dilation.")
1347            self.failUnless(c.getEndPoint() == p_start,"wrong end point after dilation.")
1348    
1349            dc=c.apply(Dilation(-1.))
1350            self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1351            self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1352            self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1353          self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")          self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1354            self.failUnless(dc.getStartPoint().isColocated(Point(1,2,3)),"start point of dilation is wrong.")
1355          self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")          self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1356            self.failUnless(dc.getEndPoint().isColocated(Point(1,1,1)),"end point of dilation is wrong.")
1357    
1358     def test_CurveLoop(self):     def test_CurveLoop(self):
1359          p0=Point(0,0,0,0.1)          p0=Point(0,0,0,0.1)
# Line 1096  class Test_PyCAD_Primitives(unittest.Tes Line 1382  class Test_PyCAD_Primitives(unittest.Tes
1382    
1383    
1384          self.failUnless(not c.isColocated(p4),"CurveLoop is colocated with point.")          self.failUnless(not c.isColocated(p4),"CurveLoop is colocated with point.")
1385            self.failUnless(c.isColocated(c),"CurveLoop is not colocated with its self.")
1386            self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"CurveLoop is not colocated with its copy.")
1387            self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"CurveLoop is not colocated with its copy with shifted points.")
1388            self.failUnless(c.isColocated(CurveLoop(l20,l12,l01)),"CurveLoop is not colocated with its copy with shuffled points.")
1389            self.failUnless(not c.isColocated(CurveLoop(lx,ly,l12)),"CurveLoop is colocated with different CurveLoop.")
1390    
1391            self.failUnless(len(c) == 3, "wrong length")
1392    
1393            c.setLocalScale(3.)
1394            self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
1395            self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
1396            self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
1397            self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
1398    
1399    
1400            cc=c.getCurves()
1401            self.failUnless(len(cc) == 3, "too many curves.")
1402            self.failUnless(l01 in cc, "l01 is missing")
1403            self.failUnless(l12 in cc, "l12 is missing")
1404            self.failUnless(l20 in cc, "l20 is missing")
1405    
1406            p=c.getPrimitives()
1407            self.failUnless(len(p) == 9, "too many primitives.")
1408            self.failUnless(l01 in p, "l01 is missing")
1409            self.failUnless(l12 in p, "l21 is missing")
1410            self.failUnless(l20 in p, "l20 is missing")
1411            self.failUnless(p0 in p, "p0 is missing")
1412            self.failUnless(p1 in p, "p1 is missing")
1413            self.failUnless(p2 in p, "p2 is missing")
1414            self.failUnless(p3 in p, "p3 is missing")
1415            self.failUnless(p4 in p, "p4 is missing")
1416    
1417            cp=c.copy()
1418            self.failUnless(isinstance(cp,CurveLoop), "copy returns is not an arc.")
1419            self.failUnless(not cp == c, "copy equals source")
1420            self.failUnless(cp.isColocated(c),"copy is not colocated with its source.")
1421            cc=cp.getCurves()
1422            self.failUnless(len(cc) == 3, "too many primitives in copy.")
1423            self.failUnless(not l01 in cc,"copy uses l01.")
1424            self.failUnless(not l12 in cc,"copy uses l12.")
1425            self.failUnless(not l20 in cc,"copy uses l20.")
1426            
1427            p0_m=Point(0,0,0)
1428            p1_m=Point(-1,-1,-1)
1429            p2_m=Point(-2,-2,-2)
1430            p3_m=Point(-3,-3,-3)
1431            p4_m=Point(-1,-2,-3)
1432    
1433            l01_m=Line(p0_m,p1_m)
1434            l12_m=Arc(p3_m,p1_m,p2_m)
1435            l20_m=Spline(p2_m,p4_m,p0_m)
1436    
1437            dc=c.apply(Dilation(-1.))
1438            self.failUnless(dc.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"dilation is wrong.")
1439            cc=dc.getCurves()
1440            self.failUnless(len(cc) == 3, "too many primitives in dilation result.")
1441            self.failUnless(not l01 in cc,"l01 is in dilation result.")
1442            self.failUnless(not l12 in cc,"l12 is in dilation result.")
1443            self.failUnless(not l20 in cc,"l20 is in dilation result.")
1444    
1445            c.modifyBy(Dilation(-1.))
1446            self.failUnless(c.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"inplace dilation is wrong.")
1447            cc=c.getCurves()
1448            self.failUnless(len(cc) == 3, "too many primitives in modified object.")
1449            self.failUnless(l01 in cc,"l01 missed in  modified object.")
1450            self.failUnless(l12 in cc,"l12 missed in  modified object.")
1451            self.failUnless(l20 in cc,"l20 missed in  modified object.")
1452          
1453       def test_ReverseCurveLoop(self):
1454            p0=Point(0,0,0,0.1)
1455            p1=Point(1,1,1,0.2)
1456            p2=Point(2,2,2,0.3)
1457            p3=Point(3,3,3,0.4)
1458            p4=Point(1,2,3)
1459            p5=Point(10,20,3)
1460            p6=Point(1,2,30)
1461    
1462            l01=Line(p0,p1)
1463            l12=Arc(p3,p1,p2)
1464            l20=Spline(p2,p4,p0)
1465    
1466            lx=Line(p2,p3)
1467            ly=Line(p3,p1)
1468    
1469            CC0=CurveLoop(l01,l20,l12)
1470            c=-CC0
1471    
1472            code=c.getGmshCommand()
1473            print code
1474            self.failUnless(code == "Line Loop(13) = {8, 9, 10};", "gmsh command wrong.")
1475    
1476    
1477            self.failUnless(not c.isColocated(p4),"CurveLoop is colocated with point.")
1478          self.failUnless(c.isColocated(c),"CurveLoop is not colocated with its self.")          self.failUnless(c.isColocated(c),"CurveLoop is not colocated with its self.")
1479          self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"CurveLoop is not colocated with its copy.")          self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"CurveLoop is not colocated with its copy.")
1480          self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"CurveLoop is not colocated with its copy with shifted points.")          self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"CurveLoop is not colocated with its copy with shifted points.")

Legend:
Removed from v.928  
changed lines
  Added in v.929

  ViewVC Help
Powered by ViewVC 1.1.26