@@ -428,30 +428,37 @@ def cut_slice(self, direction, p_min, p_max):
428
428
result , _ = rest .split_at (direction , p_max )
429
429
return result
430
430
431
- def get_discontinuities_u (self , order ):
431
+ def get_discontinuities_u (self , order , include_endpoints = False ):
432
432
p = self .get_degree_u ()
433
433
knotvector = self .get_knotvector_u ()
434
434
ms = sv_knotvector .to_multiplicity (knotvector )
435
- return [t for t , s in ms if s == p - order + 1 ]
435
+ result = [t for t , s in ms if s == p - order + 1 ]
436
+ if include_endpoints :
437
+ result = [knotvector [0 ]] + result + [knotvector [- 1 ]]
438
+ return result
436
439
437
- def get_discontinuities_v (self , order ):
440
+ def get_discontinuities_v (self , order , include_endpoints = False ):
438
441
p = self .get_degree_v ()
439
442
knotvector = self .get_knotvector_v ()
440
443
ms = sv_knotvector .to_multiplicity (knotvector )
441
- return [t for t , s in ms if s == p - order + 1 ]
444
+ result = [t for t , s in ms if s == p - order + 1 ]
445
+ if include_endpoints :
446
+ result = [knotvector [0 ]] + result + [knotvector [- 1 ]]
447
+ return result
442
448
443
- def get_discontinuities (self , direction , order ):
449
+ def get_discontinuities (self , direction , order , include_endpoints = False ):
444
450
if direction == SvNurbsSurface .U :
445
- return self .get_discontinuities_u (order )
451
+ return self .get_discontinuities_u (order , include_endpoints )
446
452
else :
447
- return self .get_discontinuities_v (order )
453
+ return self .get_discontinuities_v (order , include_endpoints )
448
454
449
455
def cut_slices_by_discontinuity (self , direction , order ):
450
- ts = self .get_discontinuities (direction , order )
451
- if len (ts ) <= 1 :
456
+ ts = self .get_discontinuities (direction , order , include_endpoints = True )
457
+ if len (ts ) <= 2 :
452
458
return [self ]
453
- print (f"Discontinuities in { direction } : { ts } " )
454
- return [self .cut_slice (direction , t1 , t2 ) for t1 , t2 in zip (ts , ts [1 :])]
459
+ result = [self .cut_slice (direction , t1 , t2 ) for t1 , t2 in zip (ts , ts [1 :])]
460
+ #print(f"Discontinuities in {direction}: {ts} => {len(result)} slices")
461
+ return result
455
462
456
463
def cut_slices_by_discontinuity_uv (self , order , join = True ):
457
464
slices_u = self .cut_slices_by_discontinuity (SvNurbsSurface .U , order )
0 commit comments