Arch: Tesselation of curved brep faces in IFC export

This commit is contained in:
Yorik van Havre 2014-05-20 17:38:13 -03:00
parent c6d9c3789a
commit e587fe2dba
2 changed files with 27 additions and 13 deletions

View File

@ -669,18 +669,33 @@ def getIfcExtrusionData(obj,scale=1):
return "polyline", getTuples(p,scale), getTuples(v,scale), d return "polyline", getTuples(p,scale), getTuples(v,scale), d
return None return None
def getIfcBrepFacesData(obj,scale=1): def getIfcBrepFacesData(obj,scale=1,tessellation=1):
"""getIfcBrepFacesData(obj,[scale]): returns a list(0) of lists(1) of lists(2) of lists(3), """getIfcBrepFacesData(obj,[scale,tesselation]): returns a list(0) of lists(1) of lists(2) of lists(3),
list(3) being a list of vertices defining a loop, list(2) describing a face from one or list(3) being a list of vertices defining a loop, list(2) describing a face from one or
more loops, list(1) being the whole solid made of several faces, list(0) being the list more loops, list(1) being the whole solid made of several faces, list(0) being the list
of solids inside the object. Scale can indicate a scaling factor""" of solids inside the object. Scale can indicate a scaling factor. Tesselation is the tesselation
factor to apply on curved faces."""
if hasattr(obj,"Shape"): if hasattr(obj,"Shape"):
import Part
if obj.Shape: if obj.Shape:
if not obj.Shape.isNull(): if not obj.Shape.isNull():
if obj.Shape.isValid(): if obj.Shape.isValid():
sols = [] sols = []
for sol in obj.Shape.Solids: for sol in obj.Shape.Solids:
s = [] s = []
curves = False
for face in sol.Faces:
for e in face.Edges:
if not isinstance(e.Curve,Part.Line):
curves = True
if curves:
tris = sol.tessellate(tessellation)
for tri in tris[1]:
f = []
for i in tri:
f.append(getTuples(tris[0][i],scale))
s.append([f])
else:
for face in sol.Faces: for face in sol.Faces:
f = [] f = []
f.append(getTuples(face.OuterWire,scale,normal=face.normalAt(0,0),close=False)) f.append(getTuples(face.OuterWire,scale,normal=face.normalAt(0,0),close=False))

View File

@ -320,12 +320,11 @@ class IfcDocument(object):
def __setattr__(self,key,value): def __setattr__(self,key,value):
if value: if value:
if key == "Owner": if key == "Owner":
print value self._person.set_argument(2,str(value))
self._person.set_argument(2,value)
elif key == "Organization": elif key == "Organization":
self._org.set_argument(1,value) self._org.set_argument(1,str(value))
elif key == "Name": elif key == "Name":
self.Project.set_argument(2,value) self.Project.set_argument(2,str(value))
self.__dict__.__setitem__(key,value) self.__dict__.__setitem__(key,value)
def findByName(self,ifctype,name): def findByName(self,ifctype,name):