Better algorithm for creating pitched roof (probably)?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- ebrahim raeyat
- Posts: 619
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Better algorithm for creating pitched roof (probably)?
I worked a little with FreeCAD Roof command, but it has some unexpected behavior in some roofs. I searched a little about another algorithms and found that there is a straight skeleton algorithm and also a library with python for this goal. I hack it to draw some complicate roofs and I think it can recognize all pieces of roof correctly,
the input is polygon point coordinates and the output is original shape coordinate, edge points in two separate parameters: sinks and source, and heights. It assumes 45 degree for angle. This is some output:
Then to create 3D we can use two options:
1- using the height of skeleton library that give us, but with some hack, but it needs some modification. Or it is better to use generalfuse command to unify some edges and then apply height, I examined it, but not succeed:
2- First use slice command in Part WB to identify 2D pieces and then project this pieces on the plate with appropriate slop:
Although this way is only for unique angle for all pieces of roof. Thanks
the input is polygon point coordinates and the output is original shape coordinate, edge points in two separate parameters: sinks and source, and heights. It assumes 45 degree for angle. This is some output:
Then to create 3D we can use two options:
1- using the height of skeleton library that give us, but with some hack, but it needs some modification. Or it is better to use generalfuse command to unify some edges and then apply height, I examined it, but not succeed:
2- First use slice command in Part WB to identify 2D pieces and then project this pieces on the plate with appropriate slop:
Although this way is only for unique angle for all pieces of roof. Thanks
Re: Better algorithm for creating pitched roof (probably)?
The Arch_Roof algorithm has some obvious limitations. I have quite recently improved the code, fixing several bugs and making the code more robust. My PR was merged on October 12 2020. So please check if you are using that version.ebrahim raeyat wrote: ↑Wed Oct 21, 2020 10:03 am I worked a little with FreeCAD Roof command, but it has some unexpected behavior in some roofs.
https://github.com/FreeCAD/FreeCAD/pull ... r498712220
- ebrahim raeyat
- Posts: 619
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: Better algorithm for creating pitched roof (probably)?
Thanks @Roy_043. I had been pulled the last version, but after reading wiki roof command and source code, I can't figure out how can I draw pitched roof for complex (a little!) shapes automatically. For example for above sketch. But I searched and find this library for this purpose:Roy_043 wrote: ↑Wed Oct 21, 2020 12:54 pmThe Arch_Roof algorithm has some obvious limitations. I have quite recently improved the code, fixing several bugs and making the code more robust. My PR was merged on October 12 2020. So please check if you are using that version.ebrahim raeyat wrote: ↑Wed Oct 21, 2020 10:03 am I worked a little with FreeCAD Roof command, but it has some unexpected behavior in some roofs.
https://github.com/FreeCAD/FreeCAD/pull ... r498712220
https://github.com/Botffy/polyskel
- ebrahim raeyat
- Posts: 619
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: Better algorithm for creating pitched roof (probably)?
Ah, my FreeCAD version:
Code: Select all
OS: Ubuntu 20.04.1 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22783 (Git)
Build type: Unknown
Branch: master
Hash: 16ec7c3612f7b8b28292b107958db110dfef82d0
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.3.0
Locale: English/United States (en_US)
Re: Better algorithm for creating pitched roof (probably)?
As explained in one of my comments in the PR, one of the limitations of the current algorithm is that only direct neighbors are checked when determining the outline of a roof segment. On the other hand the code does have certain features: variable overhangs and runs, and variable angles.
Does the code found at https://github.com/Botffy/polyskel support variable angles?
Does the code found at https://github.com/Botffy/polyskel support variable angles?
- ebrahim raeyat
- Posts: 619
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: Better algorithm for creating pitched roof (probably)?
Roy_043 wrote: ↑Thu Oct 22, 2020 3:16 pm As explained in one of my comments in the PR, one of the limitations of the current algorithm is that only direct neighbors are checked when determining the outline of a roof segment. On the other hand the code does have certain features: variable overhangs and runs, and variable angles.
Does the code found at https://github.com/Botffy/polyskel support variable angles?
No, it does not support variable angles as I know, but there is a c ++ library that support variable angles with weighted parameter, this is paper that explain the algorithm:
https://geder.at/research/2020/2020%20- ... iences.pdf
and these are source codes !:
https://github.com/cgalab/monos
https://github.com/cgalab/surfer2
Re: Better algorithm for creating pitched roof (probably)?
Thanks for those links. I'll try to look at them, but this stuff may prove to be over my head.
Keep in mind that the current algorithm supports gables, and roof segments with different angles based on consecutive parallel edges. Also the roof segments need not connect at the top. In other words: there does not have to be an enclosed space under the roof.
But the algorithms you refer to may provide inspiration for Arch_Roof and perhaps also for Arch_Space (which also works by intersecting planes).
Interestingly the ACIS geometric kernel, used by AutoCAD, BricsCAD etc., can create the complex roofs in your first post with a single extrude operation.
Keep in mind that the current algorithm supports gables, and roof segments with different angles based on consecutive parallel edges. Also the roof segments need not connect at the top. In other words: there does not have to be an enclosed space under the roof.
But the algorithms you refer to may provide inspiration for Arch_Roof and perhaps also for Arch_Space (which also works by intersecting planes).
Interestingly the ACIS geometric kernel, used by AutoCAD, BricsCAD etc., can create the complex roofs in your first post with a single extrude operation.
- Attachments
-
- Complex_Roof_ACIS_Extrude.png (76.61 KiB) Viewed 4118 times
- ebrahim raeyat
- Posts: 619
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: Better algorithm for creating pitched roof (probably)?
Thanks for your quick replies. I know the Arch-roof command has more options for drawing, but my goal for announcing this is if we could add a command like you mentioned that exist in BricsCAD etc.Roy_043 wrote: ↑Fri Oct 23, 2020 7:36 am Thanks for those links. I'll try to look at them, but this stuff may prove to be over my head.
Keep in mind that the current algorithm supports gables, and roof segments with different angles based on consecutive parallel edges. Also the roof segments need not connect at the top. In other words: there does not have to be an enclosed space under the roof.
But the algorithms you refer to may provide inspiration for Arch_Roof and perhaps also for Arch_Space (which also works by intersecting planes).
Interestingly the ACIS geometric kernel, used by AutoCAD, BricsCAD etc., can create the complex roofs in your first post with a single extrude operation.
But until that, I have only one question:
how can I find the perpendicular distance from a point to line in FreeCAD. I searched a lot and found that exist a Part measure tools, but it gets the shortest distance and some extra vector:
Then I used direct formula for calculating distance from a point to line, but it gets me only the distance of the point from the origin axis, not line!
https://en.wikipedia.org/wiki/Distance_ ... _to_a_line
If I could obtain the distance, I can obtain the height of all points in each piece that I obtained from Part slice command from the edge of polygon.
Re: Better algorithm for creating pitched roof (probably)?
Draft has several geometry functions:
To do this manually you can use the Draft_Dimension command and the Draft_Snap_Perpendicular snap.
Code: Select all
import draftgeoutils
draftgeoutils.geometry.findDistance(App.Vector(), [App.Vector(1,0,0), App.Vector(0,1,0)])
edge = App.ActiveDocument.Line.Shape.Edges[0]
draftgeoutils.geometry.findDistance(App.Vector(), edge)
- ebrahim raeyat
- Posts: 619
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: Better algorithm for creating pitched roof (probably)?
Thanks a lot. Finally, for constant angles:Roy_043 wrote: ↑Fri Oct 23, 2020 1:41 pm Draft has several geometry functions:To do this manually you can use the Draft_Dimension command and the Draft_Snap_Perpendicular snap.Code: Select all
import draftgeoutils draftgeoutils.geometry.findDistance(App.Vector(), [App.Vector(1,0,0), App.Vector(0,1,0)]) edge = App.ActiveDocument.Line.Shape.Edges[0] draftgeoutils.geometry.findDistance(App.Vector(), edge)