sketchgraphs.data.constraint_checks

This module implements a basic constraint checker for a solved graph.

This module implements a number of functions to help check basic relational constraints between entities. Note that only checking is implemented: this is not an implementation of a solver, and cannot solve for the desired constraints.

Functions

sketchgraphs.data.constraint_checks.check_edge_satisfied(seq, op: sketchgraphs.data.sequence.EdgeOp)

Determines whether the given EdgeOp instance is geometrically satisfied in the graph represented by seq.

Parameters
  • seq (List[Union[EdgeOp, NodeOp]]) – A construction sequence representing the underlying graph.

  • op (EdgeOp) – An edge op to check for validity in the current graph.

Returns

True if the current edge constraint is satisified, otherwise False.

Return type

bool

Raises

ValueError – If the current constraint is not supported (e.g. its type is not supported), or it refers to an external entity, which is not supported.

sketchgraphs.data.constraint_checks.coincident(*entities)
sketchgraphs.data.constraint_checks.concentric(*ents)
sketchgraphs.data.constraint_checks.equal(*ents)
sketchgraphs.data.constraint_checks.get_entity_by_idx(seq, idx: int)sketchgraphs.data._entity.Entity

Returns the entity or sub-entity corresponding to idx.

Parameters
  • seq (List[Union[NodeOp, EdgeOp]]) – A list of node and edge operations representing the construction sequence.

  • idx (int) – An integer representing the index of the desired entity.

Returns

An entity object representing the entity corresponding to the NodeOp at the given index.

Return type

Entity

sketchgraphs.data.constraint_checks.get_sorted_types(entities)

Obtains the types and sorts the entities based on their type order.

Parameters

entities (iterable of Entity) – An list of entities to be sorted.

Returns

  • types (List) – A list of types representing the type of each entity

  • entities (List) – A list of entities, containing the same elements as the input iterable, but sorted in the order given by types.

sketchgraphs.data.constraint_checks.horizontal(*ents)
sketchgraphs.data.constraint_checks.midpoint(*ents)
sketchgraphs.data.constraint_checks.parallel(*ents)
sketchgraphs.data.constraint_checks.perpendicular(*ents)
sketchgraphs.data.constraint_checks.tangent(*ents)
sketchgraphs.data.constraint_checks.vertical(*ents)