99from compas .geometry import Frame
1010from compas .geometry import Geometry
1111from compas .geometry import Transformation
12- from compas .tolerance import TOL
1312
1413from compas_ifc .file import IFCFile
1514
@@ -74,8 +73,6 @@ def __init__(self, filepath: str = None, schema: str = "IFC4", use_occ: bool = F
7473
7574 """
7675 self .file = IFCFile (self , filepath = filepath , schema = schema , use_occ = use_occ , load_geometries = load_geometries , verbose = verbose , extensions = extensions )
77- if filepath :
78- self .update_linear_deflection ()
7976
8077 @property
8178 def schema (self ) -> "ifcopenshell.ifcopenshell_wrapper.schema_definition" :
@@ -257,13 +254,16 @@ def export(self, path: str, entities: list["Base"] = [], as_snippet: bool = Fals
257254 """
258255 self .file .export (path , entities = entities , as_snippet = as_snippet , export_materials = export_materials , export_properties = export_properties , export_styles = export_styles )
259256
260- def show (self , entity : "Base" = None ):
257+ def show (self , entity : "Base" = None , linear_deflection : float = 100 ):
261258 """Show the IFC file in a viewer, either the entire project or a single entity.
262259
263260 Parameters
264261 ----------
265262 entity : :class:`compas_ifc.entities.base.Base`
266263 The entity to show. If None, the entire project will be shown.
264+ linear_deflection : float
265+ The linear deflection to use for the tesselation of BREP geometries.
266+ Should be adjusted based on the size of the model.
267267 """
268268 try :
269269 from compas_viewer import Viewer
@@ -274,6 +274,7 @@ def show(self, entity: "Base" = None):
274274
275275 viewer = Viewer ()
276276 print (f"Unit: { self .unit } " )
277+ print (f"Using Linear Deflection: { linear_deflection } " )
277278 viewer .unit = self .unit
278279 viewer .ui .sidebar .show_objectsetting = False
279280
@@ -284,7 +285,7 @@ def parse_entity(entity, parent=None):
284285 name = f"[{ entity .__class__ .__name__ } ]{ entity .Name } "
285286 transformation = Transformation .from_frame (entity .frame ) if entity .frame else None
286287 if getattr (entity , "geometry" , None ) and not entity .is_a ("IfcSpace" ):
287- obj = viewer .scene .add (entity .geometry , name = name , parent = parent , hide_coplanaredges = True , ** entity .style )
288+ obj = viewer .scene .add (entity .geometry , name = name , parent = parent , hide_coplanaredges = True , ** entity .style , linear_deflection = linear_deflection )
288289 obj .transformation = transformation
289290 else :
290291 obj = viewer .scene .add_group (name = name , parent = parent )
@@ -358,16 +359,6 @@ def remove(self, entity: Union["Base", list["Base"]]):
358359 """
359360 self .file .remove (entity )
360361
361- def update_linear_deflection (self ):
362- """Update the linear deflection tolerance settings in COMPAS based on the unit of the model."""
363- # TODO: deal with conversion based units like "FOOT"
364- if self .unit == "mm" :
365- TOL .lineardeflection = 1
366- elif self .unit == "cm" :
367- TOL .lineardeflection = 1e-1
368- elif self .unit == "m" :
369- TOL .lineardeflection = 1e-3
370-
371362 @classmethod
372363 def template (cls , schema : str = "IFC4" , building_count : int = 1 , storey_count : int = 1 , unit : str = "mm" , use_occ : bool = False ) -> "Model" :
373364 """Create a template model with a default project, site, building, and storey.
0 commit comments