Shape
- class Shape(lines: List[Line], arcs: List[Arc], points: List[Point], *, maximal: bool = False, update_carrier_attrs: bool = False)
A
Shaperepresents a collection of shape elements (seeShapeElement) that can be queried and modified. This is the primary unit of computation within Shape Machine.- Parameters:
lines – The
Lineinstances in this shape.arcs – The
Arcinstances in this shape.points – The
Pointinstances in this shape.maximal – Whether this shape is maximal or not. If
False,maximize_and_recalibrate()is called in__init__to maximize the geometry of the shape.update_carrier_attrs – If
True, carrier attribute sets (attributes_set) will be recomputed.
Attributes
Returns
Trueif all carriers in this shape are concentric.A list of all
Carrierinstances underlying the geometry of this shape.The center of this shape.
A mapping of
id(carrier)to allShapeElementinstances in this shape that havecarrieras theircarrierattribute.A special
ShapeSignaturemade of registration points (RegistrationPoint) at each point carrier (PointCarrier) and their perpendicular projection onto each line carrier (Line).This shape's
ShapeSignature.The
Lineinstances in this shape.The
Arcinstances in this shape.The
Pointinstances in this shape.Methods
Returns
self - self.center.Compute the boolean difference between this shape and another.
Returns true if for each
ShapeElementain this shape, there is an elementbinothersuch thata.equivalent_to(b)returnsTrueand that no other element in this shape is equivalent tob.Returns
Trueif for eachShapeElementain this shape, there is an elementbinothersuch thata.is_embedded_in(b)returnsTrue.Maximizes this shape in place and returns the newly maximized shape.
Computes all transformations
t(seeTransformation) of typequery_transformationsuch thatt @ query.shape <= selfreturnsTrue.Apply a
Transformationto all elements in this shape.Compute the boolean union between this shape and another.
- __add__(other: ndarray[3] | Shape) Shape
Shifts a shape by
other(ifotheris a vector) or performsunion()(ifotheris aShape).
- __bool__()
Returns
Trueif this shape is nonempty.
- __le__(other: Shape)
Calls
is_embedded_in().
- __len__()
Returns the number of elements (see
ShapeElement) in this shape.
- __rmatmul__(transformation: Transformation) T_co
Computes
transformable.transform(t)when performingt @ transformablefor aTransformationtandTransformabletransformable.
- __sub__(other: ndarray[3] | Shape) Shape
Shifts a shape by
-other(ifotheris a vector) or performsdifference()(ifotheris aShape).
- difference(other: Shape, maximize: bool = True) Shape
Compute the boolean difference between this shape and another.
- Parameters:
other – The other shape.
maximize – If
True, maximize the resulting shape.
- Returns:
The difference of this shape and the other shape.
- equivalent_to(other: Shape) bool
Returns true if for each
ShapeElementain this shape, there is an elementbinothersuch thata.equivalent_to(b)returnsTrueand that no other element in this shape is equivalent tob.
- filter(predicate: Callable[[ShapeElement], Any]) Shape
- filtered_to_attributes(attributes: Set[ElementAttributes]) Shape
- is_embedded_in(other: Shape) bool
Returns
Trueif for eachShapeElementain this shape, there is an elementbinothersuch thata.is_embedded_in(b)returnsTrue.
- maximize_and_recalibrate() Shape
Maximizes this shape in place and returns the newly maximized shape.
- query(query: ShapeQuery) List[Transformation]
Computes all transformations
t(seeTransformation) of typequery_transformationsuch thatt @ query.shape <= selfreturnsTrue. Currently only implemented for transformations of typeIsometry,Similarity, andAffinity.- Parameters:
query – The
ShapeQueryto use for computing transformations.- Returns:
All transformations
tof typequery_transformationsuch thatt @ query_shape <= selfreturnsTrue.
- transform(transformation: Transformation) Shape
Apply a
Transformationto all elements in this shape.
- union(other: Shape, maximize: bool = True) Shape
Compute the boolean union between this shape and another.
- Parameters:
other – The other shape.
maximize – If
True, maximize the resulting shape.
- Returns:
The union of this shape and the other shape.
- property all_attributes: Set[ElementAttributes]
- property carriers: List[Carrier]
A list of all
Carrierinstances underlying the geometry of this shape. Provided as line carriers (LineCarrier), then arc carriers (ArcCarrier), then point carriers (PointCarrier).
- property elements_by_carrier_id: Dict[int, List[ShapeElement]]
A mapping of
id(carrier)to allShapeElementinstances in this shape that havecarrieras theircarrierattribute.
- property point_line_perpendicular_signature: ShapeSignature
A special
ShapeSignaturemade of registration points (RegistrationPoint) at each point carrier (PointCarrier) and their perpendicular projection onto each line carrier (Line).The
spokesof each registration point are computed for the registration points on line carriers.
- property signature: ShapeSignature
This shape’s
ShapeSignature.A shape’s signature is created by marking all intersection locations of
carriers. ARegistrationPointis placed at each intersection withsignatureset as follows:If the registration point is coincident with a
PointCarrieror the center of aArcCarrier, itsdirect_attributesincludes that carrier’sattributes_set.If the registration point is coincident to a
LineCarrier, itsspokeswill include two spokes corresponding to that carrier.Each spoke corresponds to the half of the carrier in that direction.
If there is not a
Linein that direction from the registration point, the spoke’s type will be set toEMPTY.If there is a line in this direction, the spoke’s type will be set to
FILLED.