compas_cgal.straight_skeleton_2
¤
Functions¤
graph_from_skeleton_data
¤
graph_from_skeleton_data(
points: VerticesNumpy, indices: IntNx1, edges: IntNx2, edge_types: IntNx1
) -> Graph
Create a graph from the skeleton data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
VerticesNumpy
|
The vertices of the skeleton, each vertex defined by 3 spatial coordinates. |
required |
indices
|
IntNx1
|
The vertex indices of the skeleton, corresponding to the points. |
required |
edges
|
IntNx2
|
The edges of the skeleton, each edge defined by 2 vertex indices. |
required |
edge_types
|
IntNx1
|
The type per edge, |
required |
Returns:
| Type | Description |
|---|---|
Graph
|
The skeleton as a graph. |
interior_straight_skeleton
¤
interior_straight_skeleton(
points, as_graph=True
) -> Graph | tuple[VerticesNumpy, IntNx1, IntNx2, IntNx1]
Compute the skeleton of a 2D polygon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
The points of the polygon. |
required | |
as_graph
|
Whether the skeleton should be returned as a graph, defaults to |
True
|
Returns:
| Type | Description |
|---|---|
Graph | tuple[VerticesNumpy, IntNx1, IntNx2, IntNx1]
|
The skeleton of the polygon. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the normal of the polygon is not directed vertically upwards like [0, 0, 1]. |
interior_straight_skeleton_with_holes
¤
interior_straight_skeleton_with_holes(
points, holes, as_graph=True
) -> Graph | tuple[VerticesNumpy, IntNx1, IntNx2, IntNx1]
Compute the skeleton of a 2D polygon with holes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
The points of the 2D polygon. |
required | |
holes
|
The holes of the polygon. |
required | |
as_graph
|
Whether the skeleton should be returned as a graph, defaults to |
True
|
Returns:
| Type | Description |
|---|---|
Graph | tuple[VerticesNumpy, IntNx1, IntNx2, IntNx1]
|
The skeleton of the polygon. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the normal of the polygon is not directed vertically upwards like [0, 0, 1]. If the normal of a hole is not directed vertically downwards like [0, 0, -1]. |
offset_polygon
¤
Compute the offset from a 2D polygon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
The points of the 2D polygon. |
required | |
offset
|
The offset distance. If negative, the offset is outside the polygon, otherwise inside. |
required |
Returns:
| Type | Description |
|---|---|
list[Polygon]
|
The offset polygon(s). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the normal of the polygon is not directed vertically upwards like [0, 0, 1]. |
offset_polygon_with_holes
¤
Compute the offset from a 2D polygon with holes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
The points of the 2D polygon. |
required | |
holes
|
The holes of the polygon. |
required | |
offset
|
The offset distance. If negative, the offset is outside the polygon, otherwise inside. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[Polygon, list[Polygon]]]
|
The polygons with holes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the normal of the polygon is not directed vertically upwards like [0, 0, 1]. If the normal of a hole is not directed vertically downwards like [0, 0, -1]. |
weighted_offset_polygon
¤
Compute the offset from a 2D polygon with weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
The points of the 2D polygon. |
required | |
offset
|
The offset distance. If negative, the offset is outside the polygon, otherwise inside. |
required | |
weights
|
The weights for each edge, starting with the edge between the last and the first point. |
required |
Returns:
| Type | Description |
|---|---|
list[Polygon]
|
The offset polygon(s). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the normal of the polygon is not directed vertically upwards like [0, 0, 1]. |
ValueError
|
If the number of weights does not match the number of points. |