Geometry
CGAL-backed 2D types, GLM vector wrappers, meshes, and arrangements.
- class pyvcad.Point2
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.Point2) -> None
Default constructor creating a point at origin (0,0)
Example
>>> p = Point2() >>> print(f'({p.x()}, {p.y()})') (0.0, 0.0)
__init__(self: pyvcad.pyvcad.Point2, arg0: typing.SupportsFloat, arg1: typing.SupportsFloat) -> None
Create a 2D point with given x and y coordinates
- Parameters:
x (float) – X coordinate
y (float) – Y coordinate
Example
>>> p = Point2(1.0, 2.0) >>> print(f'({p.x()}, {p.y()})') (1.0, 2.0)
- x(self: pyvcad.pyvcad.Point2) float
Get the x coordinate of the point
- Returns:
X coordinate
- Return type:
float
- y(self: pyvcad.pyvcad.Point2) float
Get the y coordinate of the point
- Returns:
Y coordinate
- Return type:
float
- class pyvcad.Segment2
- __init__(self: pyvcad.pyvcad.Segment2, arg0: pyvcad.pyvcad.Point2, arg1: pyvcad.pyvcad.Point2) None
Create a 2D line segment between two points
- Parameters:
Example
>>> p1 = Point2(0.0, 0.0) >>> p2 = Point2(1.0, 1.0) >>> segment = Segment2(p1, p2) >>> source = segment.source() >>> target = segment.target() >>> print(f'From ({source.x()}, {source.y()}) to ({target.x()}, {target.y()})') From (0.0, 0.0) to (1.0, 1.0)
- source(self: pyvcad.pyvcad.Segment2) pyvcad.pyvcad.Point2
Returns the source point of the segment
- Returns:
The starting point of the segment
- Return type:
- target(self: pyvcad.pyvcad.Segment2) pyvcad.pyvcad.Point2
Returns the target point of the segment
- Returns:
The ending point of the segment
- Return type:
- class pyvcad.Vec2
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.Vec2) -> None
Default constructor creating a zero vector (0,0)
Example
>>> v = Vec2() >>> print(f'({v.x}, {v.y})') (0.0, 0.0)
__init__(self: pyvcad.pyvcad.Vec2, arg0: typing.SupportsFloat, arg1: typing.SupportsFloat) -> None
Create a 2D vector with given x and y components
- Parameters:
x (float) – X component
y (float) – Y component
Example
>>> v = Vec2(1.0, 2.0) >>> print(f'({v.x}, {v.y})') (1.0, 2.0)
- property x
X component of the vector
- property y
Y component of the vector
- class pyvcad.Vec3
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.Vec3) -> None
Default constructor creating a zero vector (0,0,0)
Example
>>> v = Vec3() >>> print(f'({v.x}, {v.y}, {v.z})') (0.0, 0.0, 0.0)
__init__(self: pyvcad.pyvcad.Vec3, arg0: typing.SupportsFloat, arg1: typing.SupportsFloat, arg2: typing.SupportsFloat) -> None
Create a 3D vector with given x, y, and z components
- Parameters:
x (float) – X component
y (float) – Y component
z (float) – Z component
Example
>>> v = Vec3(1.0, 2.0, 3.0) >>> print(f'({v.x}, {v.y}, {v.z})') (1.0, 2.0, 3.0)
__init__(self: pyvcad.pyvcad.Vec3, arg0: collections.abc.Sequence[typing.SupportsFloat]) -> None
Create a 3D vector from a list or tuple of 3 floats
Example
>>> v = Vec3([1.0, 2.0, 3.0]) >>> print(f'({v.x}, {v.y}, {v.z})') (1.0, 2.0, 3.0)
- property x
X component of the vector
- property y
Y component of the vector
- property z
Z component of the vector
- class pyvcad.Vec4
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.Vec4) -> None
Default constructor creating a zero vector (0,0,0,0)
Example
>>> v = Vec4() >>> print(f'({v.r}, {v.g}, {v.b}, {v.a})') (0.0, 0.0, 0.0, 0.0)
__init__(self: pyvcad.pyvcad.Vec4, arg0: typing.SupportsFloat, arg1: typing.SupportsFloat, arg2: typing.SupportsFloat, arg3: typing.SupportsFloat) -> None
Create a 4D vector with given r, g, b, and a components
- Parameters:
r (float) – Red component
g (float) – Green component
b (float) – Blue component
a (float) – Alpha component
Example
>>> v = Vec4(1.0, 0.0, 0.0, 1.0) # Red color with full opacity >>> print(f'({v.r}, {v.g}, {v.b}, {v.a})') (1.0, 0.0, 0.0, 1.0)
- property a
Alpha component of the vector
- property b
Blue component of the vector
- property g
Green component of the vector
- property r
Red component of the vector
- class pyvcad.Polygon2
- static Clip(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: collections.abc.Sequence[Polyline2]) tuple[list[pyvcad.pyvcad.Polygon2], list[Polyline2]]
- static Difference(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) list[pyvcad.pyvcad.Polygon2]
- static Intersection(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) list[pyvcad.pyvcad.Polygon2]
- static Offset(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: SupportsFloat) list[pyvcad.pyvcad.Polygon2]
- static Union(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) list[pyvcad.pyvcad.Polygon2]
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.Polygon2) -> None
__init__(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Point2]) -> None
__init__(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Vec2]) -> None
- bounding_box(self: pyvcad.pyvcad.Polygon2) tuple[pyvcad.pyvcad.Point2, pyvcad.pyvcad.Point2]
- diff(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Polygon2) list[pyvcad.pyvcad.Polygon2]
- do_clip(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[Polyline2]) tuple[list[pyvcad.pyvcad.Polygon2], list[Polyline2]]
- do_union(*args, **kwargs)
Overloaded function.
do_union(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Polygon2) -> list[pyvcad.pyvcad.Polygon2]
do_union(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) -> list[pyvcad.pyvcad.Polygon2]
- double_area(self: pyvcad.pyvcad.Polygon2) float
- draw(self: pyvcad.pyvcad.Polygon2) None
- holes(self: pyvcad.pyvcad.Polygon2) list[pyvcad.pyvcad.Polygon2]
- inside(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Point2) bool
- intersect(*args, **kwargs)
Overloaded function.
intersect(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Polygon2) -> list[pyvcad.pyvcad.Polygon2]
intersect(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) -> list[pyvcad.pyvcad.Polygon2]
- is_ccw(self: pyvcad.pyvcad.Polygon2) bool
- offset(self: pyvcad.pyvcad.Polygon2, arg0: SupportsFloat) list[pyvcad.pyvcad.Polygon2]
- on_boundary(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Point2) bool
- reverse(self: pyvcad.pyvcad.Polygon2) None
- set_holes(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) None
- simplify(self: pyvcad.pyvcad.Polygon2, tolerance: SupportsFloat = 0.001) None
- to_polyline(self: pyvcad.pyvcad.Polygon2) Polyline2
- class pyvcad.Polyline2
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.Polyline2) -> None
__init__(self: pyvcad.pyvcad.Polyline2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Point2]) -> None
__init__(self: pyvcad.pyvcad.Polyline2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Vec2]) -> None
- append(self: pyvcad.pyvcad.Polyline2, arg0: pyvcad.pyvcad.Polyline2) None
- length(self: pyvcad.pyvcad.Polyline2) float
- points(self: pyvcad.pyvcad.Polyline2) list[pyvcad.pyvcad.Point2]
- prepend(self: pyvcad.pyvcad.Polyline2, arg0: pyvcad.pyvcad.Polyline2) None
- reverse(self: pyvcad.pyvcad.Polyline2) None
- segments(self: pyvcad.pyvcad.Polyline2) list[pyvcad.pyvcad.Segment2]
- simplify(self: pyvcad.pyvcad.Polyline2, tolerance: SupportsFloat = 0.001) None
- translate(self: pyvcad.pyvcad.Polyline2, arg0: pyvcad.pyvcad.Point2) None
- class pyvcad.Arrangement2
A class representing a 2D arrangement of polygons and polylines. When polygons and polylines are inserted into the arrangement, they are split by each other and the resulting faces are stored in the arrangement.
- __init__(self: pyvcad.pyvcad.Arrangement2) None
Default constructor. Creates an Arrangement2 object.
- getBoundedFaces(self: pyvcad.pyvcad.Arrangement2) list[pyvcad.pyvcad.Polygon2]
Returns a list of all bounded faces in the arrangement.
- getUnboundedFaces(self: pyvcad.pyvcad.Arrangement2) list[pyvcad.pyvcad.Polygon2]
Returns a list of all unbounded faces in the arrangement.
- insert(*args, **kwargs)
Overloaded function.
insert(self: pyvcad.pyvcad.Arrangement2, polygon: pyvcad.pyvcad.Polygon2) -> None
Inserts a Polygon2 into the arrangement.
- Parameters:
polygon (Polygon2) – The polygon to insert.
insert(self: pyvcad.pyvcad.Arrangement2, polyline: pyvcad.pyvcad.Polyline2) -> None
Inserts a Polyline2 into the arrangement.
- Parameters:
polyline (Polyline2) – The polyline to insert.
- class pyvcad.TetrahedralMesh
Class representing a tetrahedral mesh using CGAL. Contains functions to build a mesh from a tree, write the mesh to an INP file
- __init__(self: pyvcad.pyvcad.TetrahedralMesh, arg0: CGAL::Mesh_complex_3_in_triangulation_3<CGAL::Mesh_3_regular_triangulation_3_wrapper<CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::Epick>, CGAL: :Mesh_triangulation_3<CGAL::Labeled_mesh_domain_3<CGAL::Epick, int, std: :__1::pair<int, int>>, CGAL: :Default, CGAL: :Parallel_tag, CGAL: :Default, CGAL: :Default>::Tds>, int, int>) None
Constructor that takes a C3t3 object.
- static from_tree(*args, **kwargs)
Overloaded function.
from_tree(arg0: pyvcad.pyvcad.Node, arg1: typing.SupportsFloat, arg2: typing.SupportsFloat, arg3: typing.SupportsFloat, arg4: typing.SupportsInt, arg5: typing.SupportsFloat) -> pyvcad.pyvcad.TetrahedralMesh
Creates a TetrahedralMesh from a tree using a static cell size.
from_tree(arg0: pyvcad.pyvcad.Node, arg1: typing.SupportsFloat, arg2: typing.SupportsFloat, arg3: typing.SupportsFloat, arg4: typing.SupportsInt, arg5: typing.SupportsFloat, arg6: typing.SupportsFloat, arg7: str) -> pyvcad.pyvcad.TetrahedralMesh
Creates a TetrahedralMesh from a tree using a variable cell size based on the material properties gradient.
- write_to_inp(self: pyvcad.pyvcad.TetrahedralMesh, arg0: str, arg1: MaterialDefs, arg2: pyvcad.pyvcad.Node) None
Writes the tetrahedral mesh to an INP file.
- class pyvcad.HexahedralMesh
Class representing a hexahedral mesh.
- __init__(self: pyvcad.pyvcad.HexahedralMesh, node: pyvcad.pyvcad.Node, x_vox: SupportsInt, y_vox: SupportsInt, z_vox: SupportsInt) None
Constructor that takes a root node and voxel counts.
- bounding_box(self: pyvcad.pyvcad.HexahedralMesh) tuple[pyvcad.pyvcad.Vec3, pyvcad.pyvcad.Vec3]
Returns the mesh bounding box.
- compute(self: pyvcad.pyvcad.HexahedralMesh) None
Computes the hexahedral mesh based on the root node and voxel counts.
- elements(self: pyvcad.pyvcad.HexahedralMesh) list[tuple[int, int, int, int, int, int, int, int]]
Returns the mesh elements.
- material_assignments(self: pyvcad.pyvcad.HexahedralMesh) dict[int, list[int]]
Returns the material assignments.
- nodes(self: pyvcad.pyvcad.HexahedralMesh) list[pyvcad.pyvcad.Vec3]
Returns the mesh nodes.