mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 22:20:00 +00:00
typing
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -31,7 +32,7 @@ from ..entity_instance import entity_instance
|
|||||||
|
|
||||||
from . import has_occ
|
from . import has_occ
|
||||||
|
|
||||||
from typing import TypeVar
|
from typing import TypeVar, Union, Optional
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
||||||
@@ -114,13 +115,21 @@ class serializer_settings(settings_mixin, ifcopenshell_wrapper.SerializerSetting
|
|||||||
class settings(settings_mixin, ifcopenshell_wrapper.Settings):
|
class settings(settings_mixin, ifcopenshell_wrapper.Settings):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Make sure people are able to use python's platform agnostic paths
|
|
||||||
class iterator(ifcopenshell_wrapper.Iterator):
|
class iterator(ifcopenshell_wrapper.Iterator):
|
||||||
def __init__(self, settings, file_or_filename, num_threads=1, include=None, exclude=None, geometry_library="opencascade"):
|
def __init__(
|
||||||
|
self,
|
||||||
|
settings: settings,
|
||||||
|
file_or_filename: Union[file, str],
|
||||||
|
num_threads: int = 1,
|
||||||
|
include: Optional[Union[list[entity_instance],list[str]]] = None,
|
||||||
|
exclude: Optional[Union[list[entity_instance],list[str]]] = None,
|
||||||
|
geometry_library: str = "opencascade"
|
||||||
|
):
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
if isinstance(file_or_filename, file):
|
if isinstance(file_or_filename, file):
|
||||||
file_or_filename = file_or_filename.wrapped_data
|
file_or_filename = file_or_filename.wrapped_data
|
||||||
else:
|
else:
|
||||||
|
# Makes sure people are able to use python's platform agnostic paths
|
||||||
file_or_filename = os.path.abspath(file_or_filename)
|
file_or_filename = os.path.abspath(file_or_filename)
|
||||||
|
|
||||||
if include is not None and exclude is not None:
|
if include is not None and exclude is not None:
|
||||||
@@ -165,7 +174,7 @@ class iterator(ifcopenshell_wrapper.Iterator):
|
|||||||
|
|
||||||
|
|
||||||
class tree(ifcopenshell_wrapper.tree):
|
class tree(ifcopenshell_wrapper.tree):
|
||||||
def __init__(self, file=None, settings=None):
|
def __init__(self, file: Optional[file] = None, settings: Optional[settings] = None):
|
||||||
args = [self]
|
args = [self]
|
||||||
if file is not None:
|
if file is not None:
|
||||||
args.append(file.wrapped_data)
|
args.append(file.wrapped_data)
|
||||||
@@ -173,13 +182,19 @@ class tree(ifcopenshell_wrapper.tree):
|
|||||||
args.append(settings)
|
args.append(settings)
|
||||||
ifcopenshell_wrapper.tree.__init__(*args)
|
ifcopenshell_wrapper.tree.__init__(*args)
|
||||||
|
|
||||||
def add_file(self, file, settings):
|
def add_file(self, file: file, settings: settings) -> None:
|
||||||
ifcopenshell_wrapper.tree.add_file(self, file.wrapped_data, settings)
|
ifcopenshell_wrapper.tree.add_file(self, file.wrapped_data, settings)
|
||||||
|
|
||||||
def add_iterator(self, iterator):
|
def add_iterator(self, iterator: iterator) -> None:
|
||||||
ifcopenshell_wrapper.tree.add_file(self, iterator)
|
ifcopenshell_wrapper.tree.add_file(self, iterator)
|
||||||
|
|
||||||
def select(self, value, **kwargs):
|
def select(
|
||||||
|
self,
|
||||||
|
value: Union[
|
||||||
|
entity_instance, ifcopenshell_wrapper.BRepElement, tuple[float, float, float], TopoDS.TopoDS_Shape
|
||||||
|
],
|
||||||
|
**kwargs,
|
||||||
|
) -> list[entity_instance]:
|
||||||
def unwrap(value):
|
def unwrap(value):
|
||||||
if isinstance(value, entity_instance):
|
if isinstance(value, entity_instance):
|
||||||
return value.wrapped_data
|
return value.wrapped_data
|
||||||
@@ -203,7 +218,7 @@ class tree(ifcopenshell_wrapper.tree):
|
|||||||
args.append(kwargs["extend"])
|
args.append(kwargs["extend"])
|
||||||
return [entity_instance(e) for e in ifcopenshell_wrapper.tree.select(*args)]
|
return [entity_instance(e) for e in ifcopenshell_wrapper.tree.select(*args)]
|
||||||
|
|
||||||
def select_box(self, value, **kwargs):
|
def select_box(self, value, **kwargs) -> list[entity_instance]:
|
||||||
def unwrap(value):
|
def unwrap(value):
|
||||||
if isinstance(value, entity_instance):
|
if isinstance(value, entity_instance):
|
||||||
return value.wrapped_data
|
return value.wrapped_data
|
||||||
@@ -219,7 +234,9 @@ class tree(ifcopenshell_wrapper.tree):
|
|||||||
return [entity_instance(e) for e in ifcopenshell_wrapper.tree.select_box(*args)]
|
return [entity_instance(e) for e in ifcopenshell_wrapper.tree.select_box(*args)]
|
||||||
|
|
||||||
|
|
||||||
def create_shape(settings, inst, repr=None):
|
def create_shape(
|
||||||
|
settings: settings, inst: entity_instance, repr: Optional[entity_instance] = None
|
||||||
|
) -> ifcopenshell_wrapper.TriangulationElement:
|
||||||
"""
|
"""
|
||||||
Return a geometric representation from STEP-based IFCREPRESENTATIONSHAPE
|
Return a geometric representation from STEP-based IFCREPRESENTATIONSHAPE
|
||||||
or
|
or
|
||||||
|
|||||||
Reference in New Issue
Block a user