diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index 0e15fc6acd..cd3f2bddcb 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 2f88dbfc17..ab7f177d0b 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 3383ae78a9..ddaea9b589 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 = []