From 45292eb9ee5705c7bf433bb2c59878a51ec365b7 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 18 Dec 2015 10:39:40 -0200 Subject: [PATCH] Arch: IFC bugfix + added pref option to use DAE triangulation options --- src/Mod/Arch/ArchCommands.py | 12 ++++++--- src/Mod/Arch/Resources/ui/preferences-ifc.ui | 26 +++++++++++++++++--- src/Mod/Arch/importIFC.py | 21 +++++++++++----- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index 0e15fc6ac..cd3f2bddc 100644 --- a/src/Mod/Arch/ArchCommands.py +++ b/src/Mod/Arch/ArchCommands.py @@ -498,11 +498,15 @@ def meshToShape(obj,mark=True,fast=True,tol=0.001,flat=False,cut=True): return newobj return None -def removeCurves(shape,tolerance=5): - '''removeCurves(shape,tolerance=5): replaces curved faces in a shape - with faceted segments''' +def removeCurves(shape,dae=False,tolerance=5): + '''removeCurves(shape,dae,tolerance=5): replaces curved faces in a shape + with faceted segments. If dae is True, DAE triangulation options are used''' import Mesh - t = shape.cleaned().tessellate(tolerance) + if dae: + import importDAE + t = importDAE.triangulate(shape.cleaned()) + else: + t = shape.cleaned().tessellate(tolerance) m = Mesh.Mesh(t) return getShapeFromMesh(m) diff --git a/src/Mod/Arch/Resources/ui/preferences-ifc.ui b/src/Mod/Arch/Resources/ui/preferences-ifc.ui index 2f88dbfc1..ab7f177d0 100644 --- a/src/Mod/Arch/Resources/ui/preferences-ifc.ui +++ b/src/Mod/Arch/Resources/ui/preferences-ifc.ui @@ -319,13 +319,33 @@ - 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 triangulation options set in the DAE options page - Use classic triangulation + Use DAE triangulation options - ifcClassicTriangulation + ifcUseDaeOptions + + + Mod/Arch + + + + + + + + + + + Curved shapes that cannot be represented as curves in IFC are decomposed into flat facets. If this is checked, some additional calculation is done to join coplanar facets. + + + Join coplanar facets when triangulating + + + ifcJoinCoplanarFacets Mod/Arch diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 3383ae78a..ddaea9b58 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -832,8 +832,8 @@ def export(exportList,filename): if b: clones.setdefault(b.Name,[]).append(o.Name) - print "clones table: ",clones - print objectslist + #print "clones table: ",clones + #print objectslist # products for obj in objectslist: @@ -1170,7 +1170,7 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess dataset = fcshape.Solids else: dataset = fcshape.Shells - print "Warning! object contains no solids" + if DEBUG: print "Warning! object contains no solids" for fcsolid in dataset: fcsolid.scale(0.001) # to meters faces = [] @@ -1183,9 +1183,15 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess curves = True break if curves: - if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("ifcClassicTriangulation",False): + joinfacets = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("ifcJoinCoplanarFacets",False) + usedae = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("ifcUseDaeOptions",False) + if not joinfacets: shapetype = "triangulated" - tris = fcsolid.tessellate(tessellation) + if usedae: + import importDAE + tris = importDAE.triangulate(fcsolid) + else: + tris = fcsolid.tessellate(tessellation) for tri in tris[1]: pts = [ifcfile.createIfcCartesianPoint(tuple(tris[0][i])) for i in tri] loop = ifcfile.createIfcPolyLoop(pts) @@ -1194,7 +1200,10 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess faces.append(face) fcsolid = Part.Shape() # empty shape so below code is not executed else: - fcsolid = Arch.removeCurves(fcsolid) + fcsolid = Arch.removeCurves(fcsolid,dae=usedae) + if not fcsolid: + if DEBUG: print "Error: Unable to triangulate shape" + fcsolid = Part.Shape() for fcface in fcsolid.Faces: loops = []