topologicpy.CSG module
- class topologicpy.CSG.CSG
Bases:
objectParametric, provenance-aware constructive solid geometry over TGraph.
TGraph is the public expression/dependency graph. Runtime geometry, caches, dirty state and OCCT/BRepGraph lineage are deliberately kept outside the serialisable TGraph and are private implementation details.
The graph contains two vertex kinds:
source: a TopologicPy topology stored as the TGraph vertex representation.operation: an abstract CSG operation. Directed operand edges point from dependencies to the operation and carry an integeroperandrole.
Evaluation is incremental. Each node is fingerprinted from its expression data and input fingerprints; unchanged nodes reuse their cached topology. PythonOCC operations capture exact BRepTools/BRepGraph lineage through the private provenance hook when available. No BRepGraph identifiers escape this public class.
Methods
ByData(data[, silent])Reconstruct a CSG TGraph from
Data().ClearRuntime([graph])Drop private evaluation/cache/lineage state without changing TGraph data.
Compile(graph[, force])Compile the TGraph into an O(V+E) CSG evaluation plan.
Data(graph[, includeBREP])Return a persistence-safe CSG dictionary.
Descendants(graph, topology[, operation])Trace a source subtopology forward through captured exact lineage.
Evaluate(graph[, node, cache, lineage, silent])Evaluate one CSG node, reusing unchanged subexpressions.
History(graph[, operation, relation, ...])Return backend-neutral exact lineage records captured during evaluation.
Init([dictionary])Return an empty directed CSG expression TGraph.
Invalidate(graph[, node, downstream])Invalidate cached evaluation and lineage state.
LineageGraph(graph[, operation, ...])Return captured subtopology lineage as a TGraph.
Operation(graph, operation, inputs[, name, ...])Add an operation node and directed operand edges.
Origins(graph, topology[, operation])Trace a result subtopology backwards to source expression nodes.
Rewire(graph, operationNode, inputs[, silent])Replace all operand edges of an operation node.
SetSource(graph, node, topology[, data, silent])Replace a source topology and invalidate only dependent cached nodes.
Source(graph, topology[, name, data, silent])Add a source topology node and return its stable TGraph index.
ByJSONString
ByPath
DeletedBy
Difference
Export
GeneratedBy
Impose
Imprint
Intersect
JSONString
Leaves
Merge
ModifiedBy
Result
Roots
Slice
Status
Transform
UnchangedBy
Union
Validate
XOR
- static ByJSONString(string: str, silent: bool = False)
- static ByPath(path: str, silent: bool = False)
- static ClearRuntime(graph=None) None
Drop private evaluation/cache/lineage state without changing TGraph data.
- static Compile(graph, force: bool = False) Optional[dict]
Compile the TGraph into an O(V+E) CSG evaluation plan.
- static Data(graph, includeBREP: bool = True) Optional[dict]
Return a persistence-safe CSG dictionary.
- static DeletedBy(graph, operation, topologyType: Optional[str] = None) list
- static Descendants(graph, topology, operation: Any = None) list
Trace a source subtopology forward through captured exact lineage.
- static Difference(graph, a, b, **kwargs)
- static Evaluate(graph, node: Any = None, cache: bool = True, lineage: bool = True, silent: bool = False)
Evaluate one CSG node, reusing unchanged subexpressions.
- static Export(graph, path: str, indent: int = 2, overwrite: bool = False, silent: bool = False) Optional[bool]
- static GeneratedBy(graph, operation, topologyType: Optional[str] = None) list
- static History(graph, operation: Any = None, relation: Optional[str] = None, sourceNode: Any = None, resultType: Optional[str] = None) list
Return backend-neutral exact lineage records captured during evaluation.
- static Impose(graph, a, b, **kwargs)
- static Imprint(graph, a, b, **kwargs)
- static Init(dictionary: Optional[dict] = None)
Return an empty directed CSG expression TGraph.
- static Intersect(graph, *inputs, **kwargs)
- static Invalidate(graph, node: Any = None, downstream: bool = True) bool
Invalidate cached evaluation and lineage state.
- static JSONString(graph, indent: Optional[int] = None) Optional[str]
- static Leaves(graph) list
- static LineageGraph(graph, operation: Any = None, topologyType: Optional[str] = None, detailed: bool = False, includeDeleted: bool = False)
Return captured subtopology lineage as a TGraph.
This is intentionally a derived TGraph. BRepGraph stays private.
- static Merge(graph, *inputs, **kwargs)
- static ModifiedBy(graph, operation, topologyType: Optional[str] = None) list
- OPERATION = 'operation'
- static Operation(graph, operation: str, inputs: Sequence[Any], name: Optional[str] = None, matrix: Optional[Sequence[Sequence[float]]] = None, data: Optional[dict] = None, silent: bool = False) Optional[int]
Add an operation node and directed operand edges.
Operand ordering is encoded only on edges (
operand=0,1,...). This removes the duplicateda_id/b_idstate of the experimental CSG.
- static Origins(graph, topology, operation: Any = None) list
Trace a result subtopology backwards to source expression nodes.
- static Result(graph, node: Any = None)
- static Rewire(graph, operationNode, inputs: Sequence[Any], silent: bool = False) bool
Replace all operand edges of an operation node.
- static Roots(graph) list
- SCHEMA = 'topologicpy.csg/2'
- SOURCE = 'source'
- static SetSource(graph, node, topology, data: Optional[dict] = None, silent: bool = False) bool
Replace a source topology and invalidate only dependent cached nodes.
- static Slice(graph, a, b, **kwargs)
- static Source(graph, topology, name: Optional[str] = None, data: Optional[dict] = None, silent: bool = False) Optional[int]
Add a source topology node and return its stable TGraph index.
- static Status(graph) dict
- static Transform(graph, source, matrix, **kwargs)
- static UnchangedBy(graph, operation, topologyType: Optional[str] = None) list
- static Union(graph, *inputs, **kwargs)
- static Validate(graph) dict
- static XOR(graph, *inputs, **kwargs)