-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvironment.py
More file actions
69 lines (50 loc) · 2.5 KB
/
Copy pathEnvironment.py
File metadata and controls
69 lines (50 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""Environment class definition file."""
from parapy.core import Attribute, Base, Input, Part, action, child
from parapy.exchange.step import STEPReader
from model.auxiliary import dedupe_pts
from model.Component import Component
from model.paths import IN_DIR
class Environment(Base):
"""Represent the Environment class.
This class handles the environment, which includes the oml.
"""
oml_file_name: str = Input()
dedupe_thresh: float = Input(25)
component_definition: list[int] = [[0], [1,2], [3,4], [5,6], [7,8], [9,10]]
component_orientation: list[str] = ["zy", "xz", "xz", "xy", "xz", "xz"]
component_names: list[str] = ["fuselage", "right_wing", "left_wing", "vertical_tail", "left_horizontal_tail", "right_horizontal_tail"]
component_minimums: list[int] = [1000, 800, 800, 250, 250, 250]
component_iscube: list[bool] = [True, True, True, True, True, True]
@Attribute
def oml_children(self):
"""Create the oml reader Object."""
return STEPReader(filename=str(IN_DIR / self.oml_file_name)).children
@Part
def components(self):
"""Create a component from the STEP file."""
return Component(quantify=len(self.component_definition),
orientation=self.component_orientation[child.index],
indexes=self.component_definition[child.index],
name=self.component_names[child.index],
label=self.component_names[child.index],
min_cell_size=self.component_minimums[child.index],
cube_cells=self.component_iscube[child.index])
@action(label = "Export Environment Components")
def export_oml_children(self):
"""Export the OML children."""
for component in self.components:
component.step_writer.write()
@action(label = "Generate Point Clouds in Analysis Situs")
def call_analysis_situs(self):
"""Call Analysis Situs for each component to generate the point clouds."""
for component in self.components:
component.call_analysis_situs()
@Attribute
def point_cloud(self):
"""Create list of all the points created by each component."""
points = []
for component in self.components:
points += component.point_cloud
points = dedupe_pts(points=points,
thresh=self.dedupe_thresh)
return points