77from  compas .geometry  import  BrepTrim 
88from  compas_rhino .geometry  import  RhinoNurbsCurve 
99
10+ from  .vertex  import  RhinoBrepVertex 
11+ 
1012
1113class  RhinoBrepTrim (BrepTrim ):
12-     """An interface for  a Brep Trim  
14+     """Trims hold topological information about how the edges of  a Brep face are are organized.  
1315
1416    Attributes 
1517    ---------- 
@@ -21,6 +23,12 @@ class RhinoBrepTrim(BrepTrim):
2123        True if this trim is reversed from its associated edge curve and False otherwise. 
2224    native_trim : :class:`Rhino.Geometry.BrepTrim` 
2325        The underlying Rhino BrepTrim object. 
26+     start_vertex : :class:`compas_rhino.geometry.RhinoBrepVertex`, read-only 
27+         The start vertex of this trim. 
28+     end_vertex : :class:`compas_rhino.geometry.RhinoBrepVertex`, read-only 
29+         The end vertex of this trim. 
30+     vertices : list[:class:`compas_rhino.geometry.RhinoBrepVertex`], read-only 
31+         The list of vertices which comprise this trim (start and end). 
2432
2533    """ 
2634
@@ -30,6 +38,8 @@ def __init__(self, rhino_trim=None):
3038        self ._curve  =  None 
3139        self ._is_reversed  =  None 
3240        self ._iso_type  =  None 
41+         self ._start_vertex  =  None 
42+         self ._end_vertex  =  None 
3343        if  rhino_trim :
3444            self .native_trim  =  rhino_trim 
3545
@@ -40,7 +50,8 @@ def __init__(self, rhino_trim=None):
4050    @property  
4151    def  __data__ (self ):
4252        return  {
43-             "vertex" : self ._trim .StartVertex .VertexIndex ,
53+             "start_vertex" : self ._trim .StartVertex .VertexIndex ,
54+             "end_vertex" : self ._trim .EndVertex .VertexIndex ,
4455            "edge" : self ._trim .Edge .EdgeIndex  if  self ._trim .Edge  else  - 1 ,  # singular trims have no associated edge 
4556            "curve" : RhinoNurbsCurve .from_rhino (self ._trim .TrimCurve .ToNurbsCurve ()).__data__ ,
4657            "iso" : str (self ._trim .IsoStatus ),
@@ -68,7 +79,7 @@ def __from_data__(cls, data, builder):
6879        curve  =  RhinoNurbsCurve .__from_data__ (data ["curve" ]).rhino_curve 
6980        iso_status  =  getattr (Rhino .Geometry .IsoStatus , data ["iso" ])
7081        is_reversed  =  True  if  data ["is_reversed" ] ==  "true"  else  False 
71-         instance .native_trim  =  builder .add_trim (curve , data ["edge" ], is_reversed , iso_status , data ["vertex " ])
82+         instance .native_trim  =  builder .add_trim (curve , data ["edge" ], is_reversed , iso_status , data ["start_vertex " ])
7283        return  instance 
7384
7485    # ============================================================================== 
@@ -79,6 +90,18 @@ def __from_data__(cls, data, builder):
7990    def  curve (self ):
8091        return  self ._curve 
8192
93+     @property  
94+     def  start_vertex (self ):
95+         return  self ._start_vertex 
96+ 
97+     @property  
98+     def  end_vertex (self ):
99+         return  self ._end_vertex 
100+ 
101+     @property  
102+     def  vertices (self ):
103+         return  [self .start_vertex , self .end_vertex ]
104+ 
82105    @property  
83106    def  is_reverse (self ):
84107        return  self ._curve 
@@ -97,3 +120,5 @@ def native_trim(self, rhino_trim):
97120        self ._curve  =  RhinoNurbsCurve .from_rhino (rhino_trim .TrimCurve .ToNurbsCurve ())
98121        self ._is_reversed  =  rhino_trim .IsReversed ()
99122        self ._iso_type  =  int (rhino_trim .IsoStatus )
123+         self ._start_vertex  =  RhinoBrepVertex (rhino_trim .StartVertex )
124+         self ._end_vertex  =  RhinoBrepVertex (rhino_trim .EndVertex )
0 commit comments