Skip to content

Commit

Permalink
refactor(SweptComponent): deprectate old swept component type
Browse files Browse the repository at this point in the history
  • Loading branch information
kieran-mackle committed Jun 16, 2024
1 parent 27d8ae0 commit 5e54c18
Showing 1 changed file with 18 additions and 54 deletions.
72 changes: 18 additions & 54 deletions hypervehicle/components/swept.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,9 @@
from typing import List, Dict
from hypervehicle.components.component import Component
from hypervehicle.geometry import SweptPatch, SweptPatchfromEdges
from hypervehicle.components.constants import SWEPT_COMPONENT
from typing import List, Dict, Optional
from gdtk.geom.path import ReversedPath
from gdtk.geom.surface import CoonsPatch


class SweptComponent_old(Component):
componenttype = SWEPT_COMPONENT

def __init__(
self,
cross_sections: List[CoonsPatch],
sweep_axis: str = "n/a",
stl_resolution: int = 2,
verbosity: int = 1,
name: str = None,
) -> None:
"""Create a swept component.
Parameters
----------
cross_sections : list, optional
A list of cross-sectional patches to sweep through.
sweep_axis : str, optional
The axis to sweep the cross sections through. The default
is z.
"""
self.cross_sections = cross_sections
self.sweep_axis = sweep_axis
super().__init__(stl_resolution=stl_resolution, verbosity=verbosity, name=name)

def generate_patches(self):
p = SweptPatch(
cross_sections=self.cross_sections,
sweep_axis=self.sweep_axis,
)
self.patches["swept_patch"] = p
self.patches["swept_patch_end_0"] = self.cross_sections[0]
self.patches["swept_patch_end_1"] = self.cross_sections[-1]
from hypervehicle.geometry import SweptPatchfromEdges
from hypervehicle.components.component import Component
from hypervehicle.components.constants import SWEPT_COMPONENT


class SweptComponent(Component):
Expand All @@ -47,38 +12,37 @@ class SweptComponent(Component):
def __init__(
self,
cross_sections: List[List],
close_ends: bool = True,
close_ends: Optional[bool] = True,
stl_resolution: int | Dict[str, int] = 1,
verbosity: int = 1,
name: str = None,
verbosity: Optional[int] = 1,
name: Optional[str] = None,
) -> None:
"""Create a swept component.
Parameters
----------
cross_sections : list, optional
A list containing cross-sections. Each cross-sectiona is a list of
cross_sections : list
A list containing cross-sections. Each cross-section is a list of
paths that define one cross-section.
close_ends : bool, otpional
close_ends : bool, optional
If true the first and last cross-section will be used to close
the sweap component. Only supported is cross-section is defined by
4 paths.
stl_resolution : int, optional
Defines same stl_resolution to all edges.
stl_resolution : dict [str, int]
4 paths. The default is True.
stl_resolution : int | dict[str, int], optional
Defines different stl resolution for different edges. Keys are
are: 'e0', 'e1', ... 'eN', 'sweep' for edges in first cross-section
and for swept edges.
and for swept edges. The default is 1.
"""
super().__init__(stl_resolution=stl_resolution, verbosity=verbosity, name=name)
self.cross_sections = cross_sections
self.close_ends = close_ends
super().__init__(stl_resolution=stl_resolution, verbosity=verbosity, name=name)

self.n_slices = len(self.cross_sections)
self.n_edges = len(self.cross_sections[0])
self.check()
self._check_options()

def check(self, small_number=1e-12):
def _check_options(self, small_number: Optional[int] = 1e-12):
for ns, cs in enumerate(self.cross_sections):
if len(cs) != self.n_edges:
# check that each c/s has correct number of edges
Expand Down

0 comments on commit 5e54c18

Please sign in to comment.