topologicpy.CSG module

class topologicpy.CSG.CSG

Bases: object

Methods

AddOperationVertex(graph, operation, a, b[, ...])

Adds an operation vertex to the graph that performs a CSG operation on two child vertices.

AddTopologyVertex(graph, topology[, matrix, ...])

Adds a topology vertex to the graph.

Connect(graph, vertexA, vertexB[, ...])

Connects two vertices in the graph with a directional edge from vertexA to vertexB.

Init()

Returns an initial empty graph.

Invoke(graph[, silent])

Traverses the graph and evaluates all CSG operations from leaves to root, returning the final result.

Topologies([xOffset, yOffset, zOffset, ...])

Places each geometry (using its centroid) at its corresponding vertex location in the graph.

static AddOperationVertex(graph, operation, a, b, matrix=None, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Adds an operation vertex to the graph that performs a CSG operation on two child vertices. For ordered operations, the order of a and b inputs is important.

Parameters
graphtopologic_core.Graph

The input graph.

operationstr

The operation to perform. One of “union”, “difference”, “intersection”, “xor”, “merge”, “impose”, “imprint”, “slice”.

atopologic_core.Vertex

The first input vertex.

btopologic_core.Vertex

The second input vertex.

matrixlist , optional

The desired 4X4 transformation matrix to apply to the result before any further operations. Default is None.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Vertex

The added vertex.

static AddTopologyVertex(graph, topology, matrix: list = None, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Adds a topology vertex to the graph.

Parameters
graphtopologic_core.Graph

The input graph.

topologytopologic_core.Topology

The input topology..

matrixlist , optional

The desired 4X4 transformation matrix to apply to the result before any further operations. Default is None.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Vertex

The added vertex.

static Connect(graph, vertexA, vertexB, tolerance: float = 0.0001, silent: bool = False)

Connects two vertices in the graph with a directional edge from vertexA to vertexB.

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex.

matrixlist , optional

The desired 4X4 transformation matrix to apply to the result before any further operations. Default is None.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Vertex

The added vertex.

static Init()

Returns an initial empty graph.

Parameters
Returns
topologic_core.Graph

The initialized empty graph.

static Invoke(graph, silent: bool = False)

Traverses the graph and evaluates all CSG operations from leaves to root, returning the final result.

Parameters
graphtopologic_core.Graph

The input graph.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Topology

The final topology.

Topologies(xOffset: float = 0, yOffset: float = 0, zOffset: float = 0, scale: float = 1, silent: bool = False)

Places each geometry (using its centroid) at its corresponding vertex location in the graph.

Parameters
graphtopologic_core.Graph

The input graph.

xOffsetfloat , optional

An additional x offset. Default is 0.

yOffsetfloat , optional

An additional y offset. Default is 0.

zOffsetfloat , optional

An additional z offset. Default is 0.

scalefloat , optional

A desired scale to resize the placed topologies. Default is 1.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of topologies placed at their corresponding location in the graph.