diff --git a/docs/how-to/guide_rad1.md b/docs/how-to/guide_rad1.md index 4c840e7..affea25 100644 --- a/docs/how-to/guide_rad1.md +++ b/docs/how-to/guide_rad1.md @@ -143,7 +143,7 @@ The code block demonstrates how we generate a grid of sensors with 1 meter spacing and 0.75 meters away from the floor: ```py -floor_primitives = fr.unpack_primitive("Objects/floor_aroom.rad") +floor_primitives = fr.unpack_primitives("Objects/floor_aroom.rad") # Since we only have one primitive in this file, # we'll take the first one to parse. floor_polygon = fr.parse_polygon(floor_primitives[0]) diff --git a/frads/methods.py b/frads/methods.py index bf6df4d..3677246 100755 --- a/frads/methods.py +++ b/frads/methods.py @@ -102,8 +102,7 @@ class ShadingGeometryConfig: shading_geometry_file: Union[str, Path] = "" shading_geometry_bytes: Optional[np.ndarray] = None - def __post_init__(self): - ... + def __post_init__(self): ... @dataclass @@ -502,6 +501,7 @@ def __post_init__(self): f"{k} matrix name {v.matrix_name} not found in materials" ) + @dataclass class WorkflowConfig: """Workflow configuration dataclass. @@ -598,13 +598,8 @@ def __init__(self, config: WorkflowConfig): view.view, xres=view.xres, yres=view.yres ) for name, surface in self.config.model.surfaces.items(): - polygons = [parse_polygon(p) for p in surface.primitives] - flipped_primitives = [ - polygon_primitive(p.flip(), s.modifier, s.identifier) - for p, s in zip(polygons, surface.primitives) - ] self.surface_senders[name] = SurfaceSender( - surfaces=flipped_primitives, + surfaces=surface.primitives, basis=surface.basis, ) diff --git a/frads/room.py b/frads/room.py index 0318594..92a3fea 100755 --- a/frads/room.py +++ b/frads/room.py @@ -7,6 +7,7 @@ from frads import utils import numpy as np + @dataclass class WindowSurface: polygon: Polygon @@ -23,7 +24,6 @@ class Surface: identifier: str primitives: List[pr.Primitive] - def move_window(self, distance: float) -> None: """Move windows in its normal direction.""" direction = self.base.normal * distance @@ -48,7 +48,9 @@ def rotate_z(self, radians): modifier=self.base_primitive.modifier, identifier=self.base_primitive.identifier, ) - new_polygons = [plg.rotate(center, zaxis, radians) for plg in self.polygons] + new_polygons = [ + plg.rotate(center, zaxis, radians) for plg in self.polygons + ] new_primitives = [] for idx, polygon in enumerate(new_polygons): new_primitives.append( @@ -75,8 +77,6 @@ def rotate_z(self, radians): self.base_primitive = new_base_primitive - - @dataclass class Room: floor: Surface @@ -106,11 +106,14 @@ def window_primitives(self) -> List[pr.Primitive]: *[srf.primitive for srf in self.wwall.windows], ] - def model_dump(self) -> dict: model = {} - model["materials"] = {"bytes": b" ".join(p.bytes for p in self.materials)} - model["scene"] = {"bytes": b" ".join(p.bytes for p in self.primitives())} + model["materials"] = { + "bytes": b" ".join(p.bytes for p in self.materials) + } + model["scene"] = { + "bytes": b" ".join(p.bytes for p in self.primitives()) + } model["windows"] = {} for primitive in self.window_primitives(): model["windows"][primitive.identifier] = {"bytes": primitive.bytes} @@ -133,7 +136,6 @@ def rotate_z(self, radians): self.wwall.rotate_z(radians) self.nwall.rotate_z(radians) - def validate(self) -> None: """Validate the room model.""" material_names = [p.identifier for p in self.materials] @@ -163,7 +165,7 @@ def make_window( dist_left: float, dist_bot: float, width: float, - height: float + height: float, ) -> Tuple[Polygon, WindowSurface]: """Make one or more window and punch a hole. @@ -199,13 +201,11 @@ def make_window( polygon=window_polygon, modifier="glass_60", identifier=name, - ) + ), ) -def make_window_wwr( - base: Polygon, - wwr: float -) -> Tuple[Polygon, WindowSurface]: + +def make_window_wwr(base: Polygon, wwr: float) -> Tuple[Polygon, WindowSurface]: """ Make a single window and punch a hole based on window-to-wall ratio. @@ -218,7 +218,7 @@ def make_window_wwr( polygon=window_polygon, modifier="glass_60", identifier="void", - ) + ), ) @@ -306,13 +306,16 @@ def create_south_facing_room( ) -> Room: materials = list(utils.material_lib().values()) pt1 = np.array((0, 0, 0)) - pt2 = pt1 + np.array((width, 0, 0)) - pt3 = pt2 + np.array((0, depth, 0)) + pt2 = pt1 + np.array((0, depth, 0)) + pt3 = pt2 + np.array((width, 0, 0)) base_floor = Polygon.rectangle3pts(pt1, pt2, pt3) - _, base_ceiling, base_swall, base_ewall, base_nwall, base_wwall = base_floor.extrude( - np.array((0, 0, floor_floor)) + _, base_ceiling, base_wwall, base_nwall, base_ewall, base_swall = ( + base_floor.extrude(np.array((0, 0, floor_floor))) + ) + base_ceiling = base_ceiling.flip() + base_ceiling = base_ceiling.move( + np.array((0, 0, floor_ceiling - floor_floor)) ) - base_ceiling = base_ceiling.move(np.array((0, 0, floor_ceiling - floor_floor))) floor = create_surface( base_floor, modifier="neutral_lambertian_0.2",