SearchRule
- class SearchRule(query: ShapeQuery)
A
SearchRulesearches for aShapein a design.Specifically, given a
queryu, and designw, it computes the transformationsf_ithat embeduinw. It then identifies all uniquef_i(u)(the symmetry ofuandwmight result in different transformations creating equivalentf_i(u)) and asks the user to choose a matchf_ito select. When the user selects a match,wwill be replaced byw - f_i(u),uwill be placed on top and then selected (using theCommunicationLayer’soutput_shape()method withselect=True). IfALLis selected,wis then replaced withw - Σf_i(u)andΣf_i(u)is placed on top and selected. The transformations are computed with thequery_transformation’scompute()method.- Parameters:
query – The
ShapeQueryto use when searching (u).
Attributes
The
RuleApplicationTypeto use when selecting a match to apply the rule to.Methods
- apply_to(shape: Shape, communication_layer: CommunicationLayer, in_automation: bool = False, _to_design: ndarray = array([0., 0., 0.])) Tuple[Rule, List[Tuple[Shape, Shape]], Shape, Shape, Shape, Shape]
-
- Parameters:
shape – The shape to apply this rule to.
communication_layer – The
CommunicationLayerto use during rule application.in_automation – Whether this rule is being applied as part of an automation (e.g.: as part of a
RuleSequenceorProgram)._to_design – Vector used to relocate the matches to the design in application previews and enumerations. This is needed because the
ShapeMachineengine internally shifts itsinitial_designto the origin to reduce floating-point error.
- Returns:
The shape created as a result of rule application.
- application_type
The
RuleApplicationTypeto use when selecting a match to apply the rule to.