From e7d16c5f620bc4ddded8b8eae97d6e29c0012490 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 28 Oct 2015 17:24:43 -0200 Subject: [PATCH] Arch: added IFC export preference option to choose triangulation style for non-planar shapes --- src/Mod/Arch/Resources/ui/preferences-ifc.ui | 20 ++++++++++++ src/Mod/Arch/importIFC.py | 32 +++++++++++--------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/Mod/Arch/Resources/ui/preferences-ifc.ui b/src/Mod/Arch/Resources/ui/preferences-ifc.ui index a66584aa01..2f88dbfc17 100644 --- a/src/Mod/Arch/Resources/ui/preferences-ifc.ui +++ b/src/Mod/Arch/Resources/ui/preferences-ifc.ui @@ -314,6 +314,26 @@ + + + + + + Curved shapes that cannot be represented as curves in IFC are decomposed into flat facets. If this is checked, simple triangulation will be used, otherwise some additional calculation is done to join coplanar facets. + + + Use classic triangulation + + + ifcClassicTriangulation + + + Mod/Arch + + + + + diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 8c44078d42..0ff51df544 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -1175,6 +1175,7 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess fcsolid.scale(0.001) # to meters faces = [] curves = False + shapetype = "brep" for fcface in fcsolid.Faces: for e in fcface.Edges: if not isinstance(e.Curve,Part.Line): @@ -1182,17 +1183,19 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess curves = True break if curves: - #shapetype = "triangulated" - #tris = fcsolid.tessellate(tessellation) - #for tri in tris[1]: - # pts = [ifcfile.createIfcCartesianPoint(tuple(tris[0][i])) for i in tri] - # loop = ifcfile.createIfcPolyLoop(pts) - # bound = ifcfile.createIfcFaceOuterBound(loop,True) - # face = ifcfile.createIfcFace([bound]) - # faces.append(face) - fcsolid = Arch.removeCurves(fcsolid) - - shapetype = "brep" + if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("ifcClassicTriangulation",False): + shapetype = "triangulated" + tris = fcsolid.tessellate(tessellation) + for tri in tris[1]: + pts = [ifcfile.createIfcCartesianPoint(tuple(tris[0][i])) for i in tri] + loop = ifcfile.createIfcPolyLoop(pts) + bound = ifcfile.createIfcFaceOuterBound(loop,True) + face = ifcfile.createIfcFace([bound]) + faces.append(face) + fcsolid = Part.Shape() # empty shape so below code is not executed + else: + fcsolid = Arch.removeCurves(fcsolid) + for fcface in fcsolid.Faces: loops = [] verts = [v.Point for v in Part.Wire(Part.__sortEdges__(fcface.OuterWire.Edges)).Vertexes] @@ -1220,9 +1223,10 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess face = ifcfile.createIfcFace(loops) faces.append(face) - shell = ifcfile.createIfcClosedShell(faces) - shape = ifcfile.createIfcFacetedBrep(shell) - shapes.append(shape) + if faces: + shell = ifcfile.createIfcClosedShell(faces) + shape = ifcfile.createIfcFacetedBrep(shell) + shapes.append(shape) if shapes: