-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from cadbuildr/3d-sweep
3d sweep
- Loading branch information
Showing
18 changed files
with
304 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# TODO | ||
from foundation.operations.base import Operation | ||
from foundation.types.node import Node | ||
|
||
from foundation.sketch.base import SketchElement | ||
from foundation.sketch.closed_sketch_shape import Circle, ClosedSketchShape | ||
from foundation.types.node_children import NodeChildren | ||
from foundation.sketch.sketch import Sketch | ||
|
||
from foundation.types.parameters import ( | ||
UnCastFloat, | ||
UnCastBool, | ||
cast_to_float_parameter, | ||
cast_to_bool_parameter, | ||
FloatParameter, | ||
BoolParameter, | ||
) | ||
from foundation.types.types_3d.curve import Curve3DTypes | ||
|
||
|
||
class SweepChildren(NodeChildren): | ||
profile: ClosedSketchShape | ||
path: Curve3DTypes | ||
sketch: Sketch | ||
|
||
# TODO could add more optional parameters here (frenet, ...) | ||
|
||
|
||
class Sweep(Operation, Node): | ||
children_class = SweepChildren | ||
|
||
def __init__( | ||
self, | ||
profile: ClosedSketchShape, | ||
path: Curve3DTypes, | ||
): | ||
|
||
Operation.__init__(self) | ||
Node.__init__(self, parents=[]) | ||
self.children.set_profile(profile) | ||
self.children.set_path(path) | ||
self.children.set_sketch(profile.sketch) | ||
|
||
# shortcuts | ||
self.profile = self.children.profile | ||
self.path = self.children.path | ||
|
||
self.params = {} | ||
|
||
|
||
SweepChildren.__annotations__["profile"] = ClosedSketchShape | ||
SweepChildren.__annotations__["path"] = Curve3DTypes | ||
SweepChildren.__annotations__["sketch"] = Sketch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,7 @@ | |
"CustomClosedShape": 30, | ||
"Arc": 31, | ||
"SVGShape": 32, | ||
"Helix3D": 33, | ||
"Sweep": 34, | ||
"Point3D": 35, | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
from foundation.types.node_interface import NodeInterface | ||
from foundation.types.node_children import NodeChildren | ||
from foundation.types.types_3d.point_3d import Point3D | ||
from foundation.types.node import Node | ||
from foundation.types.parameters import ( | ||
FloatParameter, | ||
BoolParameter, | ||
UnCastFloat, | ||
UnCastBool, | ||
cast_to_float_parameter, | ||
cast_to_bool_parameter, | ||
) | ||
|
||
|
||
class Curve3D(NodeInterface): | ||
"""Base class for 3D curves.""" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
|
||
class Line3DChildren(NodeChildren): | ||
start: Point3D | ||
end: Point3D | ||
|
||
|
||
class Line3D(Curve3D, Node): | ||
pass | ||
# TODO: Implement the following classes | ||
|
||
|
||
# 3 points define a unique arc (note : they need to be on the same plane) | ||
class Arc3DChildren(NodeChildren): | ||
p1: Point3D | ||
p2: Point3D | ||
p3: Point3D | ||
|
||
|
||
class Arc3D(Curve3D, Node): | ||
# TODO | ||
pass | ||
|
||
|
||
class HelixChildren(NodeChildren): | ||
pitch: UnCastFloat | ||
height: UnCastFloat | ||
radius: UnCastFloat | ||
center: Point3D | ||
dir: Point3D | ||
lefthand: UnCastBool | ||
|
||
|
||
class Helix3D(Curve3D, Node): | ||
"""A Helix curve, | ||
starting at (center.x + radius.x, center.y, center.z)""" | ||
|
||
children_class = HelixChildren | ||
|
||
def __init__( | ||
self, | ||
pitch: float, | ||
height: float, | ||
radius: float, | ||
center: Point3D = Point3D(0, 0, 0), | ||
dir: Point3D = Point3D(0, 0, 1), | ||
lefthand: bool = False, | ||
): | ||
Node.__init__(self) | ||
Curve3D.__init__(self) | ||
|
||
self.children.set_pitch(cast_to_float_parameter(pitch)) | ||
self.children.set_height(cast_to_float_parameter(height)) | ||
self.children.set_radius(cast_to_float_parameter(radius)) | ||
self.children.set_center(center) | ||
self.children.set_dir(dir) | ||
self.children.set_lefthand(cast_to_bool_parameter(lefthand)) | ||
self.params = {} | ||
|
||
|
||
class Ellipse3DChildren(NodeChildren): | ||
# TODO | ||
pass | ||
|
||
|
||
class Ellipse3D(Curve3D, Node): | ||
# TODO | ||
pass | ||
|
||
|
||
class Spline3DChildren(NodeChildren): | ||
points: list[Point3D] | ||
|
||
|
||
class Spline3D(Curve3D, Node): | ||
# TODO | ||
pass | ||
|
||
|
||
Curve3DTypes = Helix3D # U | ||
|
||
HelixChildren.__annotations__["pitch"] = FloatParameter | ||
HelixChildren.__annotations__["height"] = FloatParameter | ||
HelixChildren.__annotations__["radius"] = FloatParameter | ||
HelixChildren.__annotations__["center"] = Point3D | ||
HelixChildren.__annotations__["dir"] = Point3D | ||
HelixChildren.__annotations__["lefthand"] = BoolParameter |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.