polliwog/polyline/polyline.py
def cut_by_plane(self, plane):
        """
        Return a new Polyline which keeps only the part that is in front of the given
        plane.

        For open polylines, the plane must intersect the polyline exactly once.

        For closed polylines, the plane must intersect the polylint exactly
        twice, leaving a single contiguous segment in front.
        """
        from .cut_by_plane import cut_open_polyline_by_plane

        if self.is_closed and self.num_v > 1:
            signed_distances = plane.signed_distance(self.v)
            signs_of_verts = np.sign(signed_distances)
            # For closed polylines, roll the edges so the ones in front of the
            # plane start at index 1 and the one to be cut is at index 0. (If
            # that edge stops directly on the plane, it may not actually need
            # to be cut.) This reduces it to the open polyline intersection
            # problem.
            if signs_of_verts[-1] == 1:
                # e.g. signs_of_verts = np.array([1, -1, -1, 1, 1, 1, 1])
                vertices_not_in_front, = np.where(signs_of_verts != 1)
                roll = -vertices_not_in_front[-1]
            else:
                # e.g. signs_of_verts = np.array([-1, 1, 1, 1, 1, 1, -1, -1])
                vertices_in_front, = np.where(signs_of_verts == 1)
                if len(vertices_in_front) > 0:
                    roll = -vertices_in_front[0] + 1
                else:
                    roll = 0
            working_v = np.roll(self.v, roll, axis=0)
        else:
            working_v = self.v

        new_v = cut_open_polyline_by_plane(working_v, plane)
        return Polyline(v=new_v, is_closed=False)

        Return a new Polyline which keeps only the part that is in front of the given
        plane.

        For open polylines, the plane must intersect the polyline exactly once.

        For closed polylines, the plane must intersect the polylint exactly
        twice, leaving a single contiguous segment in front.
        
Return a new Polyline which keeps only the part that is in front of the given
plane.

For open polylines, the plane must intersect the polyline exactly once.

For closed polylines, the plane must intersect the polylint exactly
twice, leaving a single contiguous segment in front.
Return a new Polyline which keeps only the part that is in front of the given plane . For open polylines the plane must intersect the polyline exactly once . For closed polylines the plane must intersect the polylint exactly twice leaving a single contiguous segment in front .
def cut_by_plane(self, plane):
        from .cut_by_plane import cut_open_polyline_by_plane
        if self.is_closed and self.num_v > 1:
            signed_distances = plane.signed_distance(self.v)
            signs_of_verts = np.sign(signed_distances)
            if signs_of_verts[-1] == 1:
                vertices_not_in_front, = np.where(signs_of_verts != 1)
                roll = -vertices_not_in_front[-1]
            else:
                vertices_in_front, = np.where(signs_of_verts == 1)
                if len(vertices_in_front) > 0:
                    roll = -vertices_in_front[0] + 1
                else:
                    roll = 0
            working_v = np.roll(self.v, roll, axis=0)
        else:
            working_v = self.v
        new_v = cut_open_polyline_by_plane(working_v, plane)
        return Polyline(v=new_v, is_closed=False)
def cut_by_plane ( self , plane ) : from . cut_by_plane import cut_open_polyline_by_plane if self . is_closed and self . num_v > 1 : signed_distances = plane . signed_distance ( self . v ) signs_of_verts = np . sign ( signed_distances ) if signs_of_verts [ - 1 ] == 1 : vertices_not_in_front , = np . where ( signs_of_verts != 1 ) roll = - vertices_not_in_front [ - 1 ] else : vertices_in_front , = np . where ( signs_of_verts == 1 ) if len ( vertices_in_front ) > 0 : roll = - vertices_in_front [ 0 ] + 1 else : roll = 0 working_v = np . roll ( self . v , roll , axis = 0 ) else : working_v = self . v new_v = cut_open_polyline_by_plane ( working_v , plane ) return Polyline ( v = new_v , is_closed = False )
Return a new Polyline which keeps only the part that is in front of the given
plane.
Return a new Polyline which keeps only the part that is in front of the given plane .
"""
        Return a new Polyline which keeps only the part that is in front of the given
        plane.

        For open polylines, the plane must intersect the polyline exactly once.

        For closed polylines, the plane must intersect the polylint exactly
        twice, leaving a single contiguous segment in front.
        """ # For closed polylines, roll the edges so the ones in front of the # plane start at index 1 and the one to be cut is at index 0. (If # that edge stops directly on the plane, it may not actually need # to be cut.) This reduces it to the open polyline intersection # problem. # e.g. signs_of_verts = np.array([1, -1, -1, 1, 1, 1, 1]) # e.g. signs_of_verts = np.array([-1, 1, 1, 1, 1, 1, -1, -1])
self
plane