Implement Overhang

This commit is contained in:
wood galaxy 2014-12-04 00:44:12 +01:00 committed by Yorik van Havre
parent 1876f36611
commit 341782ec54

View File

@ -35,7 +35,7 @@ __title__="FreeCAD Roof"
__author__ = "Yorik van Havre" __author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org" __url__ = "http://www.freecadweb.org"
def makeRoof2(baseobj=None,facenr=1, angles=[45.,], run = [], idrel = [0,],thickness = [1.,], overhang=[0.,], name=translate("Arch","Roof")): def makeRoof2(baseobj=None,facenr=1, angles=[45.,], run = [], idrel = [0,],thickness = [1.,], overhang=[2.,], name=translate("Arch","Roof")):
'''makeRoof(baseobj,[facenr],[angle],[name]) : Makes a roof based on a '''makeRoof(baseobj,[facenr],[angle],[name]) : Makes a roof based on a
face from an existing object. You can provide the number of the face face from an existing object. You can provide the number of the face
to build the roof on (default = 1), the angle (default=45) and a name (default to build the roof on (default = 1), the angle (default=45) and a name (default
@ -83,7 +83,7 @@ def makeRoof2(baseobj=None,facenr=1, angles=[45.,], run = [], idrel = [0,],thick
lover = len(overhang) lover = len(overhang)
olist = overhang olist = overhang
for i in range(l-lover): for i in range(l-lover):
olist.append(2.) olist.append(overhang[0])
obj.Overhang = olist obj.Overhang = olist
obj.Face = facenr obj.Face = facenr
@ -155,7 +155,7 @@ class _Roof(ArchComponent.Component):
obj.addProperty("App::PropertyFloatList","Runs","Arch", translate("Arch","The horizontal lenght projection of each crawling.")) obj.addProperty("App::PropertyFloatList","Runs","Arch", translate("Arch","The horizontal lenght projection of each crawling."))
obj.addProperty("App::PropertyIntegerList","IdRel","Arch", translate("Arch","The pane Id of relative profil.")) obj.addProperty("App::PropertyIntegerList","IdRel","Arch", translate("Arch","The pane Id of relative profil."))
obj.addProperty("App::PropertyFloatList","Thickness","Arch", translate("Arch","The thickness of the roof pane.")) obj.addProperty("App::PropertyFloatList","Thickness","Arch", translate("Arch","The thickness of the roof pane."))
obj.addProperty("App::PropertyFloatList","Overhang","Arch", translate("Arch","TODO:The Overhang of the roof pane.")) obj.addProperty("App::PropertyFloatList","Overhang","Arch", translate("Arch","The Overhang of the roof pane."))
obj.addProperty("App::PropertyFloatList","Heights","Arch", translate("Arch","The calculated height of the roof pane list.")) obj.addProperty("App::PropertyFloatList","Heights","Arch", translate("Arch","The calculated height of the roof pane list."))
obj.addProperty("App::PropertyInteger","Face","Base",translate("Arch","The face number of the base object used to build this roof")) obj.addProperty("App::PropertyInteger","Face","Base",translate("Arch","The face number of the base object used to build this roof"))
self.Type = "Roof" self.Type = "Roof"
@ -166,26 +166,26 @@ class _Roof(ArchComponent.Component):
return htRel return htRel
def calcRun(self, id): def calcRun(self, id):
lgRel = self.profilsDico[id]["height"]/(math.tan(math.radians(self.profilsDico[id]["angle"]))) runRel = self.profilsDico[id]["height"]/(math.tan(math.radians(self.profilsDico[id]["angle"])))
return lgRel return runRel
def calcAngle(self, id): def calcAngle(self, id):
a = math.degrees(math.atan(self.profilsDico[id]["height"]/self.profilsDico[id]["run"])) a = math.degrees(math.atan(self.profilsDico[id]["height"]/self.profilsDico[id]["run"]))
return a return a
def getPerpendicular(self, vec, angleEdge, l): def getPerpendicular(self, vec, rotEdge, l):
norm = FreeCAD.Vector(0,0,1) norm = FreeCAD.Vector(0,0,1)
perpendicular = vec.cross(norm) perpendicular = vec.cross(norm)
if -180. <= angleEdge < -90.: if -180. <= rotEdge < -90.:
perpendicular[0] = abs(perpendicular[0])*-1 perpendicular[0] = abs(perpendicular[0])*-1
perpendicular[1] = abs(perpendicular[1])*-1 perpendicular[1] = abs(perpendicular[1])*-1
elif -90. <= angleEdge <= 0.: elif -90. <= rotEdge <= 0.:
perpendicular[0] = abs(perpendicular[0])*-1 perpendicular[0] = abs(perpendicular[0])*-1
perpendicular[1] = abs(perpendicular[1]) perpendicular[1] = abs(perpendicular[1])
elif 0. < angleEdge <= 90.: elif 0. < rotEdge <= 90.:
perpendicular[0] = abs(perpendicular[0]) perpendicular[0] = abs(perpendicular[0])
perpendicular[1] = abs(perpendicular[1]) perpendicular[1] = abs(perpendicular[1])
elif 90. < angleEdge <= 180.: elif 90. < rotEdge <= 180.:
perpendicular[0] = abs(perpendicular[0]) perpendicular[0] = abs(perpendicular[0])
perpendicular[1] = abs(perpendicular[1])*-1 perpendicular[1] = abs(perpendicular[1])*-1
else: else:
@ -214,13 +214,13 @@ class _Roof(ArchComponent.Component):
def calcMissingData(self, i): def calcMissingData(self, i):
a = self.profilsDico[i]["angle"] a = self.profilsDico[i]["angle"]
lg = self.profilsDico[i]["run"] run = self.profilsDico[i]["run"]
rel = self.profilsDico[i]["idrel"] rel = self.profilsDico[i]["idrel"]
if a == 0.0 and lg == 0.0 : if a == 0.0 and run == 0.0 :
self.profilsDico[i]["run"] = self.profilsDico[rel]["run"] self.profilsDico[i]["run"] = self.profilsDico[rel]["run"]
self.profilsDico[i]["angle"] = self.profilsDico[rel]["angle"] self.profilsDico[i]["angle"] = self.profilsDico[rel]["angle"]
self.profilsDico[i]["height"] = self.calcHeight(i) self.profilsDico[i]["height"] = self.calcHeight(i)
elif lg == 0: elif run == 0:
if a == 90. : if a == 90. :
htRel = self.calcHeight(rel) htRel = self.calcHeight(rel)
self.profilsDico[i]["height"] = htRel self.profilsDico[i]["height"] = htRel
@ -258,6 +258,7 @@ class _Roof(ArchComponent.Component):
heights = [] heights = []
edges = DraftGeomUtils.sortEdges(w.Edges) edges = DraftGeomUtils.sortEdges(w.Edges)
l = len(edges) l = len(edges)
print("le contour contient "+str(l)+" aretes")
for i in range(l): for i in range(l):
self.makeRoofProfilsDic(i, obj.Angles[i], obj.Runs[i], obj.IdRel[i], obj.Overhang[i], obj.Thickness[i]) self.makeRoofProfilsDic(i, obj.Angles[i], obj.Runs[i], obj.IdRel[i], obj.Overhang[i], obj.Thickness[i])
for i in range(l): for i in range(l):
@ -265,23 +266,10 @@ class _Roof(ArchComponent.Component):
for p in self.profilsDico: for p in self.profilsDico:
heights.append(p["height"]) heights.append(p["height"])
obj.Heights = heights obj.Heights = heights
"""
for p in self.profilsDico:
print p
print obj.Angles
print obj.Runs
print obj.IdRel
print obj.Overhang
print obj.Thickness
print obj.Heights
"""
for i in range(l): for i in range(l):
edgesForward = edges[:] edgesForward = edges[:]
edgesForward.append(edges[0]) edgesForward.append(edges[0])
edgesBack = edges[:] ptsPaneProject=[]
edgesBack.insert(0,edges[-1])
points=[]
profil0 =self.profilsDico[i-1] profil0 =self.profilsDico[i-1]
profil1 =self.profilsDico[i] profil1 =self.profilsDico[i]
if i == l-1: if i == l-1:
@ -291,67 +279,140 @@ class _Roof(ArchComponent.Component):
vec0 = edges[i-1].Vertexes[-1].Point.sub(edges[i-1].Vertexes[0].Point) vec0 = edges[i-1].Vertexes[-1].Point.sub(edges[i-1].Vertexes[0].Point)
vec1 = edges[i].Vertexes[-1].Point.sub(edges[i].Vertexes[0].Point) vec1 = edges[i].Vertexes[-1].Point.sub(edges[i].Vertexes[0].Point)
vec2 = edgesForward[i+1].Vertexes[-1].Point.sub(edgesForward[i+1].Vertexes[0].Point) vec2 = edgesForward[i+1].Vertexes[-1].Point.sub(edgesForward[i+1].Vertexes[0].Point)
angleEdge0 = math.degrees(DraftVecUtils.angle(vec0)) rotEdge0 = math.degrees(DraftVecUtils.angle(vec0))
angleEdge1 = math.degrees(DraftVecUtils.angle(vec1)) rotEdge1 = math.degrees(DraftVecUtils.angle(vec1))
angleEdge2 = math.degrees(DraftVecUtils.angle(vec2)) rotEdge2 = math.degrees(DraftVecUtils.angle(vec2))
points=[edges[i].Vertexes[0].Point,edges[i].Vertexes[-1].Point] edgeEave0 = DraftGeomUtils.offset(edges[i-1],self.getPerpendicular(vec0,rotEdge0,profil0["overhang"]).negative())
edgeEave1 = DraftGeomUtils.offset(edges[i],self.getPerpendicular(vec1,rotEdge1,profil1["overhang"]).negative())
edgeEave2 = DraftGeomUtils.offset(edgesForward[i+1],self.getPerpendicular(vec2,rotEdge2,profil2["overhang"]).negative())
pt0Eave1 = DraftGeomUtils.findIntersection(edgeEave0,edgeEave1,infinite1=True,infinite2=True,)
pt1Eave1 = DraftGeomUtils.findIntersection(edgeEave1,edgeEave2,infinite1=True,infinite2=True,)
edgeEave1 = DraftGeomUtils.edg(FreeCAD.Vector(pt0Eave1[0]),FreeCAD.Vector(pt1Eave1[0]))
edgeRidge0 = DraftGeomUtils.offset(edges[i-1],self.getPerpendicular(vec0,rotEdge0,profil0["run"]))
edgeRidge1 = DraftGeomUtils.offset(edges[i],self.getPerpendicular(vec1,rotEdge1,profil1["run"]))
edgeRidge2 = DraftGeomUtils.offset(edgesForward[i+1],self.getPerpendicular(vec2,rotEdge2,profil2["run"]))
midpoint = DraftGeomUtils.findMidpoint(edges[i])
pt0Edge1 = edges[i].Vertexes[0].Point
pt1Edge1 = edges[i].Vertexes[-1].Point
print("Analyse profil " + str(i))
print "edge1",edges[i].Vertexes[0].Point,edges[i].Vertexes[-1].Point
print "edgeEave1",edgeEave1.Vertexes[0].Point,edgeEave1.Vertexes[-1].Point
print "edgeRidge1",edgeRidge1.Vertexes[0].Point,edgeRidge1.Vertexes[-1].Point
if profil1["angle"] != 90.: if profil1["angle"] != 90.:
lg = profil1["run"]
faitage = DraftGeomUtils.offset(edges[i],self.getPerpendicular(vec1,angleEdge1,lg))
midpoint = DraftGeomUtils.findMidpoint(edges[i])
if profil2["angle"] == 90. : if profil2["angle"] == 90. :
edge = DraftGeomUtils.offset(edgesForward[i+1],FreeCAD.Vector(0,0,0)) print("situation a droite : pignon")
point = DraftGeomUtils.findIntersection(faitage,edge,infinite1=True,infinite2=True,) ptsPaneProject.append(FreeCAD.Vector(pt1Eave1[0]))
points.append(FreeCAD.Vector(point[0])) point = DraftGeomUtils.findIntersection(edgeRidge1,edgeEave2,infinite1=True,infinite2=True,)
elif profil2["height"] == profil1["height"]: ptsPaneProject.append(FreeCAD.Vector(point[0]))
edge = DraftGeomUtils.offset(edgesForward[i+1],self.getPerpendicular(vec2,angleEdge2,profil2["run"])) elif profil1["height"] == profil2["height"] :
point = DraftGeomUtils.findIntersection(faitage,edge,infinite1=True,infinite2=True,) print("situation a droite : ht1 = ht2")
points.append(FreeCAD.Vector(point[0])) ptInterRidges = DraftGeomUtils.findIntersection(edgeRidge1,edgeRidge2,infinite1=True,infinite2=True,)
edgeHip = DraftGeomUtils.edg(FreeCAD.Vector(ptInterRidges[0]),pt1Edge1)
ptInterHipEave1 = DraftGeomUtils.findIntersection(edgeHip,edgeEave1,infinite1=True,infinite2=False,)
if ptInterHipEave1:
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave1[0]))
else:
ptInterHipEave2 = DraftGeomUtils.findIntersection(edgeHip,edgeEave2,infinite1=True,infinite2=True,)
ptsPaneProject.append(FreeCAD.Vector(pt1Eave1[0]))
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave2[0]))
ptsPaneProject.append(FreeCAD.Vector(ptInterRidges[0]))
elif profil1["height"] > profil2["height"]: elif profil1["height"] > profil2["height"]:
edge = DraftGeomUtils.offset(edgesForward[i+1],self.getPerpendicular(vec2,angleEdge2,profil2["run"])) print("situation a droite : ht1 > ht2")
dec = profil2["height"]/math.tan(math.radians(profil1["angle"])) dec = profil2["height"]/math.tan(math.radians(profil1["angle"]))
edge1 = DraftGeomUtils.offset(edges[i],self.getPerpendicular(vec1,angleEdge1,dec)) edgeRidge2OnPane = DraftGeomUtils.offset(edges[i],self.getPerpendicular(vec1,rotEdge1,dec))
pointR = DraftGeomUtils.findIntersection(edge,edge1,infinite1=True,infinite2=True,) ptInter1 = DraftGeomUtils.findIntersection(edgeRidge2,edgeRidge2OnPane,infinite1=True,infinite2=True,)
points.append(FreeCAD.Vector(pointR[0])) edgeHip = DraftGeomUtils.edg(FreeCAD.Vector(ptInter1[0]),pt1Edge1)
point = DraftGeomUtils.findIntersection(faitage,edge,infinite1=True,infinite2=True,) ptInterHipEave1 = DraftGeomUtils.findIntersection(edgeHip,edgeEave1,infinite1=True,infinite2=False,)
points.append(FreeCAD.Vector(point[0])) if ptInterHipEave1:
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave1[0]))
else:
ptInterHipEave2 = DraftGeomUtils.findIntersection(edgeHip,edgeEave2,infinite1=True,infinite2=True,)
ptsPaneProject.append(FreeCAD.Vector(pt1Eave1[0]))
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave2[0]))
ptsPaneProject.append(FreeCAD.Vector(ptInter1[0]))
ptInter2 = edgeHip.Vertexes[0].Point
vecInterRidges = DraftGeomUtils.findPerpendicular(ptInter2, [edgeRidge1.Edges[0],], force=0)
ptInterRidges = ptInter2.add(vecInterRidges[0])
ptsPaneProject.append(FreeCAD.Vector(ptInterRidges))
elif profil1["height"] < profil2["height"]: elif profil1["height"] < profil2["height"]:
print("situation a droite : ht1 < ht2")
dec = profil1["height"]/math.tan(math.radians(profil2["angle"])) dec = profil1["height"]/math.tan(math.radians(profil2["angle"]))
edge1 = DraftGeomUtils.offset(edgesForward[i+1],self.getPerpendicular(vec2,angleEdge2,dec)) edgeRidge2OnPane = DraftGeomUtils.offset(edgesForward[i+1],self.getPerpendicular(vec2,rotEdge2,dec))
point = DraftGeomUtils.findIntersection(faitage,edge1,infinite1=True,infinite2=True,) ptInter1 = DraftGeomUtils.findIntersection(edgeRidge1,edgeRidge2OnPane,infinite1=True,infinite2=True,)
points.append(FreeCAD.Vector(point[0])) edgeHip = DraftGeomUtils.edg(FreeCAD.Vector(ptInter1[0]),pt1Edge1)
ptInterHipEave1 = DraftGeomUtils.findIntersection(edgeHip,edgeEave1,infinite1=True,infinite2=False,)
if ptInterHipEave1:
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave1[0]))
else:
ptInterHipEave2 = DraftGeomUtils.findIntersection(edgeHip,edgeEave2,infinite1=True,infinite2=True,)
ptsPaneProject.append(FreeCAD.Vector(pt1Eave1[0]))
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave2[0]))
ptsPaneProject.append(FreeCAD.Vector(ptInter1[0]))
ptInterRidges = DraftGeomUtils.findIntersection(edgeRidge1,edgeRidge2,infinite1=True,infinite2=True,)
ptsPaneProject.append(FreeCAD.Vector(ptInterRidges[0]))
else: else:
print("Cas de figure non pris en charge") print("Cas de figure non pris en charge")
if profil0["angle"] == 90. : if profil0["angle"] == 90. :
edge = edgesBack[i] print("situation a gauche : pignon")
point = DraftGeomUtils.findIntersection(faitage,edge,infinite1=True,infinite2=True,) point = DraftGeomUtils.findIntersection(edgeRidge1,edgeEave0,infinite1=True,infinite2=True,)
points.append(FreeCAD.Vector(point[0])) ptsPaneProject.append(FreeCAD.Vector(point[0]))
ptsPaneProject.append(FreeCAD.Vector(pt0Eave1[0]))
elif profil0["height"] == profil1["height"]: elif profil0["height"] == profil1["height"]:
edge = DraftGeomUtils.offset(edgesBack[i],self.getPerpendicular(vec0,angleEdge0,profil0["run"])) print("situation a gauche : ht1 = ht0")
point = DraftGeomUtils.findIntersection(faitage,edge,infinite1=True,infinite2=True,) edgeRidge0 = DraftGeomUtils.offset(edges[i-1],self.getPerpendicular(vec0,rotEdge0,profil0["run"]))
points.append(FreeCAD.Vector(point[0])) ptInterRidges = DraftGeomUtils.findIntersection(edgeRidge1,edgeRidge0,infinite1=True,infinite2=True,)
ptsPaneProject.append(FreeCAD.Vector(ptInterRidges[0]))
edgeHip = DraftGeomUtils.edg(FreeCAD.Vector(ptInterRidges[0]),pt0Edge1)
ptInterHipEave3 = DraftGeomUtils.findIntersection(edgeHip,edgeEave1,infinite1=True,infinite2=False,)
if ptInterHipEave3:
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave3[0]))
else:
ptInterHipEave4 = DraftGeomUtils.findIntersection(edgeHip,edgeEave0,infinite1=True,infinite2=True,)
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave4[0]))
ptsPaneProject.append(FreeCAD.Vector(pt0Eave1[0]))
elif profil1["height"] > profil0["height"]: elif profil1["height"] > profil0["height"]:
print("situation a gauche : ht1 > ht0")
dec = profil0["height"]/math.tan(math.radians(profil1["angle"])) dec = profil0["height"]/math.tan(math.radians(profil1["angle"]))
edge1 = DraftGeomUtils.offset(edges[i],self.getPerpendicular(vec1,angleEdge1,dec)) edgeRidge0OnPane = DraftGeomUtils.offset(edges[i],self.getPerpendicular(vec1,rotEdge1,dec))
edge = DraftGeomUtils.offset(edges[i-1],self.getPerpendicular(vec0,angleEdge0,profil0["run"])) ptInter1 = DraftGeomUtils.findIntersection(edgeRidge0OnPane,edgeRidge0,infinite1=True,infinite2=True,)
point = DraftGeomUtils.findIntersection(edge,faitage,infinite1=True,infinite2=True,) edgeHip = DraftGeomUtils.edg(FreeCAD.Vector(ptInter1[0]),pt0Edge1)
points.append(FreeCAD.Vector(point[0])) ptInter2 = edgeHip.Vertexes[0].Point
point = DraftGeomUtils.findIntersection(edge1,edge,infinite1=True,infinite2=True,) vecInterRidges = DraftGeomUtils.findPerpendicular(ptInter2, [edgeRidge1.Edges[0],], force=0)
points.append(FreeCAD.Vector(point[0])) ptInterRidges = ptInter2.add(vecInterRidges[0])
ptsPaneProject.append(FreeCAD.Vector(ptInterRidges))
ptsPaneProject.append(FreeCAD.Vector(ptInter1[0]))
ptInterHipEave3 = DraftGeomUtils.findIntersection(edgeHip,edgeEave1,infinite1=True,infinite2=False,)
if ptInterHipEave3:
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave3[0]))
else:
ptInterHipEave4 = DraftGeomUtils.findIntersection(edgeHip,edgeEave0,infinite1=True,infinite2=True,)
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave4[0]))
ptsPaneProject.append(FreeCAD.Vector(pt0Eave1[0]))
elif profil1["height"] < profil0["height"]: elif profil1["height"] < profil0["height"]:
print("situation a gauche : ht1 < ht0")
dec = profil1["height"]/math.tan(math.radians(profil0["angle"])) dec = profil1["height"]/math.tan(math.radians(profil0["angle"]))
edge1 = DraftGeomUtils.offset(edges[i-1],self.getPerpendicular(vec0,angleEdge0,dec)) edgeRidge0OnPane = DraftGeomUtils.offset(edges[i-1],self.getPerpendicular(vec0,rotEdge0,dec))
point = DraftGeomUtils.findIntersection(faitage,edge1,infinite1=True,infinite2=True,) ptInterRidges = DraftGeomUtils.findIntersection(edgeRidge0OnPane,edgeRidge1,infinite1=True,infinite2=True,)
points.append(FreeCAD.Vector(point[0])) ptsPaneProject.append(FreeCAD.Vector(ptInterRidges[0]))
edgeHip = DraftGeomUtils.edg(FreeCAD.Vector(ptInterRidges[0]),pt0Edge1)
ptInterHipEave3 = DraftGeomUtils.findIntersection(edgeHip,edgeEave1,infinite1=True,infinite2=False,)
if ptInterHipEave3:
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave3[0]))
else:
ptInterHipEave4 = DraftGeomUtils.findIntersection(edgeHip,edgeEave0,infinite1=True,infinite2=True,)
ptsPaneProject.append(FreeCAD.Vector(ptInterHipEave4[0]))
ptsPaneProject.append(FreeCAD.Vector(pt0Eave1[0]))
else: else:
print("Cas de figure non pris en charge") print("Cas de figure non pris en charge")
points = DraftVecUtils.removeDoubles(points) ptsPaneProject = DraftVecUtils.removeDoubles(ptsPaneProject)
self.profilsDico[i]["points"] = points print("ptsPaneProject",ptsPaneProject)
lp = len(points) print("Fin Analyse profil " + str(i))
points.append(points[0]) self.profilsDico[i]["points"] = ptsPaneProject
lp = len(ptsPaneProject)
ptsPaneProject.append(ptsPaneProject[0])
edgesWire = [] edgesWire = []
for i in range(lp): for i in range(lp):
edge = Part.makeLine(points[i],points[i+1]) edge = Part.makeLine(ptsPaneProject[i],ptsPaneProject[i+1])
edgesWire.append(edge) edgesWire.append(edge)
wire = Part.Wire(edgesWire) wire = Part.Wire(edgesWire)
d = wire.BoundBox.DiagonalLength d = wire.BoundBox.DiagonalLength
@ -359,18 +420,19 @@ class _Roof(ArchComponent.Component):
overhangV = profil1["overhang"]*math.tan(math.radians(profil1["angle"])) overhangV = profil1["overhang"]*math.tan(math.radians(profil1["angle"]))
if wire.isClosed(): if wire.isClosed():
f = Part.Face(wire) f = Part.Face(wire)
f = f.extrude(FreeCAD.Vector(0,0,profil1["height"]+2*thicknessV)) f = f.extrude(FreeCAD.Vector(0,0,profil1["height"]+2*thicknessV+2*overhangV))
points=[FreeCAD.Vector(-profil1["overhang"],-overhangV,0.0),FreeCAD.Vector(profil1["run"],profil1["height"],0.0),FreeCAD.Vector(profil1["run"],profil1["height"]+thicknessV,0.0),FreeCAD.Vector(-profil1["overhang"],-overhangV+thicknessV,0.0)] f.translate(FreeCAD.Vector(0.0,0.0,-2*overhangV))
lp = len(points) ptsPaneProfil=[FreeCAD.Vector(-profil1["overhang"],-overhangV,0.0),FreeCAD.Vector(profil1["run"],profil1["height"],0.0),FreeCAD.Vector(profil1["run"],profil1["height"]+thicknessV,0.0),FreeCAD.Vector(-profil1["overhang"],-overhangV+thicknessV,0.0)]
points.append(points[0]) lp = len(ptsPaneProfil)
ptsPaneProfil.append(ptsPaneProfil[0])
edgesWire = [] edgesWire = []
for i in range(lp): for i in range(lp):
edge = Part.makeLine(points[i],points[i+1]) edge = Part.makeLine(ptsPaneProfil[i],ptsPaneProfil[i+1])
edgesWire.append(edge) edgesWire.append(edge)
profilCouv = Part.Wire(edgesWire) profilCouv = Part.Wire(edgesWire)
profilCouv.translate(midpoint) profilCouv.translate(midpoint)
profilCouv.rotate(midpoint,FreeCAD.Vector(0,0,1), 90. + angleEdge1 * -1) profilCouv.rotate(midpoint,FreeCAD.Vector(0,0,1), 90. + rotEdge1 * -1)
perp = self.getPerpendicular(vec1,angleEdge1,profil1["run"]) perp = self.getPerpendicular(vec1,rotEdge1,profil1["run"])
profilCouv.rotate(midpoint,perp,90.) profilCouv.rotate(midpoint,perp,90.)
vecT = vec1.normalize() vecT = vec1.normalize()
vecT.multiply(d) vecT.multiply(d)
@ -385,14 +447,14 @@ class _Roof(ArchComponent.Component):
else: else:
#TODO PIGNON #TODO PIGNON
pass pass
base = shps.pop() #base = shps.pop()
for s in shps: base = Part.makeCompound(shps)
base = base.fuse(s) #for s in shps:
base = base.removeSplitter() # base = base.fuse(s)
#base = base.removeSplitter()
if not base.isNull(): if not base.isNull():
if not DraftGeomUtils.isNull(pl): if not DraftGeomUtils.isNull(pl):
base.Placement = pl base.Placement = pl
base = self.processSubShapes(obj,base) base = self.processSubShapes(obj,base)
if base: if base:
if not base.isNull(): if not base.isNull():
@ -504,10 +566,7 @@ class _RoofTaskPanel:
a.append(float(it.text(1))) a.append(float(it.text(1)))
run.append(float(it.text(2))) run.append(float(it.text(2)))
rel.append(int(it.text(3))) rel.append(int(it.text(3)))
if float(it.text(4)) == 0.: thick.append(float(it.text(4)))
thick.append(1.)
else:
thick.append(float(it.text(4)))
over.append(float(it.text(5))) over.append(float(it.text(5)))
self.obj.Runs = run self.obj.Runs = run
self.obj.Angles = a self.obj.Angles = a
@ -525,7 +584,7 @@ class _RoofTaskPanel:
def retranslateUi(self, TaskPanel): def retranslateUi(self, TaskPanel):
TaskPanel.setWindowTitle(QtGui.QApplication.translate("Arch", "Roof", None, QtGui.QApplication.UnicodeUTF8)) TaskPanel.setWindowTitle(QtGui.QApplication.translate("Arch", "Roof", None, QtGui.QApplication.UnicodeUTF8))
self.title.setText(QtGui.QApplication.translate("Arch", "Parameters of the profiles of the roof:\n* Angle : slope in degrees compared to the horizontal one.\n* Run : outdistance between the wall and the ridge sheathing.\n* Thickness : thickness of the side of roof.\n* Overhang : outdistance between the sewer and the wall.\n* Height : height of the ridge sheathing (calculated automatically)\n* IdRel : Relative Id for calculations automatic.\n---\nIf Angle = 0 and Run = the 0 then profile is identical to the relative profile.\nIf Angle = the 0 then angle is calculated so that the height is the same one as the relative profile.\nIf Run = 0 then Run is calculated so that the height is the same one as the relative profile.", None, QtGui.QApplication.UnicodeUTF8)) self.title.setText(QtGui.QApplication.translate("Arch", "Parameters of the profiles of the roof:\n* Angle : slope in degrees compared to the horizontal one.\n* Run : outdistance between the wall and the ridge sheathing.\n* Thickness : thickness of the side of roof.\n* Overhang : outdistance between the sewer and the wall.\n* Height : height of the ridge sheathing (calculated automatically)\n* IdRel : Relative Id for calculations automatic.\n---\nIf Angle = 0 and Run = 0 then profile is identical to the relative profile.\nIf Angle = 0 then angle is calculated so that the height is the same one as the relative profile.\nIf Run = 0 then Run is calculated so that the height is the same one as the relative profile.", None, QtGui.QApplication.UnicodeUTF8))
self.tree.setHeaderLabels([QtGui.QApplication.translate("Arch", "Id", None, QtGui.QApplication.UnicodeUTF8), self.tree.setHeaderLabels([QtGui.QApplication.translate("Arch", "Id", None, QtGui.QApplication.UnicodeUTF8),
QtGui.QApplication.translate("Arch", "Angle", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Angle", None, QtGui.QApplication.UnicodeUTF8),
QtGui.QApplication.translate("Arch", "Run", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Run", None, QtGui.QApplication.UnicodeUTF8),