Arch: IFC bugfix + added pref option to use DAE triangulation options

This commit is contained in:
Yorik van Havre 2015-12-18 10:39:40 -02:00
parent cfba4a3d5c
commit 45292eb9ee
3 changed files with 46 additions and 13 deletions

View File

@ -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)

View File

@ -319,13 +319,33 @@
<item>
<widget class="Gui::PrefCheckBox" name="checkBox_4">
<property name="toolTip">
<string>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.</string>
<string>Use triangulation options set in the DAE options page</string>
</property>
<property name="text">
<string>Use classic triangulation</string>
<string>Use DAE triangulation options</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ifcClassicTriangulation</cstring>
<cstring>ifcUseDaeOptions</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="Gui::PrefCheckBox" name="checkBox_5">
<property name="toolTip">
<string>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.</string>
</property>
<property name="text">
<string>Join coplanar facets when triangulating</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ifcJoinCoplanarFacets</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>

View File

@ -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 = []