Author Topic: ==={Challenge}===Find the ridge lines of sloped roof  (Read 106100 times)

0 Members and 2 Guests are viewing this topic.

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #105 on: June 06, 2014, 10:17:35 AM »
chlh_jd, I've implemented your intervention from v.7 to my code, but now complex cases are solved, but simple one isn't... Can you help... Please check "WRONG SOLUTION - ERROR - SIMPLE POLYLINE.dwg" and "SOLUTION WASNT FINISHED.dwg" posted earlier with my codes... On your animated GIF it seems that it functions...
« Last Edit: June 06, 2014, 10:26:48 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #106 on: June 07, 2014, 06:02:04 AM »
Try to solve it yourself , you can annotate part like {(foo) ...;_while} {(foo1} ...;_while} {(while ...;_while} to found which part catch error , and determine which function ... , set a breakpoint by vertex or side , and easy to find where is wrong .

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #107 on: June 08, 2014, 04:39:57 AM »
I've scaled it even more and fixed scale factor to be nicer rounded number... Seems that now sometime it solves simple lwpolyline width outline and sometime it fails... But this is the best I could do... Your code remained unchanged... Here are the routines I use for now... Sorry I was been unsatisfied it passed me... Some very complex polylines can't be solved, but almost all that are decently drawn are solvable...

Thanks, chlh_jd, and sorry for my rough and wrong expectations...

Regards, all the best, M.R.
« Last Edit: June 08, 2014, 10:01:32 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #108 on: June 08, 2014, 11:10:24 AM »
I've scaled it even more and fixed scale factor to be nicer rounded number... Seems that now sometime it solves simple lwpolyline width outline and sometime it fails... But this is the best I could do... Your code remained unchanged... Here are the routines I use for now... Sorry I was been unsatisfied it passed me... Some very complex polylines can't be solved, but almost all that are decently drawn are solvable...

Thanks, chlh_jd, and sorry for my rough and wrong expectations...

Regards, all the best, M.R.
Ribar , you're welcome .
Never mind , every one wish everything perfect .

For scale object , you can put a prompt "Suggest use mm/inch as the min unit to creat slopedroof" , also you can add determine size of the polygon's boundingbox is suitable ? if not scaling it by in the routine , but it may also catch the precision problem . So I suggest do it by users themself .

You can try this case to find which size is suitable --- make 4 points which inside angle is close to zero or pi , and get their intersection ; the next do while loop for scale they 10~1e9,get each intersection and scale back , used deffrent color mark them , and found which is the correct limit .

Code: [Select]
(defun c:test(/ f1 f2 p0 p1 p2 p3 an1 an2 i p pa pb pc i%)
  (setq p0 (getpoint)
p1 (getpoint p0)
p2 (getpoint)
p3 (getpoint p2))
  (setq an1 (angle p0 p1)
an2 (angle p2 p3)
i 0)
  (defun f1 (p)
    (mapcar (function (lambda (x)
(* x 0.1 (expt 10 i))))
    p))
  (defun f2 (p)
    (mapcar (function (lambda (x)
(/ x (* 0.1 (expt 10 i)))))
    p))
  (repeat 9
    (setq i (1+ i))
    (setq p0 (f1 p0)
  p1 (f1 p1)
  p2 (f1 p2)
  p3 (f1 p3))
    (setq p (inters p0 p1 p2 p3 nil)
  pa (inters p0 (polar p0 an1 1.) p2 (polar p2 an2 1.) nil)
  pb (inters p0 (polar p0 an1 1e3) p2 (polar p2 an2 1e3) nil)
  pc (inters p0 (polar p0 an1 1e9) p2 (polar p2 an2 1e9) nil))
    (setq p (f2 p)
  pa (f2 pa)
  pb (f2 pb)
  pc (f2 pc))
    (setq i% 0)
    (mapcar (function (lambda (p)
(if p
  (entmake (list (cons 0 "POINT")
       (cons 10 p)
       (cons 62 (+ i (* 10 i%))))))
(setq i% (1+ i%))
))
    (list p pa pb pc))
    )
  (princ)
  )
« Last Edit: June 08, 2014, 11:17:30 AM by chlh_jd »

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #109 on: June 10, 2014, 05:56:09 AM »
My last version... Still it may find wrong solution or crash, but I think it's a little better for searching solutions - fewer crashes especially with polyline width outlines that were previously crashed... Beside of scaling it's also advisable to put polyline near WCS origin (0.0 0.0 0.0)...

So long from me, M.R.

[EDIT] : 2droof.lsp & 2droof-t.lsp updated to reflect changes in new chlh_jd's Proof_8.lsp
[EDIT] : 2droof.lsp & 2droof-t.lsp updated to reflect changes in new chlh_jd's Proof_9.lsp
[EDIT] : 2droof.lsp & 2droof-t.lsp updated to reflect changes in new chlh_jd's Proof_10.lsp
« Last Edit: June 20, 2014, 08:05:05 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #110 on: June 10, 2014, 01:47:43 PM »
New version , add header and more test .
Code - Auto/Visual Lisp: [Select]
  1. ;;;-----------------------------------------------------------------------------;;;
  2. ;;;  
  3. ;;;  ---------------------------------------------------------------------------;;;
  4. ;;;  SlopedRoof                                                                 ;;;
  5. ;;;  ---------------------------------------------------------------------------;;;
  6. ;;;  function : Find the ridge lines of sloped roof                             ;;;
  7. ;;;  ---------------------------------------------------------------------------;;;
  8. ;;;  Return:                                                                    ;;;
  9. ;;;         2D -- SlopedRoof Lines / SlopedRoof Closed Polygons of  Each Side   ;;;
  10. ;;;         3D -- SlopedRoof Closed Polygons of Each face                       ;;;
  11. ;;;                          / A Union Surface                                  ;;;
  12. ;;;                          / Solids of Each face                              ;;;
  13. ;;;  ---------------------------------------------------------------------------;;;
  14. ;;;  Writen By GSLS(SS) June 2014                                               ;;;
  15. ;;;        (C)  EasyCity OptDesign Studio of Building Structures                ;;;
  16. ;;;  Email: chlh_jd@126.com        Tel:86-0592-5391029    Fax:86-0592-5391020   ;;;
  17. ;;;  ---------------------------------------------------------------------------;;;
  18. ;;;  Main thread reference :                                                    ;;;
  19. ;;;      JianGuo Li, Algorithm about generate slopedroof line from 2D polygon.  ;;;
  20. ;;;      [BC Dissertation] Hubei University in China . 2009.                   ;;;
  21. ;;;      Many Thanks to JianGuo Li !                                            ;;;
  22. ;;;  -------------------------------------------                                ;;;
  23. ;;;  JianGuo Li's article main abort references :
  24. ;;;      [5] D.T.Lee. Medial axis transformation of a planar shape [J],IEEE Trans PAM I , 1982, 4:363-369
  25. ;;;      [6] Chin F, Snoeyink J., Wang C.A. Finding the medial axis of a simple polygon in linear time
  26. ;;;           [J]. Discrete and Computational Geometry , 1999, 21:405-420
  27. ;;;      [8] Joseph O,Rourke. Computational Geometry In C [M].Second Edition. Cambridge University Press, 2004.179-181
  28. ;;;      ......
  29. ;;;  ---------------------------------------------------------------------------;;;
  30. ;;;  Version revit See Command Routine .                                        ;;;
  31. ;;;  -------------------------------------------                                ;;;
  32. ;;;  Thanks Ribar.M from http://www.theswamp.org  for do many test              ;;;
  33. ;;;  -------------------------------------------                                ;;;
  34. ;;;  Discuss website : http://www.theswamp.org/index.php?topic=41837.0          ;;;
  35. ;;;  -------------------------------------------                                ;;;
  36. ;;;  Any Advice will be welcome , Thank you !                                   ;;;
  37. ;;;  ---------------------------------------------------------------------------;;;
  38.  
« Last Edit: June 10, 2014, 01:54:28 PM by chlh_jd »

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #111 on: June 10, 2014, 04:31:10 PM »
chlh_jd, thanks for your LISP... Found little mistake - change (getangle) to (getreal) when specifying Degrees... Everything else is fine... I haven't analyzed it but it seems that it handles polyline width outlines... So with less coding it's better than mine, but there is one example where my version can handle complex polyline - after error messages and your is looping forever...

Thanks, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #112 on: June 13, 2014, 01:28:13 AM »
chlh_jd, thanks for your LISP... Found little mistake - change (getangle) to (getreal) when specifying Degrees...
Ribar , you're welcome . Many thanks for your test .
GetAngle allow user type in specifying angle , I don't think it's a mistake unless you give some e.g. .

... Everything else is fine... I haven't analyzed it but it seems that it handles polyline width outlines
Thanks, M.R.
The width pl to ontlines routine I'v writen so long ago and no time to opt it , do you have a better version ?
... So with less coding it's better than mine, but there is one example where my version can handle complex polyline - after error messages and your is looping forever...
Can you post the error dwg ? Thanks .

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #113 on: June 13, 2014, 04:34:23 AM »
chlh_jd, thanks for your LISP... Found little mistake - change (getangle) to (getreal) when specifying Degrees...
Ribar , you're welcome . Many thanks for your test .
GetAngle allow user type in specifying angle , I don't think it's a mistake unless you give some e.g. .
If you plan to keep (getangle), you should remove line with conversion of variable a to radians - getangle takes values in degrees and automatically assigns radians to variable... The simplest way for modifications is to change (getangle) to (getreal) and to keep everything else as it is...
... Everything else is fine... I haven't analyzed it but it seems that it handles polyline width outlines
Thanks, M.R.
The width pl to ontlines routine I'v writen so long ago and no time to opt it , do you have a better version ?
No, chlh_jd I use your version, but I believe Lee Mac has also this routine - both normal and advanced versions with elliptical arcs if polyline with arced segments...
... So with less coding it's better than mine, but there is one example where my version can handle complex polyline - after error messages and your is looping forever...
Can you post the error dwg ? Thanks .
I'll post examples, but note that I can't occupy theswamp with so many of them, still there are complex polylines that aren't solvable for now, just draw one with many vertices and go zig-zag in making segments - avoid convex shapes - concave are problematical...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #114 on: June 14, 2014, 08:17:58 AM »
Thanks Ribar .

1. I knew getangle will return degree , I use it just for degree in the case .

2. Not all things are open source, and use it and cherish it .

3. Just like I've said , the routine can't suit for any case , what you post you can solve in yours , I'll try to slove it , but not sure I can do it .

Thank you again .

« Last Edit: June 14, 2014, 10:49:35 AM by chlh_jd »

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #115 on: June 14, 2014, 02:44:37 PM »
Ribar , new version fix the bug your post .
« Last Edit: June 14, 2014, 03:36:05 PM by chlh_jd »

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #116 on: June 15, 2014, 05:31:35 AM »
chlh_jd, thanks for new Proof_9.lsp... Still it isn't all OK... Now complex roof... You can try to make similar examples and test... Only if you have extra time and wish to continue...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #117 on: June 17, 2014, 04:41:16 AM »
Ribar , the error you post has been fix , see proof-10.lsp and gif , thank you .
Proof-10 , add 2d frame draw mode , it's like the frame get by voronoi method , but higher acc than voronoi .

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #118 on: June 17, 2014, 08:27:02 AM »
Thanks, chlh_jd... Another one, only if you have wish to continue... And so on...

Many thanks, regards, M.R.
« Last Edit: June 17, 2014, 08:57:58 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #119 on: June 19, 2014, 02:01:34 PM »
Nothing special, updated LISPs posted here :

http://www.theswamp.org/index.php?topic=41837.msg522582#msg522582

Regards, M.R.

[EDIT] : There was mistake - now corrected...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube