kumiki.csg.pathcsg¶
Flat import path
kumiki/__init__.py re-exports everything on this page via from kumiki import *, so every name below is also available directly as kumiki.PathSegment -- you do not need to import from the submodule path shown in the heading above.
kumiki.csg.pathcsg
¶
Path-based CSG: FancyPath, a closed 2D boundary of straight and arc segments, and PathExtrusion, which extrudes one along its local Z.
Unlike ConvexPolygonExtrusion the boundary may be concave. Curved sides carry no plane, so they are never measurable.
PathExtrusionFeatureKey
module-attribute
¶
PathExtrusionFeatureKey = Union[ExtrusionCap, FlatSide, CurvedSide]
PathSegment
dataclass
¶
Bases: ABC
One segment of a closed FancyPath, in the path's local 2D plane.
is_planar
abstractmethod
¶
ray_crossings
abstractmethod
¶
Return the x values where this segment crosses height y.
inclusive=False counts each crossing at a shared vertex once (for parity tests);
inclusive=True includes the segment's own endpoints (for convex decomposition).
Source code in kumiki/csg/pathcsg.py
closest_point
abstractmethod
¶
outward_local_normal
abstractmethod
¶
Return the 2D outward normal at point on this segment, assuming a CCW path.
bounds
abstractmethod
¶
tessellate
abstractmethod
¶
tessellate(tolerance: float) -> List[V2]
Return points approximating this segment for meshing, excluding start and including end.
tessellate_with_extra_breaks
abstractmethod
¶
Like tessellate(), plus a vertex at each y in other_breaks within this segment's y range.
Keeps the wall mesh's vertices matching the cap pieces' seams.
Source code in kumiki/csg/pathcsg.py
sample_interior
abstractmethod
¶
Return mesh points strictly between point_lo and point_hi on this segment, in that order.
Uses the same sample grid as tessellate() so cap and wall meshes share vertices. Empty for a straight segment.
Source code in kumiki/csg/pathcsg.py
reverse
abstractmethod
¶
reverse() -> PathSegment
StraightSegment
dataclass
¶
Bases: PathSegment
A straight segment of a path, between two 2D points.
is_planar
¶
ray_crossings
¶
Source code in kumiki/csg/pathcsg.py
closest_point
¶
Source code in kumiki/csg/pathcsg.py
outward_local_normal
¶
bounds
¶
Source code in kumiki/csg/pathcsg.py
tessellate_with_extra_breaks
¶
Source code in kumiki/csg/pathcsg.py
sample_interior
¶
reverse
¶
reverse() -> StraightSegment
ArcSegment
dataclass
¶
Bases: PathSegment
A circular arc from start_angle, sweeping sweep_angle: CCW if positive, CW if negative.
abs(sweep_angle) is in (0, 2*pi]. The sign picks which of the two arcs between the endpoints.
is_planar
¶
ray_crossings
¶
Source code in kumiki/csg/pathcsg.py
closest_point
¶
Source code in kumiki/csg/pathcsg.py
outward_local_normal
¶
Source code in kumiki/csg/pathcsg.py
bounds
¶
Source code in kumiki/csg/pathcsg.py
signed_area_contribution
¶
signed_area_contribution() -> Numeric
Source code in kumiki/csg/pathcsg.py
tessellate_with_extra_breaks
¶
Source code in kumiki/csg/pathcsg.py
sample_interior
¶
Source code in kumiki/csg/pathcsg.py
reverse
¶
reverse() -> ArcSegment
Source code in kumiki/csg/pathcsg.py
FancyPath
dataclass
¶
A closed loop of segments, each ending where the next starts.
Not validated on construction; call is_valid().
is_valid
¶
Return whether the loop has a segment, closes, and winds CCW.
Self-intersection isn't checked; a self-intersecting path is undefined behaviour.
Source code in kumiki/csg/pathcsg.py
bounds
¶
Source code in kumiki/csg/pathcsg.py
locate_boundary_segment
¶
locate_boundary_segment(point: V2, eps: Optional[Numeric] = None) -> Optional[Tuple[int, PathSegment]]
Return the first segment point lies on, or None if it isn't on the boundary.
Source code in kumiki/csg/pathcsg.py
is_point_on_boundary_2d
¶
contains_point_2d
¶
Source code in kumiki/csg/pathcsg.py
tessellate
¶
tessellate(tolerance: float) -> Profile
Return the path as a point list, for an outline. Use tessellate_for_mesh for a PathExtrusion's wall.
Source code in kumiki/csg/pathcsg.py
tessellate_for_mesh
¶
tessellate_for_mesh(tolerance: float) -> Profile
Return the path as a point list with a vertex at every seam decompose_path_into_convex_pieces makes.
Source code in kumiki/csg/pathcsg.py
FlatSide
dataclass
¶
Key of the side extruded from a straight segment.
CurvedSide
dataclass
¶
Key of the side extruded from an arc. Has no plane, so is never measurable.
SimplePathExtrusionFeature
dataclass
¶
Bases: _PathExtrusionFeature, FaceFeature
A flat side (FlatSide key) or an end cap of a PathExtrusion.
SimplePathExtrusionCurvedFeature
dataclass
¶
Bases: _PathExtrusionFeature, CurvedFaceFeature
A curved side of a PathExtrusion. Has no plane.
__post_init__
¶
PathExtrusion
dataclass
¶
Bases: HasFeatures, CutCSG
Extrusion of a closed FancyPath (may be concave) along local Z.
The path is in the local XY plane at transform; it extends -z by start_distance and +z by
end_distance, as ConvexPolygonExtrusion.
transform
class-attribute
instance-attribute
¶
__repr__
¶
side
¶
side(index: int) -> PathExtrusionFeatureKey
Return the key for side index: FlatSide or CurvedSide as the segment is.
feature
¶
feature(name: str, key: PathExtrusionFeatureKey, **rest) -> _PathExtrusionFeature
Return a feature of this extrusion; pass extrusion.side(n) for a side.
Source code in kumiki/csg/pathcsg.py
carriers
¶
carriers() -> Dict[FeatureKey, Carrier]
contains_point
¶
Source code in kumiki/csg/pathcsg.py
is_point_on_boundary
¶
Source code in kumiki/csg/pathcsg.py
get_outward_normal
¶
get_outward_normal(point: V3, eps: Optional[Numeric] = None) -> Optional[Direction3D]
Source code in kumiki/csg/pathcsg.py
get_aabb
¶
get_aabb() -> AxisAlignedBoundingBox
Source code in kumiki/csg/pathcsg.py
get_convex_hull
¶
Return the convex hull of the path's segment start points, extruded.
KNOWN BUG: an arc bulging outward lies outside this hull, so the bound is too small.
Source code in kumiki/csg/pathcsg.py
plane_sides
¶
Return the union of its convex pieces' plane_sides.
Source code in kumiki/csg/pathcsg.py
decompose_path_into_convex_pieces
¶
Split a FancyPath into convex polygons (point lists), sweeping horizontal bands over its segments.
Band corners are exact; curved band edges are sampled at tolerance.
Source code in kumiki/csg/pathcsg.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | |
is_cap
¶
is_cap(key: PathExtrusionFeatureKey) -> bool
side_index
¶
side_index(key: PathExtrusionFeatureKey) -> int
Return the segment index a side key names. Raises for a cap.