def __init__(self, orientation='height', line=LineSegment.from_points([Vec2(0, 0), Vec2(1, 0)]), alt_of=None): super(LineRepresentation, self).__init__(alt_of) self.line = line # extend the LineSegment to include a bounding_box field, planar doesn't have that originally self.line.bounding_box = BoundingBox.from_points(self.line.points) self.num_dim = 1 self.middle = line.mid self.alt_representations = [PointRepresentation(self.line.mid, self)] classes = [Landmark.END, Landmark.MIDDLE, Landmark.END] if orientation == 'height' \ else [Landmark.SIDE, Landmark.MIDDLE, Landmark.SIDE] self.landmarks = { 'start': Landmark('start', PointRepresentation(self.line.start), self, classes[0]), 'end': Landmark('end', PointRepresentation(self.line.end), self, classes[2]), 'middle': Landmark('middle', PointRepresentation(self.line.mid), self, classes[1]), }
def __init__(self, ratio=None, line=LineSegment.from_points([Vec2(0, 0), Vec2(1, 0)]), alt_of=None): super(LineRepresentation, self).__init__(alt_of) self.line = line # extend the LineSegment to include a bounding_box field, planar doesn't have that originally self.line.bounding_box = BoundingBox.from_points(self.line.points) self.num_dim = 1 self.middle = line.mid self.alt_representations = [PointRepresentation(self.line.mid, self)] self.ratio_limit = 2 if ratio is None or ratio >= self.ratio_limit: self.landmarks = { 'start': Landmark('start', PointRepresentation(self.line.start), self, Landmark.END), 'middle': Landmark('middle', PointRepresentation(self.line.mid), self, Landmark.MIDDLE), 'end': Landmark('end', PointRepresentation(self.line.end), self, Landmark.END), } else: self.landmarks = { 'start': Landmark('start', PointRepresentation(self.line.start), self, Landmark.SIDE), 'end': Landmark('end', PointRepresentation(self.line.end), self, Landmark.SIDE) }
def __init__(self, ratio=None, line=LineSegment.from_points([Vec2(0, 0), Vec2(1, 0)]), alt_of=None): super(LineRepresentation, self).__init__(alt_of) self.ratio = ratio self.line = line # extend the LineSegment to include a bounding_box field, planar doesn't have that originally self.line.bounding_box = BoundingBox.from_points(self.line.points) self.num_dim = 1 self.middle = line.mid self.alt_representations = [PointRepresentation(self.line.mid, self)] self.ratio_limit = 2 if ratio is None or ratio >= self.ratio_limit: self.landmarks = { 'start': Landmark('start', PointRepresentation(self.line.start), self, Landmark.END), 'middle': Landmark('middle', PointRepresentation(self.line.mid), self, Landmark.MIDDLE), 'end': Landmark('end', PointRepresentation(self.line.end), self, Landmark.END), } else: self.landmarks = { 'start': Landmark('start', PointRepresentation(self.line.start), self, Landmark.SIDE), 'end': Landmark('end', PointRepresentation(self.line.end), self, Landmark.SIDE) }