120
120
from OCP .HLRBRep import HLRBRep_Algo , HLRBRep_HLRToShape
121
121
from OCP .ShapeAnalysis import ShapeAnalysis_FreeBounds
122
122
from OCP .ShapeFix import ShapeFix_Shape , ShapeFix_Wireframe
123
- from OCP .Standard import Standard_Failure , Standard_NoSuchObject
123
+ from OCP .Standard import (
124
+ Standard_Failure ,
125
+ Standard_NoSuchObject ,
126
+ Standard_ConstructionError ,
127
+ )
124
128
from OCP .TColStd import (
125
129
TColStd_Array1OfReal ,
126
130
TColStd_HArray1OfBoolean ,
@@ -511,7 +515,8 @@ def location_at(
511
515
distance : float ,
512
516
position_mode : PositionMode = PositionMode .PARAMETER ,
513
517
frame_method : FrameMethod = FrameMethod .FRENET ,
514
- planar : bool = False ,
518
+ planar : bool | None = None ,
519
+ x_dir : VectorLike | None = None ,
515
520
) -> Location :
516
521
"""Locations along curve
517
522
@@ -522,8 +527,18 @@ def location_at(
522
527
position_mode (PositionMode, optional): position calculation mode.
523
528
Defaults to PositionMode.PARAMETER.
524
529
frame_method (FrameMethod, optional): moving frame calculation method.
530
+ The FRENET frame can “twist” or flip unexpectedly, especially near flat
531
+ spots. The CORRECTED frame behaves more like a “camera dolly” or
532
+ sweep profile would — it's smoother and more stable.
525
533
Defaults to FrameMethod.FRENET.
526
- planar (bool, optional): planar mode. Defaults to False.
534
+ planar (bool, optional): planar mode. Defaults to None.
535
+ x_dir (VectorLike, optional): override the x_dir to help with plane
536
+ creation along a 1D shape. Must be perpendicalar to shapes tangent.
537
+ Defaults to None.
538
+
539
+ .. deprecated::
540
+ The `planar` parameter is deprecated and will be removed in a future release.
541
+ Use `x_dir` to specify orientation instead.
527
542
528
543
Returns:
529
544
Location: A Location object representing local coordinate system
@@ -550,23 +565,45 @@ def location_at(
550
565
pnt = curve .Value (param )
551
566
552
567
transformation = gp_Trsf ()
553
- if planar :
568
+ if planar is not None :
569
+ warnings .warn (
570
+ "The 'planar' parameter is deprecated and will be removed in a future version. "
571
+ "Use 'x_dir' to control orientation instead." ,
572
+ DeprecationWarning ,
573
+ stacklevel = 2 ,
574
+ )
575
+ if planar is not None and planar :
554
576
transformation .SetTransformation (
555
577
gp_Ax3 (pnt , gp_Dir (0 , 0 , 1 ), gp_Dir (normal .XYZ ())), gp_Ax3 ()
556
578
)
579
+ elif x_dir is not None :
580
+ try :
581
+
582
+ transformation .SetTransformation (
583
+ gp_Ax3 (pnt , gp_Dir (tangent .XYZ ()), Vector (x_dir ).to_dir ()), gp_Ax3 ()
584
+ )
585
+ except Standard_ConstructionError :
586
+ raise ValueError (
587
+ f"Unable to create location with given x_dir { x_dir } . "
588
+ f"x_dir must be perpendicular to shape's tangent "
589
+ f"{ tuple (Vector (tangent ))} ."
590
+ )
591
+
557
592
else :
558
593
transformation .SetTransformation (
559
594
gp_Ax3 (pnt , gp_Dir (tangent .XYZ ()), gp_Dir (normal .XYZ ())), gp_Ax3 ()
560
595
)
596
+ loc = Location (TopLoc_Location (transformation ))
561
597
562
- return Location ( TopLoc_Location ( transformation ))
598
+ return loc
563
599
564
600
def locations (
565
601
self ,
566
602
distances : Iterable [float ],
567
603
position_mode : PositionMode = PositionMode .PARAMETER ,
568
604
frame_method : FrameMethod = FrameMethod .FRENET ,
569
- planar : bool = False ,
605
+ planar : bool | None = None ,
606
+ x_dir : VectorLike | None = None ,
570
607
) -> list [Location ]:
571
608
"""Locations along curve
572
609
@@ -579,13 +616,21 @@ def locations(
579
616
frame_method (FrameMethod, optional): moving frame calculation method.
580
617
Defaults to FrameMethod.FRENET.
581
618
planar (bool, optional): planar mode. Defaults to False.
619
+ x_dir (VectorLike, optional): override the x_dir to help with plane
620
+ creation along a 1D shape. Must be perpendicalar to shapes tangent.
621
+ Defaults to None.
622
+
623
+ .. deprecated::
624
+ The `planar` parameter is deprecated and will be removed in a future release.
625
+ Use `x_dir` to specify orientation instead.
582
626
583
627
Returns:
584
628
list[Location]: A list of Location objects representing local coordinate
585
629
systems at the specified distances.
586
630
"""
587
631
return [
588
- self .location_at (d , position_mode , frame_method , planar ) for d in distances
632
+ self .location_at (d , position_mode , frame_method , planar , x_dir )
633
+ for d in distances
589
634
]
590
635
591
636
def normal (self ) -> Vector :
0 commit comments