DeepSDFStruct 1.7.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DeepSDFStruct/SDF.py +1734 -0
- DeepSDFStruct/__init__.py +66 -0
- DeepSDFStruct/deep_sdf/__init__.py +69 -0
- DeepSDFStruct/deep_sdf/create_screenshots_from_plyfiles.py +65 -0
- DeepSDFStruct/deep_sdf/data.py +258 -0
- DeepSDFStruct/deep_sdf/metrics/__init__.py +14 -0
- DeepSDFStruct/deep_sdf/metrics/mesh_to_analytical.py +24 -0
- DeepSDFStruct/deep_sdf/models.py +197 -0
- DeepSDFStruct/deep_sdf/networks/__init__.py +8 -0
- DeepSDFStruct/deep_sdf/networks/analytic_round_cross.py +105 -0
- DeepSDFStruct/deep_sdf/networks/deep_sdf_decoder.py +155 -0
- DeepSDFStruct/deep_sdf/networks/hierarchical_deep_sdf_decoder.py +139 -0
- DeepSDFStruct/deep_sdf/networks/hierarchical_positional_sdf_decoder.py +190 -0
- DeepSDFStruct/deep_sdf/networks/resnet_positional_sdf_decoder.py +108 -0
- DeepSDFStruct/deep_sdf/nn_utils.py +70 -0
- DeepSDFStruct/deep_sdf/plotting.py +143 -0
- DeepSDFStruct/deep_sdf/reconstruction.py +165 -0
- DeepSDFStruct/deep_sdf/training.py +840 -0
- DeepSDFStruct/deep_sdf/workspace.py +363 -0
- DeepSDFStruct/design_of_experiments.py +235 -0
- DeepSDFStruct/flexicubes/__init__.py +15 -0
- DeepSDFStruct/flexicubes/flexicubes.py +1005 -0
- DeepSDFStruct/flexicubes/tables.py +2338 -0
- DeepSDFStruct/flexisquares/__init__.py +15 -0
- DeepSDFStruct/flexisquares/flexisquares.py +967 -0
- DeepSDFStruct/flexisquares/tables.py +63 -0
- DeepSDFStruct/lattice_structure.py +254 -0
- DeepSDFStruct/local_shapes.py +226 -0
- DeepSDFStruct/mesh.py +1184 -0
- DeepSDFStruct/optimization.py +357 -0
- DeepSDFStruct/parametrization.py +215 -0
- DeepSDFStruct/pretrained_models.py +128 -0
- DeepSDFStruct/sampling.py +670 -0
- DeepSDFStruct/sdf_operations.py +990 -0
- DeepSDFStruct/sdf_primitives.py +1416 -0
- DeepSDFStruct/splinepy_unitcells/__init__.py +35 -0
- DeepSDFStruct/splinepy_unitcells/chi_3D.py +1617 -0
- DeepSDFStruct/splinepy_unitcells/cross_lattice.py +165 -0
- DeepSDFStruct/splinepy_unitcells/double_lattice_extruded.py +298 -0
- DeepSDFStruct/splinepy_unitcells/snappy_3d.py +544 -0
- DeepSDFStruct/torch_spline.py +446 -0
- DeepSDFStruct/trained_models/analytic_round_cross/LatentCodes/latest.pth +0 -0
- DeepSDFStruct/trained_models/analytic_round_cross/ModelParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/analytic_round_cross/OptimizerParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/analytic_round_cross/specs.json +45 -0
- DeepSDFStruct/trained_models/chi_and_cross/LatentCodes/latest.pth +0 -0
- DeepSDFStruct/trained_models/chi_and_cross/Logs.pth +0 -0
- DeepSDFStruct/trained_models/chi_and_cross/ModelParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/chi_and_cross/OptimizerParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/chi_and_cross/specs.json +76 -0
- DeepSDFStruct/trained_models/primitives/LatentCodes/latest.pth +0 -0
- DeepSDFStruct/trained_models/primitives/ModelParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/primitives/OptimizerParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/primitives/specs.json +46 -0
- DeepSDFStruct/trained_models/primitives_2d/LatentCodes/latest.pth +0 -0
- DeepSDFStruct/trained_models/primitives_2d/ModelParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/primitives_2d/OptimizerParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/primitives_2d/specs.json +46 -0
- DeepSDFStruct/trained_models/round_cross/LatentCodes/latest.pth +0 -0
- DeepSDFStruct/trained_models/round_cross/Logs.pth +0 -0
- DeepSDFStruct/trained_models/round_cross/ModelParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/round_cross/OptimizerParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/round_cross/specs.json +45 -0
- DeepSDFStruct/trained_models/test_experiment/LatentCodes/latent_code_data_map.json +106 -0
- DeepSDFStruct/trained_models/test_experiment/specs.json +45 -0
- DeepSDFStruct/trained_models/test_experiment/training_summary.json +10 -0
- DeepSDFStruct/trained_models/test_experiment_hierarchical/LatentCodes/latent_code_data_map.json +106 -0
- DeepSDFStruct/trained_models/test_experiment_hierarchical/specs.json +45 -0
- DeepSDFStruct/trained_models/test_experiment_hierarchical/training_summary.json +10 -0
- DeepSDFStruct/trained_models/test_experiment_homogenization/LatentCodes/latent_code_data_map.json +5006 -0
- DeepSDFStruct/trained_models/test_experiment_homogenization/LatentCodes/latest.pth +0 -0
- DeepSDFStruct/trained_models/test_experiment_homogenization/Logs.png +0 -0
- DeepSDFStruct/trained_models/test_experiment_homogenization/ModelParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/test_experiment_homogenization/OptimizerParameters/latest.pth +0 -0
- DeepSDFStruct/trained_models/test_experiment_homogenization/specs.json +83 -0
- DeepSDFStruct/trained_models/test_experiment_homogenization/training_summary.json +10 -0
- DeepSDFStruct/utils.py +96 -0
- DeepSDFStruct/visualization/latent_viewer.py +211 -0
- DeepSDFStruct/visualization/latent_viewer_cli.py +8 -0
- benchmarks/generate_sdf_showcase.py +622 -0
- benchmarks/sdf_from_mesh_benchmark.py +52 -0
- benchmarks/sdf_from_mesh_comparison.md +33 -0
- benchmarks/sdf_showcase/operations/boolean/difference_sphere_box.png +0 -0
- benchmarks/sdf_showcase/operations/boolean/union_sphere_box.png +0 -0
- benchmarks/sdf_showcase/operations/transformations/circular_array_sphere.png +0 -0
- benchmarks/sdf_showcase/operations/transformations/dilate_sphere.png +0 -0
- benchmarks/sdf_showcase/operations/transformations/mirror_sphere.png +0 -0
- benchmarks/sdf_showcase/operations/transformations/repeat_sphere.png +0 -0
- benchmarks/sdf_showcase/operations/transformations/revolve_circle.png +0 -0
- benchmarks/sdf_showcase/operations/transformations/shell_sphere.png +0 -0
- benchmarks/sdf_showcase/operations/transformations/twist_torus.png +0 -0
- benchmarks/sdf_showcase/primitives/2D/circle.png +0 -0
- benchmarks/sdf_showcase/primitives/2D/equilateral_triangle.png +0 -0
- benchmarks/sdf_showcase/primitives/2D/hexagon.png +0 -0
- benchmarks/sdf_showcase/primitives/2D/polygon_pentagon.png +0 -0
- benchmarks/sdf_showcase/primitives/2D/rectangle.png +0 -0
- benchmarks/sdf_showcase/primitives/2D/rounded_rectangle.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/box.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/capped_cone.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/capped_cylinder.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/capsule.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/cone.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/corner_spheres.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/cross_ms.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/cylinder.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/dodecahedron.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/ellipsoid.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/icosahedron.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/octahedron.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/pyramid.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/rounded_box.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/rounded_cone.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/rounded_cylinder.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/sphere.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/tetrahedron.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/torus.png +0 -0
- benchmarks/sdf_showcase/primitives/3D/wireframe_box.png +0 -0
- deepsdfstruct-1.7.2.dist-info/METADATA +44 -0
- deepsdfstruct-1.7.2.dist-info/RECORD +165 -0
- deepsdfstruct-1.7.2.dist-info/WHEEL +5 -0
- deepsdfstruct-1.7.2.dist-info/licenses/LICENSE +208 -0
- deepsdfstruct-1.7.2.dist-info/licenses/NOTICE +67 -0
- deepsdfstruct-1.7.2.dist-info/scm_file_list.json +178 -0
- deepsdfstruct-1.7.2.dist-info/scm_version.json +8 -0
- deepsdfstruct-1.7.2.dist-info/top_level.txt +4 -0
- docs/Makefile +20 -0
- docs/api_reference.rst +6 -0
- docs/conf.py +60 -0
- docs/index.rst +136 -0
- docs/make.bat +35 -0
- docs/qr_code_github.png +0 -0
- docs/qr_code_paper.png +0 -0
- docs/readme_images/example_output_01.png +0 -0
- docs/readme_images/example_output_02.png +0 -0
- docs/readme_images/example_output_03.png +0 -0
- docs/readme_images/example_output_04.png +0 -0
- tests/data/chairs/1005.obj +282 -0
- tests/data/chairs/1024.obj +222 -0
- tests/data/chairs/README.md +1 -0
- tests/data/circular_balls_test_case.stl +0 -0
- tests/data/cone.stl +1794 -0
- tests/data/example_disconnectd_mesh.inp +1784 -0
- tests/data/example_line_mesh.vtk +0 -0
- tests/data/stanford_bunny.stl +0 -0
- tests/data/sweep_test_case.stl +0 -0
- tests/test_DOE.py +49 -0
- tests/test_elongate_sdf.py +195 -0
- tests/test_flexisquares.py +187 -0
- tests/test_generate_dataset.py +76 -0
- tests/test_lattice_evaluation.py +137 -0
- tests/test_mesh_export.py +137 -0
- tests/test_mesh_functions.py +49 -0
- tests/test_networks.py +71 -0
- tests/test_pretrained_models.py +40 -0
- tests/test_reconstruction.py +101 -0
- tests/test_sdf_from_mesh.py +52 -0
- tests/test_sdf_functions.py +117 -0
- tests/test_sdf_primitives.py +668 -0
- tests/test_sdf_trimesh_comparison.py +482 -0
- tests/test_splinepy_unitcells.py +64 -0
- tests/test_structural_optimization.py +178 -0
- tests/test_torch_spline.py +216 -0
- tests/test_train_model.py +110 -0
- tests/test_training_data_ids.py +41 -0
- tests/tmp_outputs/temp_file.txt +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cross Lattice Unit Cell
|
|
3
|
+
=======================
|
|
4
|
+
|
|
5
|
+
This module implements a 2D cross-shaped lattice unit cell using splinepy.
|
|
6
|
+
The lattice consists of a rectangle with two diagonal struts in the center.
|
|
7
|
+
|
|
8
|
+
The unit cell is parametrized by strut thickness and can be used as a
|
|
9
|
+
building block for larger lattice structures.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import numpy as _np
|
|
13
|
+
|
|
14
|
+
from splinepy.bezier import Bezier as _Bezier
|
|
15
|
+
from splinepy.microstructure.tiles.tile_base import TileBase as _TileBase
|
|
16
|
+
import splinepy as sp
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CrossLattice(_TileBase):
|
|
20
|
+
"""
|
|
21
|
+
Lattice base cell, consisting of a rectangle with two diagonals in the
|
|
22
|
+
center.
|
|
23
|
+
|
|
24
|
+
.. raw:: html
|
|
25
|
+
|
|
26
|
+
<p><a href="../_static/DoubleLattice.html">Fullscreen</a>.</p>
|
|
27
|
+
<embed type="text/html" width="100%" height="400" src="../_static/DoubleLattice.html" />
|
|
28
|
+
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
|
|
31
|
+
_dim = 2
|
|
32
|
+
_para_dim = 2
|
|
33
|
+
# tile is evaluated at each corner
|
|
34
|
+
_evaluation_points = _np.array([[0.5, 0.5, 0.5]])
|
|
35
|
+
_n_info_per_eval_point = 1
|
|
36
|
+
|
|
37
|
+
def create_tile(
|
|
38
|
+
self,
|
|
39
|
+
parameters=None,
|
|
40
|
+
parameter_sensitivities=None,
|
|
41
|
+
make3D=True,
|
|
42
|
+
**kwargs, # noqa ARG002
|
|
43
|
+
):
|
|
44
|
+
"""Create a microtile based on the parameters that describe the branch
|
|
45
|
+
thicknesses.
|
|
46
|
+
|
|
47
|
+
Thickness parameters are used to describe the inner radius of the
|
|
48
|
+
outward facing branches
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------
|
|
52
|
+
parameters : np.array
|
|
53
|
+
first entry defines the thickness of the vertical and horizontal
|
|
54
|
+
branches
|
|
55
|
+
second entry defines the thickness of the diagonal branches
|
|
56
|
+
parameter_sensitivities: np.ndarray
|
|
57
|
+
correlates with thickness of branches and entouring wall
|
|
58
|
+
contact_length : double
|
|
59
|
+
required for conformity between tiles, sets the length of the center
|
|
60
|
+
block on the tiles boundary
|
|
61
|
+
|
|
62
|
+
Returns
|
|
63
|
+
-------
|
|
64
|
+
microtile_list : list(splines)
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
# set to default if nothing is given
|
|
68
|
+
if parameters is None:
|
|
69
|
+
self._logd("Tile request is not parametrized, setting default 0.2")
|
|
70
|
+
parameters = _np.ones((1, 1)) * 0.1
|
|
71
|
+
if not (_np.all(parameters > 0) and _np.all(parameters < 0.5)):
|
|
72
|
+
raise ValueError(
|
|
73
|
+
"Parameters must be between 0.01 and 0.5/(1+sqrt(2))=0.207"
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
self.check_params(parameters)
|
|
77
|
+
|
|
78
|
+
# Check if user requests derivative splines
|
|
79
|
+
if self.check_param_derivatives(parameter_sensitivities):
|
|
80
|
+
n_derivatives = parameter_sensitivities.shape[2]
|
|
81
|
+
derivatives = []
|
|
82
|
+
else:
|
|
83
|
+
n_derivatives = 0
|
|
84
|
+
derivatives = None
|
|
85
|
+
|
|
86
|
+
splines = []
|
|
87
|
+
for i_derivative in range(n_derivatives + 1):
|
|
88
|
+
# Constant auxiliary values
|
|
89
|
+
if i_derivative == 0:
|
|
90
|
+
t = parameters[0, 0]
|
|
91
|
+
v_one_half = 0.5
|
|
92
|
+
v_one = 1.0
|
|
93
|
+
v_zero = 0.0
|
|
94
|
+
else:
|
|
95
|
+
cl = 0.0
|
|
96
|
+
t = parameter_sensitivities[0, 0, i_derivative - 1]
|
|
97
|
+
v_one_half = 0.0
|
|
98
|
+
v_one = 0.0
|
|
99
|
+
v_zero = 0.0
|
|
100
|
+
|
|
101
|
+
# Init return value
|
|
102
|
+
spline_list = []
|
|
103
|
+
|
|
104
|
+
# 1
|
|
105
|
+
spline_list.append(
|
|
106
|
+
_Bezier(
|
|
107
|
+
degrees=[1, 1],
|
|
108
|
+
control_points=[
|
|
109
|
+
[t, 0],
|
|
110
|
+
[v_one_half, v_one_half - t],
|
|
111
|
+
[0, 0],
|
|
112
|
+
[v_one_half, v_one_half],
|
|
113
|
+
],
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
# 2
|
|
118
|
+
spline_list.append(
|
|
119
|
+
_Bezier(
|
|
120
|
+
degrees=[1, 1],
|
|
121
|
+
control_points=[
|
|
122
|
+
[0, 0],
|
|
123
|
+
[v_one_half, v_one_half],
|
|
124
|
+
[0, t],
|
|
125
|
+
[v_one_half - t, v_one_half],
|
|
126
|
+
],
|
|
127
|
+
)
|
|
128
|
+
)
|
|
129
|
+
hor_reflected_spline_list = []
|
|
130
|
+
for spline in spline_list:
|
|
131
|
+
reflected_spline = spline.copy()
|
|
132
|
+
reflected_spline.control_points[:, 0] = (
|
|
133
|
+
v_one - spline.control_points[:, 0]
|
|
134
|
+
)
|
|
135
|
+
hor_reflected_spline_list.append(reflected_spline)
|
|
136
|
+
|
|
137
|
+
vert_reflected_splines = []
|
|
138
|
+
for spline in spline_list + hor_reflected_spline_list:
|
|
139
|
+
reflected_spline = spline.copy()
|
|
140
|
+
reflected_spline.control_points[:, 1] = (
|
|
141
|
+
v_one - spline.control_points[:, 1]
|
|
142
|
+
)
|
|
143
|
+
vert_reflected_splines.append(reflected_spline)
|
|
144
|
+
spline_list = (
|
|
145
|
+
spline_list + hor_reflected_spline_list + vert_reflected_splines
|
|
146
|
+
)
|
|
147
|
+
# Pass to output
|
|
148
|
+
if i_derivative == 0:
|
|
149
|
+
splines = spline_list.copy()
|
|
150
|
+
else:
|
|
151
|
+
derivatives.append(spline_list)
|
|
152
|
+
extr_spline_list = []
|
|
153
|
+
for spline in spline_list:
|
|
154
|
+
if make3D:
|
|
155
|
+
extr_spline = sp.helpme.create.extruded(spline, (0, 0, 1))
|
|
156
|
+
temp_pts = extr_spline.control_points.copy()
|
|
157
|
+
extr_spline.control_points[:, 0] = temp_pts[:, 1]
|
|
158
|
+
extr_spline.control_points[:, 1] = temp_pts[:, 2]
|
|
159
|
+
extr_spline.control_points[:, 2] = temp_pts[:, 0]
|
|
160
|
+
else:
|
|
161
|
+
extr_spline = spline
|
|
162
|
+
extr_spline_list.append(extr_spline)
|
|
163
|
+
|
|
164
|
+
# Return results
|
|
165
|
+
return (extr_spline_list, None)
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Double Lattice Extruded Unit Cell
|
|
3
|
+
=================================
|
|
4
|
+
|
|
5
|
+
This module implements an extruded double lattice unit cell using splinepy.
|
|
6
|
+
The structure consists of a 2D double lattice pattern (rectangle with two
|
|
7
|
+
diagonals) extruded in the z-direction.
|
|
8
|
+
|
|
9
|
+
This provides a 3D lattice with controllable thickness in both the planar
|
|
10
|
+
and extrusion directions, useful for layered structures and anisotropic
|
|
11
|
+
mechanical properties.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import numpy as _np
|
|
15
|
+
|
|
16
|
+
from splinepy.bezier import Bezier as _Bezier
|
|
17
|
+
from splinepy.microstructure.tiles.tile_base import TileBase as _TileBase
|
|
18
|
+
from splinepy.utils.log import warning as _warning
|
|
19
|
+
from splinepy.helpme import create
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DoubleLatticeExtruded(_TileBase):
|
|
23
|
+
def __init__(self):
|
|
24
|
+
"""
|
|
25
|
+
Lattice base cell, consisting of a rectangle with two diagonals in the
|
|
26
|
+
center, extruded in the z-direction."""
|
|
27
|
+
self._dim = 3
|
|
28
|
+
self._para_dim = 3
|
|
29
|
+
self._evaluation_points = _np.array([[0.5, 0.5, 0.5]])
|
|
30
|
+
self._n_info_per_eval_point = 2
|
|
31
|
+
|
|
32
|
+
def create_tile(
|
|
33
|
+
self,
|
|
34
|
+
parameters=None,
|
|
35
|
+
parameter_sensitivities=None,
|
|
36
|
+
contact_length=0.5,
|
|
37
|
+
**kwargs, # noqa ARG002
|
|
38
|
+
):
|
|
39
|
+
"""Create a microtile based on the parameters that describe the branch
|
|
40
|
+
thicknesses.
|
|
41
|
+
|
|
42
|
+
Thickness parameters are used to describe the inner radius of the
|
|
43
|
+
outward facing branches
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
parameters : np.array
|
|
48
|
+
first entry defines the thickness of the vertical and horizontal
|
|
49
|
+
branches
|
|
50
|
+
second entry defines the thickness of the diagonal branches
|
|
51
|
+
parameter_sensitivities: np.ndarray
|
|
52
|
+
correlates with thickness of branches and entouring wall
|
|
53
|
+
contact_length : double
|
|
54
|
+
required for conformity between tiles, sets the length of the center
|
|
55
|
+
block on the tiles boundary
|
|
56
|
+
|
|
57
|
+
Returns
|
|
58
|
+
-------
|
|
59
|
+
microtile_list : list(splines)
|
|
60
|
+
"""
|
|
61
|
+
index_second_value = 1
|
|
62
|
+
if not isinstance(contact_length, float):
|
|
63
|
+
raise ValueError("Invalid Type")
|
|
64
|
+
if not ((contact_length > 0.0) and (contact_length < 1.0)):
|
|
65
|
+
raise ValueError("Contact length must be in (0.,1.)")
|
|
66
|
+
|
|
67
|
+
# set to default if nothing is given
|
|
68
|
+
if parameters is None:
|
|
69
|
+
self._logd("Tile request is not parametrized, setting default 0.2")
|
|
70
|
+
parameters = _np.ones((1, 2)) * 0.2
|
|
71
|
+
# Maintain backwards compatibility
|
|
72
|
+
elif parameters.shape[1] == 1:
|
|
73
|
+
_warning("DoubleLattice now expects 2 values")
|
|
74
|
+
index_second_value = 0
|
|
75
|
+
self._n_info_per_eval_point = 1
|
|
76
|
+
if not (
|
|
77
|
+
_np.all(parameters > 0) and _np.all(parameters < 0.5 / (1 + _np.sqrt(2)))
|
|
78
|
+
):
|
|
79
|
+
raise ValueError(
|
|
80
|
+
"Parameters must be between 0.01 and 0.5/(1+sqrt(2))=0.207"
|
|
81
|
+
)
|
|
82
|
+
self.check_params(parameters)
|
|
83
|
+
|
|
84
|
+
# Check if user requests derivative splines
|
|
85
|
+
if self.check_param_derivatives(parameter_sensitivities):
|
|
86
|
+
n_derivatives = parameter_sensitivities.shape[2]
|
|
87
|
+
derivatives = []
|
|
88
|
+
else:
|
|
89
|
+
n_derivatives = 0
|
|
90
|
+
derivatives = None
|
|
91
|
+
|
|
92
|
+
splines = []
|
|
93
|
+
for i_derivative in range(n_derivatives + 1):
|
|
94
|
+
# Constant auxiliary values
|
|
95
|
+
if i_derivative == 0:
|
|
96
|
+
cl = contact_length
|
|
97
|
+
thick_vert_hor = parameters[0, 0] # parameters.shape == [1]
|
|
98
|
+
thick_diagonal = parameters[0, index_second_value]
|
|
99
|
+
v_one_half = 0.5
|
|
100
|
+
v_one = 1.0
|
|
101
|
+
v_zero = 0.0
|
|
102
|
+
else:
|
|
103
|
+
cl = 0.0
|
|
104
|
+
thick_vert_hor = parameter_sensitivities[0, 0, i_derivative - 1]
|
|
105
|
+
thick_diagonal = parameter_sensitivities[
|
|
106
|
+
0, index_second_value, i_derivative - 1
|
|
107
|
+
]
|
|
108
|
+
v_one_half = 0.0
|
|
109
|
+
v_one = 0.0
|
|
110
|
+
v_zero = 0.0
|
|
111
|
+
|
|
112
|
+
# Set variables
|
|
113
|
+
a01 = v_zero
|
|
114
|
+
a02 = thick_vert_hor
|
|
115
|
+
a03 = thick_vert_hor + thick_diagonal * _np.sqrt(2)
|
|
116
|
+
a04 = (v_one - cl) * 0.5
|
|
117
|
+
a05 = v_one_half - thick_diagonal * _np.sqrt(2)
|
|
118
|
+
a06 = v_one_half
|
|
119
|
+
a07 = v_one_half + thick_diagonal * _np.sqrt(2)
|
|
120
|
+
a08 = (v_one + cl) * 0.5
|
|
121
|
+
a09 = v_one - (thick_vert_hor + thick_diagonal * _np.sqrt(2))
|
|
122
|
+
a10 = v_one - thick_vert_hor
|
|
123
|
+
a11 = v_one
|
|
124
|
+
# Init return value
|
|
125
|
+
spline_list = []
|
|
126
|
+
|
|
127
|
+
# 1
|
|
128
|
+
spline_list.append(
|
|
129
|
+
_Bezier(
|
|
130
|
+
degrees=[1, 1],
|
|
131
|
+
control_points=[[a01, a01], [a02, a02], [a01, a04], [a02, a03]],
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# 2
|
|
136
|
+
spline_list.append(
|
|
137
|
+
_Bezier(
|
|
138
|
+
degrees=[1, 1],
|
|
139
|
+
control_points=[[a01, a01], [a04, a01], [a02, a02], [a03, a02]],
|
|
140
|
+
)
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
# 3
|
|
144
|
+
spline_list.append(
|
|
145
|
+
_Bezier(
|
|
146
|
+
degrees=[1, 1],
|
|
147
|
+
control_points=[[a04, a01], [a08, a01], [a03, a02], [a09, a02]],
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# 4
|
|
152
|
+
spline_list.append(
|
|
153
|
+
_Bezier(
|
|
154
|
+
degrees=[1, 1],
|
|
155
|
+
control_points=[[a08, a01], [a11, a01], [a09, a02], [a10, a02]],
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
# 5
|
|
160
|
+
spline_list.append(
|
|
161
|
+
_Bezier(
|
|
162
|
+
degrees=[1, 1],
|
|
163
|
+
control_points=[[a10, a02], [a11, a01], [a10, a03], [a11, a04]],
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# 6
|
|
168
|
+
spline_list.append(
|
|
169
|
+
_Bezier(
|
|
170
|
+
degrees=[1, 1],
|
|
171
|
+
control_points=[[a11, a04], [a11, a08], [a10, a03], [a10, a09]],
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
# 7
|
|
176
|
+
spline_list.append(
|
|
177
|
+
_Bezier(
|
|
178
|
+
degrees=[1, 1],
|
|
179
|
+
control_points=[[a10, a09], [a11, a08], [a10, a10], [a11, a11]],
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
# 8
|
|
183
|
+
spline_list.append(
|
|
184
|
+
_Bezier(
|
|
185
|
+
degrees=[1, 1],
|
|
186
|
+
control_points=[[a09, a10], [a10, a10], [a08, a11], [a11, a11]],
|
|
187
|
+
)
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# 9
|
|
191
|
+
spline_list.append(
|
|
192
|
+
_Bezier(
|
|
193
|
+
degrees=[1, 1],
|
|
194
|
+
control_points=[[a03, a10], [a09, a10], [a04, a11], [a08, a11]],
|
|
195
|
+
)
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# 10
|
|
199
|
+
spline_list.append(
|
|
200
|
+
_Bezier(
|
|
201
|
+
degrees=[1, 1],
|
|
202
|
+
control_points=[[a02, a10], [a03, a10], [a01, a11], [a04, a11]],
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
# 11
|
|
207
|
+
spline_list.append(
|
|
208
|
+
_Bezier(
|
|
209
|
+
degrees=[1, 1],
|
|
210
|
+
control_points=[[a01, a08], [a02, a09], [a01, a11], [a02, a10]],
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
# 12
|
|
215
|
+
spline_list.append(
|
|
216
|
+
_Bezier(
|
|
217
|
+
degrees=[1, 1],
|
|
218
|
+
control_points=[[a01, a04], [a02, a03], [a01, a08], [a02, a09]],
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
# 13
|
|
223
|
+
spline_list.append(
|
|
224
|
+
_Bezier(
|
|
225
|
+
degrees=[1, 1],
|
|
226
|
+
control_points=[[a02, a09], [a05, a06], [a02, a10], [a06, a06]],
|
|
227
|
+
)
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# 14
|
|
231
|
+
spline_list.append(
|
|
232
|
+
_Bezier(
|
|
233
|
+
degrees=[1, 1],
|
|
234
|
+
control_points=[[a02, a10], [a06, a06], [a03, a10], [a06, a07]],
|
|
235
|
+
)
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
# 15
|
|
239
|
+
spline_list.append(
|
|
240
|
+
_Bezier(
|
|
241
|
+
degrees=[1, 1],
|
|
242
|
+
control_points=[[a02, a02], [a06, a06], [a02, a03], [a05, a06]],
|
|
243
|
+
)
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
# 16
|
|
247
|
+
spline_list.append(
|
|
248
|
+
_Bezier(
|
|
249
|
+
degrees=[1, 1],
|
|
250
|
+
control_points=[[a02, a02], [a03, a02], [a06, a06], [a06, a05]],
|
|
251
|
+
)
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
# 17
|
|
255
|
+
spline_list.append(
|
|
256
|
+
_Bezier(
|
|
257
|
+
degrees=[1, 1],
|
|
258
|
+
control_points=[[a09, a02], [a10, a02], [a06, a05], [a06, a06]],
|
|
259
|
+
)
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# 18
|
|
263
|
+
spline_list.append(
|
|
264
|
+
_Bezier(
|
|
265
|
+
degrees=[1, 1],
|
|
266
|
+
control_points=[[a06, a06], [a10, a02], [a07, a06], [a10, a03]],
|
|
267
|
+
)
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
# 19
|
|
271
|
+
spline_list.append(
|
|
272
|
+
_Bezier(
|
|
273
|
+
degrees=[1, 1],
|
|
274
|
+
control_points=[[a06, a06], [a07, a06], [a10, a10], [a10, a09]],
|
|
275
|
+
)
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
# 20
|
|
279
|
+
spline_list.append(
|
|
280
|
+
_Bezier(
|
|
281
|
+
degrees=[1, 1],
|
|
282
|
+
control_points=[[a06, a06], [a10, a10], [a06, a07], [a09, a10]],
|
|
283
|
+
)
|
|
284
|
+
)
|
|
285
|
+
for index, spline in enumerate(spline_list):
|
|
286
|
+
# switch x and z axis by inserting zeros for y
|
|
287
|
+
spline_list[index].control_points = _np.insert(
|
|
288
|
+
spline_list[index].control_points, 1, values=0, axis=1
|
|
289
|
+
)
|
|
290
|
+
spline_list[index] = create.extruded(spline, extrusion_vector=[0, 1, 0])
|
|
291
|
+
# Pass to output
|
|
292
|
+
if i_derivative == 0:
|
|
293
|
+
splines = spline_list.copy()
|
|
294
|
+
else:
|
|
295
|
+
derivatives.append(spline_list)
|
|
296
|
+
|
|
297
|
+
# Return results
|
|
298
|
+
return (splines, derivatives)
|