@@ -66,7 +66,7 @@ def test03_dictionaries(self):
6666 self .assertTrue ("skylight" in osut .film ())
6767 self .assertTrue ("skylight" in osut .uo ())
6868 self .assertEqual (osut .film ().keys (), osut .uo ().keys ())
69-
69+
7070 def test04_materials (self ):
7171 material = osut .mats ()["material" ]
7272 sand = osut .mats ()["sand" ]
@@ -3308,6 +3308,84 @@ def test25_segments_triads_orientation(self):
33083308 p7 = openstudio .Point3d (14 , 20 , - 5 )
33093309 p8 = openstudio .Point3d (- 9 , - 9 , - 5 )
33103310
3311+ # Stress test 'to_p3Dv'. 4 valid input cases.
3312+ # Valid case #1: a single Point3d.
3313+ vtx = osut .p3Dv (p0 )
3314+ self .assertTrue (isinstance (vtx , openstudio .Point3dVector ))
3315+ self .assertEqual (vtx [0 ], p0 ) # same object ID
3316+
3317+ # Valid case #2: a Point3dVector.
3318+ vtxx = openstudio .Point3dVector ()
3319+ vtxx .append (p0 )
3320+ vtxx .append (p1 )
3321+ vtxx .append (p2 )
3322+ vtxx .append (p3 )
3323+ vtx = osut .p3Dv (vtxx )
3324+ self .assertTrue (isinstance (vtx , openstudio .Point3dVector ))
3325+ self .assertEqual (vtx [ 0 ], p0 ) # same object ID
3326+ self .assertEqual (vtx [ 1 ], p1 ) # same object ID
3327+ self .assertEqual (vtx [ 2 ], p2 ) # same object ID
3328+ self .assertEqual (vtx [- 1 ], p3 ) # same object ID
3329+
3330+ # Valid case #3: Surface vertices.
3331+ model = openstudio .model .Model ()
3332+ surface = openstudio .model .Surface (vtxx , model )
3333+ self .assertTrue (isinstance (surface .vertices (), tuple )) # ! Point3dVector
3334+ self .assertEqual (len (surface .vertices ()), 4 )
3335+ vtx = osut .p3Dv (vtxx )
3336+ self .assertTrue (isinstance (vtx , openstudio .Point3dVector ))
3337+ self .assertEqual (len (vtx ), 4 )
3338+ self .assertEqual (vtx [0 ], p0 )
3339+ self .assertEqual (vtx [1 ], p1 )
3340+ self .assertEqual (vtx [2 ], p2 )
3341+ self .assertEqual (vtx [3 ], p3 )
3342+
3343+ # Valid case #4: Array.
3344+ vtx = osut .p3Dv ([p0 , p1 , p2 , p3 ])
3345+ self .assertTrue (isinstance (vtx , openstudio .Point3dVector ))
3346+ self .assertEqual (len (vtx ), 4 )
3347+ self .assertEqual (vtx [0 ], p0 )
3348+ self .assertEqual (vtx [1 ], p1 )
3349+ self .assertEqual (vtx [2 ], p2 )
3350+ self .assertEqual (vtx [3 ], p3 )
3351+
3352+ # Stress test 'nextUp'.
3353+ m0 = "Invalid 'points (2+)' arg #1 (osut.nextUp)"
3354+
3355+ # Invalid case.
3356+ pt = osut .nextUp ([], p0 )
3357+ self .assertFalse (pt )
3358+ self .assertTrue (o .is_warn ())
3359+ self .assertEqual (len (o .logs ()), 1 )
3360+ self .assertEqual (o .logs ()[0 ]["message" ], m0 )
3361+ self .assertEqual (o .clean (), DBG )
3362+
3363+ # Valid case.
3364+ pt = osut .nextUp ([p0 , p1 , p2 , p3 ], p0 )
3365+ self .assertTrue (isinstance (pt , openstudio .Point3d ))
3366+ self .assertEqual (pt , p1 )
3367+
3368+ pt = osut .nextUp ([p0 , p0 , p0 ], p0 )
3369+ self .assertTrue (isinstance (pt , openstudio .Point3d ))
3370+ self .assertEqual (pt , p0 )
3371+
3372+ # Stress test 'segments'. Invalid case.
3373+ sgs = osut .segments (p3 )
3374+ self .assertTrue (isinstance (sgs , openstudio .Point3dVectorVector ))
3375+ self .assertFalse (sgs )
3376+ self .assertEqual (o .status (), 0 ) # nothing logged
3377+
3378+ sgs = osut .segments ([p3 , p3 ])
3379+ self .assertTrue (isinstance (sgs , openstudio .Point3dVectorVector ))
3380+ self .assertFalse (sgs )
3381+ self .assertEqual (o .status (), 0 ) # nothing logged
3382+
3383+ # Valid case.
3384+ sgs = osut .segments ([p0 , p1 , p2 , p3 ])
3385+ self .assertTrue (isinstance (sgs , openstudio .Point3dVectorVector ))
3386+ self .assertEqual (len (sgs ), 4 )
3387+ self .assertTrue (isinstance (sgs [- 1 ], tuple )) # ! Point3dVector
3388+
33113389 # Stress test 'uniques'.
33123390 m0 = "'n points' str? expecting int (osut.uniques)"
33133391
@@ -3375,6 +3453,7 @@ def test25_segments_triads_orientation(self):
33753453 self .assertEqual (len (collinears ), 2 )
33763454 self .assertTrue (osut .areSame (collinears [0 ], p0 ))
33773455 self .assertTrue (osut .areSame (collinears [1 ], p1 ))
3456+ self .assertTrue (osut .isPointAlongSegment (p0 , sgs [0 ]))
33783457
33793458 # Only 2 collinears, so request for first 3 is ignored.
33803459 collinears = osut .collinears ([p0 , p1 , p2 , p3 , p8 ], 3 )
@@ -3409,6 +3488,22 @@ def test25_segments_triads_orientation(self):
34093488 self .assertTrue (osut .areSame (collinears [0 ], p0 ))
34103489 self .assertTrue (osut .areSame (collinears [1 ], p1 ))
34113490
3491+ # Stress test isPointAlongSegment.
3492+ m0 = "'point' str? expecting Point3d (osut.p3Dv)"
3493+
3494+ # Invalid case.
3495+ self .assertFalse (osut .isPointAlongSegment (p3 , "osut" ))
3496+ self .assertTrue (o .is_debug ())
3497+ self .assertEqual (len (o .logs ()), 1 )
3498+ self .assertEqual (o .logs ()[0 ]["message" ], m0 )
3499+ self .assertEqual (o .clean (), DBG )
3500+
3501+ # Valid case.
3502+ pts = openstudio .Point3dVector ()
3503+ pts .append (p0 )
3504+ pts .append (p1 )
3505+ self .assertFalse (osut .isPointAlongSegment (p3 , pts ))
3506+
34123507 # CASE a1: 2x end-to-end line segments (returns matching endpoints).
34133508 self .assertTrue (osut .doesLineIntersect ([p0 , p1 ], [p1 , p2 ]))
34143509 pt = osut .lineIntersection ([p0 , p1 ], [p1 , p2 ])
@@ -4999,7 +5094,7 @@ def test33_leader_line_anchors_inserts(self):
49995094 # [ 4, 14, 0] ... vs [16, 2, 20]
50005095 # [ 0, 14, 0] ... vs [20, 2, 20]
50015096 # [ 0, 0, 0] ... vs [20, 16, 20]
5002-
5097+
50035098 def test34_generated_skylight_wells (self ):
50045099 o = osut .oslg
50055100 self .assertEqual (o .status (), 0 )
0 commit comments