66from compas .geometry import Frame
77from compas .geometry import Point
88from compas .geometry import Polygon
9- from compas .geometry import bestfit_frame_numpy
9+
10+ # from compas.geometry import bestfit_frame_numpy
1011
1112
1213class Contact (Data ):
@@ -48,9 +49,9 @@ def __data__(self) -> dict:
4849
4950 def __init__ (
5051 self ,
51- points : Optional [ list [Point ]] = None ,
52- frame : Optional [ Frame ] = None ,
53- size : Optional [ float ] = None ,
52+ points : list [Point ],
53+ frame : Frame ,
54+ size : float ,
5455 mesh : Optional [Mesh ] = None ,
5556 name : Optional [str ] = None ,
5657 ):
@@ -76,22 +77,30 @@ def points(self) -> Union[list[Point], None]:
7677
7778 @points .setter
7879 def points (self , items : Union [list [Point ], list [list [float ]]]) -> None :
79- self ._points = []
80- for item in items :
81- self ._points .append (Point (* item ))
80+ previous = Point (* items [0 ])
81+ self ._points = [previous ]
82+ for xyz in items [1 :]:
83+ if previous == xyz :
84+ continue
85+ previous = Point (* xyz )
86+ self ._points .append (previous )
87+ if self ._points [0 ] == self ._points [- 1 ]:
88+ del self ._points [- 1 ]
8289
8390 @property
8491 def polygon (self ) -> Polygon :
8592 if self ._polygon is None :
8693 self ._polygon = Polygon (self .points )
94+ if self ._polygon .plane .normal .dot (self .frame .zaxis ) < 0 :
95+ self ._polygon .plane .normal .flip ()
8796 return self ._polygon
8897
8998 @property
9099 def frame (self ) -> Frame :
91- if self ._frame is None :
92- self ._frame = Frame (* bestfit_frame_numpy (self .points ))
93- if self ._frame .zaxis .dot (self .polygon .normal ) < 0 :
94- self ._frame .invert ()
100+ # if self._frame is None:
101+ # self._frame = Frame(*bestfit_frame_numpy(self.points))
102+ # if self._frame.zaxis.dot(self.polygon.normal) < 0:
103+ # self._frame.invert()
95104 return self ._frame
96105
97106 @property
0 commit comments