Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swept Surface #438

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
7320d61
Add: show_swept-file and swept-function in create-file
OberGue Apr 18, 2024
8e544a1
Add: first kinda swept surface implementation in show_swept-file
OberGue Apr 29, 2024
f63b2d5
Fix: Moved computation from show_swept-file to create-file
OberGue May 2, 2024
d871575
Add: function for transformation matrix
OberGue May 2, 2024
f3bcd76
Add: show_options changed in show_swept-file
OberGue May 2, 2024
a6c3eba
Add: positioning of cross-section control points
OberGue May 6, 2024
78ea5a2
Fix: now, evaluation-points are fitted instead of CPs
OberGue May 6, 2024
5f16669
Add: rotation matrix and centered cross section
OberGue May 7, 2024
afa5569
Fix: getting fitting flexible for CS eval points; Note: WIP
OberGue May 7, 2024
3a4cb53
Add: Transformation matrix now with projection; Note: WIP
OberGue May 14, 2024
9f07a67
Fix: calculation of transformation matrix - still working on projecti…
OberGue May 15, 2024
d4f1b8f
minor clean up during discussion
j042 May 21, 2024
7d07e79
Fix: create-file transformation matrices now calculated once; rotatio…
OberGue May 22, 2024
fc9b911
Fix: changed arbitrary vector vec and rotation matrix in create-file;…
OberGue May 22, 2024
8e6c006
Fix: random vector vec now dependent of tangent
OberGue May 23, 2024
fb3ef95
Add: new function in fit.py-file; Fix: adaptions in create.py-file ac…
OberGue Jun 9, 2024
17b9cc9
Fix: pre-commit changes
OberGue Jun 9, 2024
3c82d3e
Add: changed show-settings to better possibility of comparison
OberGue Jun 12, 2024
142d226
Big update; Add: nurbs, traj refinement; Del: fitting routine
OberGue Jun 12, 2024
17b100c
Fix: calculation of rotation matrix
OberGue Jun 19, 2024
42ffcbf
Add: refinement routine; Fix: no more derivative redundance
OberGue Jun 20, 2024
98bde93
Fix: no more global splinepy import
OberGue Jun 27, 2024
d79096f
Add: self-refinement now working; added function in bspline.py (note:…
OberGue Jul 1, 2024
35961fc
Add: function for closed trajectories
OberGue Jul 2, 2024
f08140b
Add: some checks were added
OberGue Jul 2, 2024
9a5c99d
Add: reference to nurbs book
OberGue Jul 2, 2024
e1d46a9
Add: auto_refinement variable
OberGue Jul 2, 2024
384a0d2
Fix: positioning of cs-cps now acc to traj-cps; Fix: auto_refinement …
OberGue Jul 2, 2024
46c8f54
Add: test functions in create-test-file
OberGue Jul 2, 2024
75a5bb6
Rm: removed unnecessary insertion function in bspline.py
OberGue Jul 3, 2024
65a320f
Add: opportunity to set cross-sec CPs on traj eval points or traj CPs
OberGue Jul 3, 2024
9d34f7c
Add: swept description; Fix: using settings.TOLERANCE
OberGue Jul 3, 2024
04b75e1
Fix: get rid of x,y,z
OberGue Jul 3, 2024
fa153f6
Fix: embedded calc of transf matrices in normal code - without functi…
OberGue Jul 3, 2024
058957a
Add: debug log at cs_normal_vector
OberGue Jul 3, 2024
c59a26b
Add: debug log for B division by zero
OberGue Jul 3, 2024
2c73c87
Add: functionality to rotate cross_section around traj-tangent-vector
OberGue Jul 8, 2024
c2ecb5b
Add: test function to compare swept and extruded
OberGue Jul 8, 2024
ad3a125
Add: test_swept_with_costum_normal now with derivative check
OberGue Jul 8, 2024
249eb09
Rm: auto_refinement; Rm: clean up show_swept file
OberGue Jul 10, 2024
dcc4773
Fix: new test functions
OberGue Jul 12, 2024
27c6094
Rm: german comment
OberGue Jul 12, 2024
bc627a8
Add: capabilities of sweeping in the docstring
OberGue Jul 12, 2024
08d903d
Fix: changed indentation in docstring
OberGue Jul 12, 2024
86e00f4
Fix: added points in docstring
OberGue Jul 12, 2024
016b7c6
Add: show_swept-file now shows more examples
OberGue Sep 9, 2024
43e48d4
Rm: .all()-function in test_create-file
OberGue Sep 10, 2024
255b874
Fix: show_options and variable names in show_swept
OberGue Sep 11, 2024
4207da0
Fix: changed comments of cs_nv
OberGue Sep 16, 2024
5751704
Add: assertions and comments in test_basic_functionality-function in …
OberGue Sep 16, 2024
53851c7
Fix: error messages in create-file
OberGue Sep 16, 2024
ba5264d
Fix: clarified error messages at input checks of create-file
OberGue Sep 16, 2024
b2a3d5e
Fix: rotation matrix calculation now also for e2 entries
OberGue Sep 17, 2024
40229b0
Add: catch division by zero in trajectory-tangent calculation
OberGue Nov 8, 2024
c2e0750
Fix: input checks now with spline-instance; Add: casting of rotation_…
OberGue Nov 8, 2024
874234f
Add: temporal variable in order to avoid multiple cross-product-calcu…
OberGue Nov 8, 2024
26361bd
Fix: changed vector calculations to inplace syntax (where possible)
OberGue Nov 8, 2024
31cfe13
Fix: changed name of centering test-function
OberGue Nov 8, 2024
18b3ff0
Fix: split first instance check and insert f for string
OberGue Nov 8, 2024
c1a57da
Fix: changed error messages semantically
OberGue Nov 8, 2024
2f3f2c5
Fix: changed TypeError to ValueError
OberGue Nov 8, 2024
c4490f8
Add: catch division by zero
OberGue Nov 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions examples/show_swept.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import gustaf as gus
import numpy as np

import splinepy
OberGue marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == "__main__":

### TRAJECTORY ###
OberGue marked this conversation as resolved.
Show resolved Hide resolved
OberGue marked this conversation as resolved.
Show resolved Hide resolved

# define a hook-trajectory
dict_trajectory = {
"degrees": [3],
"knot_vectors": [
[0.0, 0.0, 0.0, 0.0, 0.2, 0.4, 0.6, 0.8, 0.9, 1.0, 1.0, 1.0, 1.0]
],
"control_points": np.array(
[
[0.5, 0],
[0.5, 2],
[1.0, 3],
[2.0, 4],
[2.15, 5],
[1.8, 5.9],
[1.0, 6.2],
[-0.25, 6],
[-0.5, 5],
]
),
}

# create spline of trajectory dict
trajectory = splinepy.BSpline(**dict_trajectory)
OberGue marked this conversation as resolved.
Show resolved Hide resolved

# refine trajectory by inserting knots and control points
trajectory.uniform_refine(0, 1)

### CROSS SECTIONS ###

# 1. create a circular 1D-line-cross-section
cross_section_circle = splinepy.helpme.create.circle(0.5).nurbs

# 2. create a circular 2D-surface-cross-section
cross_section_disk = splinepy.helpme.create.surface_circle(0.5).nurbs

# 3. create a rectangular 2D-surface-cross-section
cross_section_plate = splinepy.helpme.create.box(1, 1).nurbs

# Define a custom normal vector for the cross-section when:
# a) The cross-section is not planar in the x-y plane, or
# b) Crooked sweeping is desired
cs_nv = np.array([1, 0, 1])

### SWEEP ###

# create swept surface
swept_surface_circle = splinepy.helpme.create.swept(
trajectory=trajectory,
cross_section=cross_section_circle,
cross_section_normal=None,
set_on_trajectory=False,
rotation_adaption=None,
)
OberGue marked this conversation as resolved.
Show resolved Hide resolved

# create crooked swept solid (circular nr. 1)
# the cross-section's normal vector is not default; crooked sweeping
swept_solid_disk_1 = splinepy.helpme.create.swept(
trajectory=trajectory,
cross_section=cross_section_disk,
cross_section_normal=cs_nv,
set_on_trajectory=False,
rotation_adaption=None,
)

# create swept solid (circular nr. 2)
# the cross-sections are set on the trajectory's control points (default)
swept_solid_disk_2 = splinepy.helpme.create.swept(
trajectory=trajectory,
cross_section=cross_section_disk,
cross_section_normal=None,
set_on_trajectory=False,
rotation_adaption=None,
)

# create swept solid (circular nr. 3)
# the cross-sections are set on the trajectory's evaluation points
swept_solid_disk_3 = splinepy.helpme.create.swept(
trajectory=trajectory,
cross_section=cross_section_disk,
cross_section_normal=None,
set_on_trajectory=True,
rotation_adaption=None,
)

# create swept solid (rectangular nr. 1)
swept_solid_plate_1 = splinepy.helpme.create.swept(
trajectory=trajectory,
cross_section=cross_section_plate,
cross_section_normal=None,
set_on_trajectory=False,
rotation_adaption=None,
)

# create swept solid (rectangular nr. 2)
# rotation adaption with 45 degrees
swept_solid_plate_2 = splinepy.helpme.create.swept(
trajectory=trajectory,
cross_section=cross_section_plate,
cross_section_normal=None,
set_on_trajectory=False,
rotation_adaption=45 * np.pi / 180,
)
OberGue marked this conversation as resolved.
Show resolved Hide resolved

### VISUALIZATION ###

# first window: swept surface
gus.show(
["Trajectory", trajectory],
["1D Cross Section", cross_section_circle],
["Swept Surface", swept_surface_circle],
resolution=51,
control_mesh=False,
control_point_ids=False,
)

# adjust show options
swept_solid_disk_2.show_options["alpha"] = 0.3
swept_solid_disk_3.show_options["alpha"] = 0.3
trajectory.show_options["control_points"] = False
OberGue marked this conversation as resolved.
Show resolved Hide resolved

# second window: swept solids (circular)
gus.show(
["2D Cross Section", cross_section_disk],
["Swept Solid - Crooked Sweeping", swept_solid_disk_1],
[
"Swept Solid - Set on Control Points",
swept_solid_disk_2,
trajectory,
],
[
"Swept Solid - Set on Evaluation Points",
swept_solid_disk_3,
trajectory,
],
resolution=51,
control_mesh=False,
control_point_ids=False,
)

# third window: swept solids (rectangular)
gus.show(
["New Cross Section", cross_section_plate],
["Swept Solid without Rotation", swept_solid_plate_1],
["Swept Solid with 45° Rotation", swept_solid_plate_2],
resolution=51,
control_mesh=False,
control_point_ids=False,
)
1 change: 0 additions & 1 deletion splinepy/bspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ def remove_knots(self, parametric_dimension, knots, tolerance=None):

self._logd(f"Tried to remove {len(knots)} knot(s).")
self._logd(f"Actually removed {sum(removed)} knot(s).")

return removed

def normalize_knot_vectors(self):
Expand Down
Loading
Loading