3232from openglider .vector .projection import flatten_list
3333from openglider .utils import Config
3434
35+ from openglider_cpp import euklid
3536
3637from typing import TYPE_CHECKING
3738if TYPE_CHECKING :
@@ -118,9 +119,9 @@ def get_list(rib, cut_front, cut_back):
118119 side = - cut_front [1 ] # -1 -> lower, 1->upper
119120 front = rib .profile_2d (cut_front [0 ] * side )
120121 back = rib .profile_2d (cut_back [0 ] * side )
121- return rib .profile_3d [front :back ]
122+ return euklid . PolyLine3D ( rib .profile_3d [front :back ]. data . tolist ())
122123 else :
123- return PolyLine ([rib .align (rib .profile_2d .align (p ) + [0 ]) for p in (cut_front , cut_back )])
124+ return euklid . PolyLine3D ([rib .align (rib .profile_2d .align (p ) + [0 ]) for p in (cut_front , cut_back )])
124125
125126 left = get_list (cell .rib1 , self .left_front , self .left_back )
126127 right = get_list (cell .rib2 , self .right_front , self .right_back )
@@ -190,7 +191,7 @@ def get_mesh(self, cell, insert_points=4, project_3d=False):
190191 polygon = [range (len (vertices ))]
191192 return Mesh .from_indexed (vertices , {"diagonals" : polygon })
192193
193- def get_flattened (self , cell , ribs_flattened = None ) -> Tuple [ PolyLine2D , PolyLine2D ] :
194+ def get_flattened (self , cell , ribs_flattened = None ):
194195 first , second = self .get_3d (cell )
195196 left , right = flatten_list (first , second )
196197 return left , right
@@ -525,28 +526,17 @@ def _get_ik_values(self, cell: "openglider.glider.cell.Cell", numribs=0, exact=T
525526 if exact :
526527 ik_values_new = []
527528 inner = cell .get_flattened_cell (numribs )["inner" ]
528- p_front_left = inner [0 ][ ik_left_front ]
529- p_front_right = inner [- 1 ][ ik_right_front ]
530- p_back_left = inner [0 ][ ik_left_back ]
531- p_back_right = inner [- 1 ][ ik_right_back ]
529+ p_front_left = inner [0 ]. get ( ik_left_front )
530+ p_front_right = inner [- 1 ]. get ( ik_right_front )
531+ p_back_left = inner [0 ]. get ( ik_left_back )
532+ p_back_right = inner [- 1 ]. get ( ik_right_back )
532533
533534 for i , ik in enumerate (ik_values ):
534535 ik_front , ik_back = ik
535- line : openglider .vector .PolyLine2D = inner [i ]
536-
537- _cut_front = line .cut (p_front_left , p_front_right , ik_front , True )
538- _cut_back = line .cut (p_back_left , p_back_right , ik_back , True )
539-
540- try :
541- _ik_front = next (_cut_front )[0 ]
542- except StopIteration :
543- _ik_front = ik_front
544- logging .warning (f"panel_ik_failure: { ik_front } { cell } /{ self } /back" )
545- try :
546- _ik_back = next (_cut_back )[0 ]
547- except StopIteration :
548- _ik_back = ik_back
549- logging .warning (f"panel_ik_failure: { ik_front } { cell } /{ self } /back" )
536+ line : euklid .PolyLine2D = inner [i ]
537+
538+ _ik_front , _ = line .cut (p_front_left , p_front_right , ik_front )
539+ _ik_back , _ = line .cut (p_back_left , p_back_right , ik_back )
550540
551541 ik_values_new .append ((_ik_front , _ik_back ))
552542
@@ -594,7 +584,7 @@ def integrate_3d_shaping(self, cell: "Cell", sigma, inner_2d, midribs=None):
594584
595585 for rib_no in range (numribs + 2 ):
596586 x1 , x2 = positions [rib_no ]
597- rib_2d = inner_2d [rib_no ][ x1 : x2 ]
587+ rib_2d = inner_2d [rib_no ]. get ( x1 , x2 )
598588 rib_3d = ribs [rib_no ][x1 :x2 ]
599589
600590 lengthes_2d = rib_2d .get_segment_lengthes ()
@@ -682,7 +672,7 @@ def __json__(self):
682672 def _get_flattened_line (self , cell ):
683673 flattened_cell = cell .get_flattened_cell ()
684674 left , right = flattened_cell ["ballooned" ]
685- line = ( left * ( 1 - self . y )). add (right * self .y )
675+ line = left . mix (right , self .y )
686676
687677 ik_front = (cell .rib1 .profile_2d (self .x_start ) + cell .rib2 .profile_2d (self .x_start ))/ 2
688678 ik_back = (cell .rib1 .profile_2d (self .x_end ) + cell .rib2 .profile_2d (self .x_end ))/ 2
@@ -699,18 +689,20 @@ def draw_panel_marks(self, cell, panel):
699689 stop = min (ik_back , ik_interpolation_back (self .y ))
700690
701691 if start < stop :
702- return line [ start : stop ]
692+ return line . get ( start , stop )
703693
704694 return None
705695
706696 def get_flattened (self , cell ):
707697 line , ik_front , ik_back = self ._get_flattened_line (cell )
708698
709- left = line .copy ().add_stuff (- self .channel_width / 2 )
710- right = line .copy ().add_stuff (self .channel_width / 2 )
699+ left = line .offset (- self .channel_width / 2 )
700+ right = line .offset (self .channel_width / 2 )
701+
702+ contour = left .get (ik_front , ik_back ) + right .get (ik_back , ik_front )
711703
712- contour = left [ ik_front : ik_back ] + right [ ik_back : ik_front ]
713- contour .close ()
704+ # todo!
705+ # contour.close()
714706
715707 marks = []
716708
@@ -723,7 +715,7 @@ def get_flattened(self, cell):
723715
724716 for ik in panel_iks :
725717 if ik_front < ik < ik_back :
726- marks .append (openglider . vector .PolyLine2D ([
718+ marks .append (openglider_cpp . euklid .PolyLine2D ([
727719 left [ik ],
728720 right [ik ]
729721 ]))
0 commit comments