File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -504,6 +504,11 @@ func (c *commandContext) AddSurface(resolution float32) bool {
504
504
505
505
w := int (l0 / resolution )
506
506
h := int (l1 / resolution )
507
+
508
+ if w * h == 0 {
509
+ return true
510
+ }
511
+
507
512
pcNew := & pc.PointCloud {
508
513
PointCloudHeader : c .editor .pp .PointCloudHeader .Clone (),
509
514
Points : w * h ,
Original file line number Diff line number Diff line change @@ -285,3 +285,34 @@ func TestBaseFileter(t *testing.T) {
285
285
}, c .baseFilterByMask (false ))
286
286
})
287
287
}
288
+
289
+ func TestAddSurface (t * testing.T ) {
290
+ var selectRange float32 = 1.0
291
+ t .Run ("NotSelected" , func (t * testing.T ) {
292
+ c := & commandContext {
293
+ selected : []mat.Vec3 {
294
+ {0 , 0 , 0 },
295
+ {0.1 , 0 , 0 },
296
+ },
297
+ selectRange : & selectRange ,
298
+ }
299
+ c .updateRect ()
300
+ if ok := c .AddSurface (0.11 ); ok {
301
+ t .Fatal ("AddSurface must success (but do nothing) if surface has zero points" )
302
+ }
303
+ })
304
+ t .Run ("ZeroPoints" , func (t * testing.T ) {
305
+ c := & commandContext {
306
+ selected : []mat.Vec3 {
307
+ {0 , 0 , 0 },
308
+ {0.1 , 0 , 0 },
309
+ {0.1 , 0.1 , 0 },
310
+ },
311
+ selectRange : & selectRange ,
312
+ }
313
+ c .updateRect ()
314
+ if ok := c .AddSurface (0.11 ); ! ok {
315
+ t .Fatal ("AddSurface must fail if region is not selected" )
316
+ }
317
+ })
318
+ }
You can’t perform that action at this time.
0 commit comments