mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Expose geometry types in snake case
Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -37,9 +37,9 @@ if TYPE_CHECKING:
|
||||
|
||||
T = TypeVar("T")
|
||||
ShapeElementType = Union[
|
||||
ifcopenshell_wrapper.BRepElement, ifcopenshell_wrapper.TriangulationElement, ifcopenshell_wrapper.SerializedElement
|
||||
ifcopenshell_wrapper.native_element, ifcopenshell_wrapper.triangulation_element, ifcopenshell_wrapper.serialized_element
|
||||
]
|
||||
ShapeType = Union[ifcopenshell_wrapper.BRep, ifcopenshell_wrapper.Triangulation, ifcopenshell_wrapper.Serialization]
|
||||
ShapeType = Union[ifcopenshell_wrapper.native, ifcopenshell_wrapper.triangulation, ifcopenshell_wrapper.serialization]
|
||||
|
||||
|
||||
def wrap_shape_creation(settings, shape):
|
||||
@@ -54,7 +54,7 @@ if has_occ:
|
||||
except ImportError:
|
||||
from OCC import TopoDS # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
def wrap_shape_creation(settings: settings, shape: ifcopenshell_wrapper.Element):
|
||||
def wrap_shape_creation(settings: settings, shape: ifcopenshell_wrapper.element):
|
||||
if getattr(settings, "use_python_opencascade", False):
|
||||
return utils.create_shape_from_serialization(shape)
|
||||
else:
|
||||
@@ -252,7 +252,7 @@ class settings_mixin:
|
||||
if k in map(self.rname, self.setting_names()):
|
||||
return k
|
||||
else:
|
||||
raise AttributeError("'Settings' object has no attribute '%s'" % k)
|
||||
raise AttributeError("'settings' object has no attribute '%s'" % k)
|
||||
|
||||
def build_parser(self, parser) -> None:
|
||||
"""
|
||||
@@ -304,11 +304,11 @@ class settings_mixin:
|
||||
self.set(k.replace("_", "-"), v)
|
||||
|
||||
|
||||
class settings(settings_mixin, ifcopenshell_wrapper.Settings):
|
||||
class settings(settings_mixin, ifcopenshell_wrapper.settings):
|
||||
use_python_opencascade = False
|
||||
|
||||
|
||||
class iterator(ifcopenshell_wrapper.Iterator):
|
||||
class iterator(ifcopenshell_wrapper.iterator):
|
||||
def __init__(
|
||||
self,
|
||||
settings: settings,
|
||||
@@ -370,7 +370,7 @@ class iterator(ifcopenshell_wrapper.Iterator):
|
||||
if has_occ:
|
||||
|
||||
def get(self):
|
||||
return wrap_shape_creation(self.settings, ifcopenshell_wrapper.Iterator.get(self))
|
||||
return wrap_shape_creation(self.settings, ifcopenshell_wrapper.iterator.get(self))
|
||||
|
||||
def __iter__(self) -> Generator[IteratorOutput, None, None]:
|
||||
if self.initialize():
|
||||
@@ -380,7 +380,7 @@ class iterator(ifcopenshell_wrapper.Iterator):
|
||||
break
|
||||
|
||||
def get_task_products(self):
|
||||
return entity_instance.wrap_value(ifcopenshell_wrapper.Iterator.get_task_products(self), self.file)
|
||||
return entity_instance.wrap_value(ifcopenshell_wrapper.iterator.get_task_products(self), self.file)
|
||||
|
||||
|
||||
ClashType = Literal["protrusion", "pierce", "collision", "clearance"]
|
||||
@@ -404,7 +404,7 @@ class tree(ifcopenshell_wrapper.tree):
|
||||
|
||||
def select(
|
||||
self,
|
||||
value: Union[entity_instance, ifcopenshell_wrapper.BRepElement, tuple[float, float, float]],
|
||||
value: Union[entity_instance, ifcopenshell_wrapper.native_element, tuple[float, float, float]],
|
||||
**kwargs,
|
||||
) -> list[entity_instance]:
|
||||
def unwrap(value):
|
||||
@@ -415,7 +415,7 @@ class tree(ifcopenshell_wrapper.tree):
|
||||
return value
|
||||
|
||||
args = [self, unwrap(value)]
|
||||
if isinstance(value, (entity_instance, ifcopenshell_wrapper.BRepElement)):
|
||||
if isinstance(value, (entity_instance, ifcopenshell_wrapper.native_element)):
|
||||
args.append(kwargs.get("completely_within", False))
|
||||
if "extend" in kwargs:
|
||||
args.append(kwargs["extend"])
|
||||
@@ -480,7 +480,7 @@ def create_shape(
|
||||
repr: Optional[entity_instance] = None,
|
||||
geometry_library: GEOMETRY_LIBRARY = "opencascade",
|
||||
logger: Optional[ifcopenshell.logger] = None,
|
||||
) -> Union[ShapeType, ShapeElementType, ifcopenshell_wrapper.Transformation, utils.shape_tuple, TopoDS.TopoDS_Shape]:
|
||||
) -> Union[ShapeType, ShapeElementType, ifcopenshell_wrapper.transformation, utils.shape_tuple, TopoDS.TopoDS_Shape]:
|
||||
"""
|
||||
Returns a geometric interpretation of the IFC entity instance
|
||||
|
||||
@@ -494,7 +494,7 @@ def create_shape(
|
||||
- `inst` is IfcRepresentation and `repr` is None -> ShapeType\n
|
||||
- `inst` is IfcRepresentationItem and `repr` is None -> ShapeType\n
|
||||
- `inst` is IfcProfileDef and `repr` is None -> ShapeType\n
|
||||
- `inst` is IfcPlacement / IfcObjectPlacement -> Transformation\n
|
||||
- `inst` is IfcPlacement / IfcObjectPlacement -> transformation\n
|
||||
- `inst` is IfcTypeProduct and `repr` is None -> None\n
|
||||
- `inst` is IfcTypeProduct and `repr` is provided -> RuntimeError
|
||||
(for IfcTypeProducts provide just IfcRepresentation as `inst`).\n
|
||||
@@ -664,7 +664,7 @@ class _serializer_factory:
|
||||
self.extension = extension
|
||||
self.__name__ = name
|
||||
|
||||
def __call__(self, out_filename: Union[str, PathLike[str]], *args: Any) -> ifcopenshell_wrapper.GeometrySerializer:
|
||||
def __call__(self, out_filename: Union[str, PathLike[str]], *args: Any) -> ifcopenshell_wrapper.geometry_serializer:
|
||||
if self.name == "obj" and len(args) == 2:
|
||||
output_filename = args[0]
|
||||
output_temp_filename = out_filename
|
||||
|
||||
@@ -60,7 +60,7 @@ except ImportError:
|
||||
class shape_tuple(NamedTuple):
|
||||
"""A tuple containing IfcOpenShell serialized element/shape and pythonOCC shape."""
|
||||
|
||||
data: Union[ifcopenshell_wrapper.SerializedElement, ifcopenshell_wrapper.Serialization]
|
||||
data: Union[ifcopenshell_wrapper.serialized_element, ifcopenshell_wrapper.serialization]
|
||||
geometry: TopoDS.TopoDS_Shape
|
||||
styles: tuple[tuple[float, float, float, float], ...]
|
||||
style_ids: tuple[int, ...]
|
||||
@@ -268,16 +268,16 @@ def serialize_shape(shape):
|
||||
|
||||
|
||||
def create_shape_from_serialization(
|
||||
brep_object: Union[ifcopenshell_wrapper.SerializedElement, ifcopenshell_wrapper.Serialization],
|
||||
brep_object: Union[ifcopenshell_wrapper.serialized_element, ifcopenshell_wrapper.serialization],
|
||||
) -> Union[shape_tuple, TopoDS.TopoDS_Shape]:
|
||||
brep_data, occ_shape, styles, style_ids = None, None, (), ()
|
||||
|
||||
is_product_shape = True
|
||||
if isinstance(brep_object, ifcopenshell_wrapper.SerializedElement):
|
||||
if isinstance(brep_object, ifcopenshell_wrapper.serialized_element):
|
||||
brep_data = brep_object.geometry.brep_data
|
||||
styles = brep_object.geometry.surface_styles
|
||||
style_ids = brep_object.geometry.surface_style_ids
|
||||
elif isinstance(brep_object, ifcopenshell_wrapper.Serialization):
|
||||
elif isinstance(brep_object, ifcopenshell_wrapper.serialization):
|
||||
try:
|
||||
brep_data = brep_object.brep_data
|
||||
styles = brep_object.surface_styles
|
||||
|
||||
@@ -105,7 +105,7 @@ class spf_header:
|
||||
@property
|
||||
def file_schema(self) -> entity_instance: ...
|
||||
|
||||
class BRep(Representation):
|
||||
class native(representation):
|
||||
def __init__(self, settings, entity, id, shapes): ...
|
||||
def as_compound(self, force_meters=False): ...
|
||||
def begin(self): ...
|
||||
@@ -118,30 +118,30 @@ class BRep(Representation):
|
||||
def shapes(self): ...
|
||||
def size(self): ...
|
||||
|
||||
class BRepElement(Element):
|
||||
class native_element(element):
|
||||
def __init__(self, id, parent_id, name, type, guid, context, trsf, geometry, product): ...
|
||||
def calculate_projected_surface_area(self, along_x, along_y, along_z): ...
|
||||
@property
|
||||
def geometry(self) -> BRep: ...
|
||||
def geometry(self) -> native: ...
|
||||
@property
|
||||
def surface_area(self): ...
|
||||
@property
|
||||
def volume(self): ...
|
||||
|
||||
class ConversionResult:
|
||||
class conversion_result:
|
||||
def ItemId(self): ...
|
||||
def Placement(self): ...
|
||||
def Shape(self): ...
|
||||
def Style(self): ...
|
||||
def StylePtr(self): ...
|
||||
def __init__(self, *args): ...
|
||||
def append(self, trsf): ...
|
||||
def apply_transform(self, unit_scale=1.0): ...
|
||||
def hasStyle(self): ...
|
||||
def placement(self): ...
|
||||
def prepend(self, trsf): ...
|
||||
def setStyle(self, newStyle): ...
|
||||
def shape(self) -> conversion_result_shape: ...
|
||||
def style(self): ...
|
||||
def style_ptr(self): ...
|
||||
|
||||
class ConversionResultShape:
|
||||
class conversion_result_shape:
|
||||
def serialize(self, place, arg3): ...
|
||||
def triangulate(self, *args): ...
|
||||
def __init__(self, *args, **kwargs): ...
|
||||
@@ -193,7 +193,7 @@ class DoubleArray3:
|
||||
def size(self): ...
|
||||
def swap(self, v): ...
|
||||
|
||||
class Element:
|
||||
class element:
|
||||
def __init__(self, settings, id, parent_id, name, type, guid, context, trsf, product): ...
|
||||
# TODO: Remove from the wrapper?
|
||||
def SetParents(self, newparents): ...
|
||||
@@ -233,7 +233,7 @@ class Element:
|
||||
@property
|
||||
def product(self) -> entity_instance: ...
|
||||
@property
|
||||
def transformation(self) -> Transformation: ...
|
||||
def transformation(self) -> transformation: ...
|
||||
@property
|
||||
def transformation_buffer(self) -> bytes: ...
|
||||
@property
|
||||
@@ -252,7 +252,7 @@ class Element:
|
||||
"""
|
||||
...
|
||||
|
||||
class GeometrySerializer:
|
||||
class geometry_serializer:
|
||||
READ_BREP: Any
|
||||
READ_TRIANGULATION: Any
|
||||
def __init__(self, *args, **kwargs): ...
|
||||
@@ -264,7 +264,7 @@ class GeometrySerializer:
|
||||
def ready(self): ...
|
||||
def setFile(self, file: file) -> None: ...
|
||||
def setUnitNameAndMagnitude(self, name, magnitude): ...
|
||||
def settings(self, *args) -> "Settings": ...
|
||||
def settings(self, *args) -> "settings": ...
|
||||
def write(self, *args): ...
|
||||
def writeHeader(self): ...
|
||||
|
||||
@@ -284,7 +284,7 @@ class instance_streamer:
|
||||
def status(self): ...
|
||||
def yield_header_instances(self, enabled): ...
|
||||
|
||||
class Iterator:
|
||||
class iterator:
|
||||
def __init__(self, *args): ...
|
||||
initialization_outcome_: Any
|
||||
processed_: Any
|
||||
@@ -294,7 +294,7 @@ class Iterator:
|
||||
def create(self): ...
|
||||
def file(self): ...
|
||||
def filters(self, *args): ...
|
||||
def get(self) -> Element:
|
||||
def get(self) -> element:
|
||||
"""Get last processed element."""
|
||||
...
|
||||
|
||||
@@ -344,7 +344,7 @@ class OpaqueCoordinate_4:
|
||||
def size(self): ...
|
||||
def to_double(self): ...
|
||||
|
||||
class OpaqueNumber:
|
||||
class opaque_number:
|
||||
def abs(self): ...
|
||||
def add(self, other): ...
|
||||
def divide(self, other): ...
|
||||
@@ -358,7 +358,7 @@ class OpaqueNumber:
|
||||
def to_double(self): ...
|
||||
def to_string(self): ...
|
||||
|
||||
class Representation:
|
||||
class representation:
|
||||
def __init__(self, settings, entity, id): ...
|
||||
def entity(self): ...
|
||||
@property
|
||||
@@ -369,7 +369,7 @@ class Representation:
|
||||
- 2468 - IfcRelVoidsElement
|
||||
"""
|
||||
|
||||
def settings(self) -> "Settings": ...
|
||||
def settings(self) -> "settings": ...
|
||||
|
||||
class RocksDBPrefixIterator:
|
||||
def __init__(self, storage, prefix): ...
|
||||
@@ -386,7 +386,7 @@ class RocksDbSerializer:
|
||||
def setFile(self, arg2) -> None: ...
|
||||
def writeHeader(self) -> None: ...
|
||||
|
||||
class Serialization(Representation):
|
||||
class serialization(representation):
|
||||
def __init__(self, brep): ...
|
||||
@property
|
||||
def brep_data(self): ...
|
||||
@@ -395,12 +395,12 @@ class Serialization(Representation):
|
||||
@property
|
||||
def surface_styles(self): ...
|
||||
|
||||
class SerializedElement(Element):
|
||||
class serialized_element(element):
|
||||
def __init__(self, shape_model): ...
|
||||
@property
|
||||
def geometry(self) -> Serialization: ...
|
||||
def geometry(self) -> serialization: ...
|
||||
|
||||
class Settings:
|
||||
class settings:
|
||||
def get_(self, name): ...
|
||||
def get_type(self, name): ...
|
||||
def set_(self, *args): ...
|
||||
@@ -418,13 +418,13 @@ class SwigPyIterator:
|
||||
def previous(self): ...
|
||||
def value(self): ...
|
||||
|
||||
class Transformation:
|
||||
class transformation:
|
||||
def __init__(self, settings, matrix): ...
|
||||
def data(self): ...
|
||||
@property
|
||||
def matrix(self): ...
|
||||
|
||||
class Triangulation(Representation):
|
||||
class triangulation(representation):
|
||||
def __init__(self, *args): ...
|
||||
def addEdge(self, item_id, style, i0, i1): ...
|
||||
def addFace(self, *args): ...
|
||||
@@ -479,12 +479,12 @@ class Triangulation(Representation):
|
||||
@property
|
||||
def verts_buffer(self) -> bytes: ...
|
||||
|
||||
class TriangulationElement(Element):
|
||||
class triangulation_element(element):
|
||||
def __init__(self, *args): ...
|
||||
@property
|
||||
def geometry(self) -> Triangulation: ...
|
||||
def geometry(self) -> triangulation: ...
|
||||
|
||||
class WriteOnlyGeometrySerializer(GeometrySerializer):
|
||||
class write_only_geometry_serializer(geometry_serializer):
|
||||
def __init__(self, *args, **kwargs): ...
|
||||
def read(self, *args): ...
|
||||
|
||||
@@ -1568,7 +1568,7 @@ class torus(surface):
|
||||
|
||||
class tree:
|
||||
def __init__(self, *args): ...
|
||||
def add_element(self, element: Element | None) -> None: ...
|
||||
def add_element(self, element: element | None) -> None: ...
|
||||
def add_file(self, *args) -> None: ...
|
||||
def clash_clearance_many(
|
||||
self,
|
||||
@@ -1651,7 +1651,7 @@ def set_feature(x: Literal["use_attribute_value_derived"], v: bool) -> None:
|
||||
|
||||
def create_box(*args): ...
|
||||
def create_epeck(*args): ...
|
||||
def create_geometry_serializer(*args) -> GeometrySerializer: ...
|
||||
def create_geometry_serializer(*args) -> geometry_serializer: ...
|
||||
def create_shape(*args): ...
|
||||
def flatten(deep): ...
|
||||
def get_info_cpp(v: entity_instance, recursive: bool, include_identifier: bool) -> dict[str, Any]: ...
|
||||
|
||||
@@ -46,7 +46,7 @@ MatrixType = npt.NDArray[np.float64]
|
||||
|
||||
tol = 1e-6
|
||||
|
||||
# NOTE: See representation.h for W.Triangulation buffer types.
|
||||
# NOTE: See representation.h for W.triangulation buffer types.
|
||||
|
||||
# NOTE: For functions that return a single scalar ensure to use .item() to
|
||||
# return the Python float instead of numpy float
|
||||
@@ -68,7 +68,7 @@ def is_x(value: float, x: float, tolerance: Optional[float] = None) -> bool:
|
||||
return abs(x - value) < tolerance
|
||||
|
||||
|
||||
def get_volume(geometry: W.Triangulation) -> float:
|
||||
def get_volume(geometry: W.triangulation) -> float:
|
||||
"""Calculates the total internal volume of a geometry
|
||||
|
||||
Volumes of non-manifold geometry will be unpredictable.
|
||||
@@ -98,7 +98,7 @@ def get_volume(geometry: W.Triangulation) -> float:
|
||||
return abs(sum(volumes))
|
||||
|
||||
|
||||
def get_x(geometry: W.Triangulation) -> float:
|
||||
def get_x(geometry: W.triangulation) -> float:
|
||||
"""Calculates the X length of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -108,7 +108,7 @@ def get_x(geometry: W.Triangulation) -> float:
|
||||
return (np.max(verts_flat[0::3]) - np.min(verts_flat[0::3])).item()
|
||||
|
||||
|
||||
def get_y(geometry: W.Triangulation) -> float:
|
||||
def get_y(geometry: W.triangulation) -> float:
|
||||
"""Calculates the Y length of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -118,7 +118,7 @@ def get_y(geometry: W.Triangulation) -> float:
|
||||
return (np.max(verts_flat[1::3]) - np.min(verts_flat[1::3])).item()
|
||||
|
||||
|
||||
def get_z(geometry: W.Triangulation) -> float:
|
||||
def get_z(geometry: W.triangulation) -> float:
|
||||
"""Calculates the Z length of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -128,7 +128,7 @@ def get_z(geometry: W.Triangulation) -> float:
|
||||
return (np.max(verts_flat[2::3]) - np.min(verts_flat[2::3])).item()
|
||||
|
||||
|
||||
def get_max_xy(geometry: W.Triangulation) -> float:
|
||||
def get_max_xy(geometry: W.triangulation) -> float:
|
||||
"""Gets the maximum X or Y length of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -137,7 +137,7 @@ def get_max_xy(geometry: W.Triangulation) -> float:
|
||||
return max(get_x(geometry), get_y(geometry))
|
||||
|
||||
|
||||
def get_max_xyz(geometry: W.Triangulation) -> float:
|
||||
def get_max_xyz(geometry: W.triangulation) -> float:
|
||||
"""Gets the maximum X, Y, or Z length of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -146,7 +146,7 @@ def get_max_xyz(geometry: W.Triangulation) -> float:
|
||||
return max(get_x(geometry), get_y(geometry), get_z(geometry))
|
||||
|
||||
|
||||
def get_min_xyz(geometry: W.Triangulation) -> float:
|
||||
def get_min_xyz(geometry: W.triangulation) -> float:
|
||||
"""Gets the minimum X, Y, or Z length of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -164,7 +164,7 @@ def get_shape_matrix(shape: ShapeElementType) -> MatrixType:
|
||||
return np.frombuffer(shape.transformation_buffer, "d").reshape((4, 4), order="F")
|
||||
|
||||
|
||||
def get_bbox_centroid(geometry: W.Triangulation) -> tuple[float, float, float]:
|
||||
def get_bbox_centroid(geometry: W.triangulation) -> tuple[float, float, float]:
|
||||
"""Calculates the bounding box centroid of the geometry
|
||||
|
||||
The centroid is in local coordinates relative to the object's placement.
|
||||
@@ -176,7 +176,7 @@ def get_bbox_centroid(geometry: W.Triangulation) -> tuple[float, float, float]:
|
||||
return (np.min(vertices_array, axis=0) + np.max(vertices_array, axis=0)) / 2
|
||||
|
||||
|
||||
def get_vert_centroid(geometry: W.Triangulation) -> tuple[float, float, float]:
|
||||
def get_vert_centroid(geometry: W.triangulation) -> tuple[float, float, float]:
|
||||
"""Calculates the average vertex centroid of the geometry
|
||||
|
||||
The centroid is in local coordinates relative to the object's placement.
|
||||
@@ -188,7 +188,7 @@ def get_vert_centroid(geometry: W.Triangulation) -> tuple[float, float, float]:
|
||||
|
||||
|
||||
def get_element_bbox_centroid(
|
||||
element: ifcopenshell.entity_instance, geometry: W.Triangulation
|
||||
element: ifcopenshell.entity_instance, geometry: W.triangulation
|
||||
) -> npt.NDArray[np.float64]:
|
||||
"""Calculates the element's bounding box centroid
|
||||
|
||||
@@ -206,7 +206,7 @@ def get_element_bbox_centroid(
|
||||
return (mat @ np.array([*centroid, 1.0]))[0:3]
|
||||
|
||||
|
||||
def get_shape_bbox_centroid(shape: ShapeElementType, geometry: W.Triangulation) -> npt.NDArray[np.float64]:
|
||||
def get_shape_bbox_centroid(shape: ShapeElementType, geometry: W.triangulation) -> npt.NDArray[np.float64]:
|
||||
"""Calculates the shape's bounding box centroid
|
||||
|
||||
The centroid is in global coordinates. Note that if you do not have the
|
||||
@@ -220,7 +220,7 @@ def get_shape_bbox_centroid(shape: ShapeElementType, geometry: W.Triangulation)
|
||||
return (get_shape_matrix(shape) @ np.array([*centroid, 1.0]))[0:3]
|
||||
|
||||
|
||||
def get_vertices(geometry: W.Triangulation, is_2d: bool = False) -> npt.NDArray[np.float64]:
|
||||
def get_vertices(geometry: W.triangulation, is_2d: bool = False) -> npt.NDArray[np.float64]:
|
||||
"""Get all the vertices as a numpy array
|
||||
|
||||
Vertices are in local coordinates.
|
||||
@@ -235,7 +235,7 @@ def get_vertices(geometry: W.Triangulation, is_2d: bool = False) -> npt.NDArray[
|
||||
return np.frombuffer(geometry.verts_buffer, "d").reshape(-1, 3)
|
||||
|
||||
|
||||
def get_edges(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
|
||||
def get_edges(geometry: W.triangulation) -> npt.NDArray[np.int32]:
|
||||
"""Get all the edges as a numpy array
|
||||
|
||||
Results are a nested numpy array e.g. [[e1v1, e1v2], [e2v1, e2v2], ...]
|
||||
@@ -251,7 +251,7 @@ def get_edges(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
|
||||
return np.frombuffer(geometry.edges_buffer, dtype="i").reshape(-1, 2)
|
||||
|
||||
|
||||
def get_faces(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
|
||||
def get_faces(geometry: W.triangulation) -> npt.NDArray[np.int32]:
|
||||
"""Get all the faces as a numpy array
|
||||
|
||||
Faces are always triangulated. If the shape is a BRep and you want to get
|
||||
@@ -266,7 +266,7 @@ def get_faces(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
|
||||
return np.frombuffer(geometry.faces_buffer, dtype="i").reshape(-1, 3)
|
||||
|
||||
|
||||
def get_material_colors(geometry: W.Triangulation) -> npt.NDArray[np.float64]:
|
||||
def get_material_colors(geometry: W.triangulation) -> npt.NDArray[np.float64]:
|
||||
"""Get material colors as a numpy array.
|
||||
|
||||
:return: A numpy array listing RGBA color for each shape's material.
|
||||
@@ -277,7 +277,7 @@ def get_material_colors(geometry: W.Triangulation) -> npt.NDArray[np.float64]:
|
||||
return np.frombuffer(geometry.colors_buffer, dtype="d").reshape(-1, 4)
|
||||
|
||||
|
||||
def get_normals(geometry: W.Triangulation) -> npt.NDArray[np.float64]:
|
||||
def get_normals(geometry: W.triangulation) -> npt.NDArray[np.float64]:
|
||||
"""Get vertex normals as a numpy array.
|
||||
|
||||
See geometry settings documentation for settings that affect normals.
|
||||
@@ -288,12 +288,12 @@ def get_normals(geometry: W.Triangulation) -> npt.NDArray[np.float64]:
|
||||
return np.frombuffer(geometry.normals_buffer, dtype="d").reshape(-1, 3)
|
||||
|
||||
|
||||
def get_shape_material_styles(geometry: W.Triangulation) -> tuple[W.style, ...]:
|
||||
def get_shape_material_styles(geometry: W.triangulation) -> tuple[W.style, ...]:
|
||||
"""Get list of material styles."""
|
||||
return geometry.materials
|
||||
|
||||
|
||||
def get_faces_material_style_ids(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
|
||||
def get_faces_material_style_ids(geometry: W.triangulation) -> npt.NDArray[np.int32]:
|
||||
"""Get material styles ids for the geometry faces.
|
||||
|
||||
Return a list of corresponding indices of styles from get_shape_material_styles for each face.
|
||||
@@ -302,12 +302,12 @@ def get_faces_material_style_ids(geometry: W.Triangulation) -> npt.NDArray[np.in
|
||||
return np.frombuffer(geometry.material_ids_buffer, dtype="i")
|
||||
|
||||
|
||||
def get_faces_representation_item_ids(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
|
||||
def get_faces_representation_item_ids(geometry: W.triangulation) -> npt.NDArray[np.int32]:
|
||||
"""Get representation item ids for the geometry faces."""
|
||||
return np.frombuffer(geometry.item_ids_buffer, dtype="i")
|
||||
|
||||
|
||||
def get_edges_representation_item_ids(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
|
||||
def get_edges_representation_item_ids(geometry: W.triangulation) -> npt.NDArray[np.int32]:
|
||||
"""Get representation item ids for the geometry edges.
|
||||
|
||||
Can be useful for geometry without faces and in general is more universal
|
||||
@@ -316,7 +316,7 @@ def get_edges_representation_item_ids(geometry: W.Triangulation) -> npt.NDArray[
|
||||
return np.frombuffer(geometry.edges_item_ids_buffer, dtype="i")
|
||||
|
||||
|
||||
def get_shape_vertices(shape: ShapeElementType, geometry: W.Triangulation) -> npt.NDArray[np.float64]:
|
||||
def get_shape_vertices(shape: ShapeElementType, geometry: W.triangulation) -> npt.NDArray[np.float64]:
|
||||
"""Get the shape's vertices as a numpy array
|
||||
|
||||
Vertices are in global coordinates. If you do not have the shape, you can
|
||||
@@ -334,7 +334,7 @@ def get_shape_vertices(shape: ShapeElementType, geometry: W.Triangulation) -> np
|
||||
return np.delete((mat @ np.hstack((verts, np.ones((len(verts), 1)))).T).T, -1, axis=1)
|
||||
|
||||
|
||||
def get_element_vertices(element: ifcopenshell.entity_instance, geometry: W.Triangulation) -> npt.NDArray[np.float64]:
|
||||
def get_element_vertices(element: ifcopenshell.entity_instance, geometry: W.triangulation) -> npt.NDArray[np.float64]:
|
||||
"""Get the element's vertices as a numpy array
|
||||
|
||||
Vertices are in global coordinates. Note that if you have the shape, it is
|
||||
@@ -353,7 +353,7 @@ def get_element_vertices(element: ifcopenshell.entity_instance, geometry: W.Tria
|
||||
return np.delete((mat @ np.hstack((verts, np.ones((len(verts), 1)))).T).T, -1, axis=1)
|
||||
|
||||
|
||||
def get_bottom_elevation(geometry: W.Triangulation) -> float:
|
||||
def get_bottom_elevation(geometry: W.triangulation) -> float:
|
||||
"""Gets the lowest local Z ordinate of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -363,7 +363,7 @@ def get_bottom_elevation(geometry: W.Triangulation) -> float:
|
||||
return np.min(verts_flat[2::3]).item()
|
||||
|
||||
|
||||
def get_top_elevation(geometry: W.Triangulation) -> float:
|
||||
def get_top_elevation(geometry: W.triangulation) -> float:
|
||||
"""Gets the highest local Z ordinate of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -373,7 +373,7 @@ def get_top_elevation(geometry: W.Triangulation) -> float:
|
||||
return np.max(verts_flat[2::3]).item()
|
||||
|
||||
|
||||
def get_shape_bottom_elevation(shape: ShapeElementType, geometry: W.Triangulation) -> float:
|
||||
def get_shape_bottom_elevation(shape: ShapeElementType, geometry: W.triangulation) -> float:
|
||||
"""Gets the lowest global Z ordinate of the shape
|
||||
|
||||
If you do not have the shape, you can use :func:`get_element_bottom_elevation`
|
||||
@@ -386,7 +386,7 @@ def get_shape_bottom_elevation(shape: ShapeElementType, geometry: W.Triangulatio
|
||||
return min([v[2] for v in get_shape_vertices(shape, geometry)])
|
||||
|
||||
|
||||
def get_shape_top_elevation(shape: ShapeElementType, geometry: W.Triangulation) -> float:
|
||||
def get_shape_top_elevation(shape: ShapeElementType, geometry: W.triangulation) -> float:
|
||||
"""Gets the highest global Z ordinate of the shape
|
||||
|
||||
If you do not have the shape, you can use :func:`get_element_top_elevation`
|
||||
@@ -399,7 +399,7 @@ def get_shape_top_elevation(shape: ShapeElementType, geometry: W.Triangulation)
|
||||
return max([v[2] for v in get_shape_vertices(shape, geometry)])
|
||||
|
||||
|
||||
def get_element_bottom_elevation(element: ifcopenshell.entity_instance, geometry: W.Triangulation) -> float:
|
||||
def get_element_bottom_elevation(element: ifcopenshell.entity_instance, geometry: W.triangulation) -> float:
|
||||
"""Gets the lowest global Z ordinate of the element
|
||||
|
||||
Note that if you have the shape, it is more efficient to use
|
||||
@@ -412,7 +412,7 @@ def get_element_bottom_elevation(element: ifcopenshell.entity_instance, geometry
|
||||
return min([v[2] for v in get_element_vertices(element, geometry)])
|
||||
|
||||
|
||||
def get_element_top_elevation(element: ifcopenshell.entity_instance, geometry: W.Triangulation) -> float:
|
||||
def get_element_top_elevation(element: ifcopenshell.entity_instance, geometry: W.triangulation) -> float:
|
||||
"""Gets the highest global Z ordinate of the element
|
||||
|
||||
Note that if you have the shape, it is more efficient to use
|
||||
@@ -458,7 +458,7 @@ def get_area_vf(vertices: npt.NDArray[np.float64], faces: npt.NDArray[np.int32])
|
||||
return mesh_area.item()
|
||||
|
||||
|
||||
def get_area(geometry: W.Triangulation) -> float:
|
||||
def get_area(geometry: W.triangulation) -> float:
|
||||
"""Calculates the surface area of the geometry
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
@@ -470,7 +470,7 @@ def get_area(geometry: W.Triangulation) -> float:
|
||||
|
||||
|
||||
def get_side_area(
|
||||
geometry: W.Triangulation,
|
||||
geometry: W.triangulation,
|
||||
axis: AXIS_LITERAL = "Y",
|
||||
direction: Optional[VectorType] = None,
|
||||
angle: float = 90.0,
|
||||
@@ -520,7 +520,7 @@ def get_side_area(
|
||||
return get_area_vf(vertices, filtered_faces)
|
||||
|
||||
|
||||
def get_max_side_area(geometry: W.Triangulation) -> float:
|
||||
def get_max_side_area(geometry: W.triangulation) -> float:
|
||||
"""Returns the maximum X, Y, or Z side area
|
||||
|
||||
See :func:`get_side_area` for how side area is calculated.
|
||||
@@ -531,12 +531,12 @@ def get_max_side_area(geometry: W.Triangulation) -> float:
|
||||
return max(get_side_area(geometry, axis="X"), get_side_area(geometry, axis="Y"), get_side_area(geometry, axis="Z"))
|
||||
|
||||
|
||||
def get_top_area(geometry: W.Triangulation) -> float:
|
||||
def get_top_area(geometry: W.triangulation) -> float:
|
||||
return get_side_area(geometry, axis="Z", angle=45)
|
||||
|
||||
|
||||
def get_footprint_area(
|
||||
geometry: W.Triangulation,
|
||||
geometry: W.triangulation,
|
||||
axis: AXIS_LITERAL = "Z",
|
||||
direction: Optional[VECTOR_3D] = None,
|
||||
) -> float:
|
||||
@@ -614,7 +614,7 @@ def get_footprint_area(
|
||||
return unioned_polygon.area
|
||||
|
||||
|
||||
def get_outer_surface_area(geometry: W.Triangulation) -> float:
|
||||
def get_outer_surface_area(geometry: W.triangulation) -> float:
|
||||
"""Calculates the outer surface area (i.e. all sides except for top and bottom)
|
||||
|
||||
This is typically useful for calculating painted areas of beams which
|
||||
@@ -640,7 +640,7 @@ def get_outer_surface_area(geometry: W.Triangulation) -> float:
|
||||
return get_area_vf(vertices, filtered_faces)
|
||||
|
||||
|
||||
def get_footprint_perimeter(geometry: W.Triangulation) -> float:
|
||||
def get_footprint_perimeter(geometry: W.triangulation) -> float:
|
||||
"""Calculates the footprint perimeter of the geometry
|
||||
|
||||
All faces with a negative Z normal are considered and the distance of all
|
||||
@@ -743,7 +743,7 @@ def get_base_extrusions(element: ifcopenshell.entity_instance) -> Union[list[ifc
|
||||
return extrusions
|
||||
|
||||
|
||||
def get_total_edge_length(geometry: W.Triangulation) -> float:
|
||||
def get_total_edge_length(geometry: W.triangulation) -> float:
|
||||
"""Calculates the total length of edges in a given geometry.
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
|
||||
Reference in New Issue
Block a user