Author Topic: Straight Skeletons for Roofs  (Read 18732 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Straight Skeletons for Roofs
« Reply #45 on: March 07, 2006, 04:55:54 PM »
< .. snip ..> Otherwise stop 80% of the coding posted here because it is built-in somewhere. :-D

^^ what he said ! 

innovation IS critical.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

One Shot

  • Guest
Re: Straight Skeletons for Roofs
« Reply #46 on: May 01, 2008, 04:08:41 PM »
This topic was very interesting?  What ever happened to this anyway?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10397
Re: Straight Skeletons for Roofs
« Reply #47 on: May 01, 2008, 05:12:48 PM »
It proved too difficult for me at the time. I think I could now do the flat version I proposed, but it was a limited solution at best. That is it would only work for single plate height roofs.

I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

One Shot

  • Guest
Re: Straight Skeletons for Roofs
« Reply #48 on: May 01, 2008, 06:24:26 PM »
It proved too difficult for me at the time. I think I could now do the flat version I proposed, but it was a limited solution at best. That is it would only work for single plate height roofs.



I was trying to find a program like this back is 2005 to use it at work.  Maybe someday it could get completed.

Thank you,

Brad

One Shot

  • Guest
Re: Straight Skeletons for Roofs
« Reply #49 on: May 02, 2008, 08:55:40 AM »
It proved too difficult for me at the time. I think I could now do the flat version I proposed, but it was a limited solution at best. That is it would only work for single plate height roofs.



Cab,

could you post what you have.  I would like to see how it works.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10397
Re: Straight Skeletons for Roofs
« Reply #50 on: May 02, 2008, 09:14:48 AM »
No, because it doesn't work. :-)
What I have is 545 lines of code in the development stages from 2004.
The debugging had just begun and looking back at the code there are many things I would change
just because of the knowledge I have gained over the years.
The code is too raw for me to post and without knowledge of the code and lack of commenting only an
experienced programmer could figure it out.


I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

One Shot

  • Guest
Re: Straight Skeletons for Roofs
« Reply #51 on: May 02, 2008, 12:56:40 PM »
No problem Cab, I understand.

One Shot

  • Guest
Re: Straight Skeletons for Roofs
« Reply #52 on: May 02, 2008, 01:06:43 PM »

Arch_Eric

  • Guest
Re: Straight Skeletons for Roofs
« Reply #53 on: May 08, 2008, 04:39:03 PM »
Clear! (thump) Here's my donation so far...though it's just a bloated offset routine just yet...

Code: [Select]
(defun loff (pt od)
(setq ang (angle (car pt) (cadr pt)))
(list (polar (car pt) (+ ang (/ pi 2)) od) (polar (cadr pt) (+ ang (/ pi 2)) od)))

(defun witio (lin1 lin2 intb)
 (inters (car lin1) (cadr lin1) (car lin2) (cadr lin2) intb)
)
 
(defun lpfm (lin1 dir)
 (setq mp (polar (car lin1) (angle (car lin1) (cadr lin1)) (/ (distance (car lin1) (cadr lin1)) 2)))
 (setq ep (polar mp (+ (angle (car lin1) (cadr lin1)) (* (/ pi 2) dir)) 2000))
 (list mp ep))

(defun c:skel ()
(setq iter (getint "Number of iterations: "))
(setq roof (entget (car (entsel "\nSelect roof outline:"))))
(setq rv '())
(setq n -1)
(repeat (length roof)
 (setq n (+ 1 n))
 (if (= (car (nth n roof)) 10)
  (setq rv (cons (cdr (nth n roof)) rv))
 )
)
(setq re '())
(setq n -1)
(repeat (length rv)
 (setq n (+ 1 n))
 (if (= n (- (length rv) 1)) (setq re (cons (list (nth n rv) (nth 0 rv)) re)) (setq re (cons (list (nth n rv) (nth (+ 1 n) rv)) re)))
)
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-EndUndoMark ActDoc)
(vla-StartUndoMark ActDoc)
(setq osm (getvar "osmode"))
(setvar "osmode" 0)
(setq n -1)
(setq ra '())
(repeat (length re)
 (setq n (+ n 1))
 (setq m n)
 (setq as T)
 (repeat (length re)
  (setq m (+ m 1))
  (if (> m (- (length re) 1)) (setq m 0))
  (if (= m n) (setq m (+ 1 m)))
  (if as (progn
  (if (witio (lpfm (nth n re) 1) (nth m re) T) (setq as nil ra (append ra '(1))))
  (if (witio (lpfm (nth n re) -1) (nth m re) T) (setq as nil ra (append ra '(-1))))))
 )
)
(setq o 0)
(repeat iter
 (command "_pline")
 (setq n -1)
 (setq o (+ 1 o))
 (repeat (+ (length re) 1)
  (setq n (+ n 1))
  (if (= n (- (length re) 1)) (setq m 0) (setq m (+ n 1)))
  (if (= n (length re)) (setq n 0 m 1))
  (command (witio (loff (nth n re) (* o (nth n ra))) (loff (nth m re) (* o (nth m ra))) nil))
 )
 (command "")
)
(vla-EndUndoMark ActDoc)
(setvar "osmode" osm)
(princ)
)
« Last Edit: May 08, 2008, 04:42:20 PM by Arch_Eric »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10397
Re: Straight Skeletons for Roofs
« Reply #54 on: May 08, 2008, 05:42:33 PM »
Eric,
Welcome to TheSwamp. :-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Arch_Eric

  • Guest
Re: Straight Skeletons for Roofs
« Reply #55 on: May 08, 2008, 06:20:24 PM »
Thanks, Cab :)

Did you go that page with the java applet showing how it calculated the roofs? Wowsa. That's amazing stuff. I seriously see it being possible in LISP. But I've got a question for the lot of ya.

In my function, I collect all the vertices, then create a list of all the edges using the vertices. Then I take each edge and check which direction a perpendicular line from the midpoint intersects another edge and use that direction as the interior of the shape. It works ok for simple roof shapes, but eats dirt on concave type shapes that would have an intersection both ways. Like I said before, I'm pretty green in LISP and haven't figured a better way yet. Any ideas?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10397
Re: Straight Skeletons for Roofs
« Reply #56 on: May 08, 2008, 07:27:42 PM »
Yes there are some cool links with great demo's.
My only possible solution was this http://www.theswamp.org/index.php?topic=721.msg100264#msg100264

LE's example used the perimeter as a polyline & then offset to the inside.

Not sure of your question though. Perhaps a picture, if you can post one.
In the Reply screen you will see "Additional Options", click it & it will allow you to upload a photo or DWG.

See Ya.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Arch_Eric

  • Guest
Re: Straight Skeletons for Roofs
« Reply #57 on: July 01, 2008, 02:49:23 PM »
Ok, I've spent the last few nights laying awake in bed running through an algorithm for this. In my head it works.  :-P

Code: [Select]
Collect vertex points
Define the bisector line for each vertex, calling each bisector a tier 1
Recursively loop through function:
Loop through the bisector lines to find the shortest intersection with another bisector
- With the shortest bisecting line, check to see if other bisectors intersect at the same point
- If at least one line intersects at that point, draw all lines that intersect and remove bisectors from list
- If no other lines intersect, check tier of bisectors
 + If tier 1s then create new bisector line using the angles of the two, and define as a tier 2
 + If tier 1 and 2 bisect (should be a ridgeline with a hipline or something), check the angle of intersection
  | If < 90 mirror the tier 1 across a line 90deg from tier 2
  | If > 90 mirror the tier 1 across the tier 2 line
 + If two tier 2's bisect, it should be far enough into the routine to be finding 3 or more lines intersecting at the same point
 + Remove intersecting bisectors from list
- Check the length of list against the length before above code and see if list is shorter; if not report error and exit
- Call back into self with new list
:?

Lost yet? I've got the base code for it, I just need to write the recursive function (ie - the hard part). I'm kinda itchy to see what it will return when I run it. Of course, single plate height will be the issue here, but you people should be able to modify the outcome to your needs.  :evil:

Spike Wilbury

  • Guest
Re: Straight Skeletons for Roofs
« Reply #58 on: July 20, 2008, 12:49:48 AM »
Yes there are some cool links with great demo's.
My only possible solution was this http://www.theswamp.org/index.php?topic=721.msg100264#msg100264

LE's example used the perimeter as a polyline & then offset to the inside.

Not sure of your question though. Perhaps a picture, if you can post one.
In the Reply screen you will see "Additional Options", click it & it will allow you to upload a photo or DWG.

See Ya.

BTW, Here it is an animated image showing the latest done in arx... it just needs some minor corrections :)
« Last Edit: July 21, 2008, 11:05:53 PM by Luis E. »

Arch_Eric

  • Guest
Re: Straight Skeletons for Roofs
« Reply #59 on: July 20, 2008, 02:19:32 AM »
Cool.  :-) Mine is nowhere near that good. I've got basic shapes down, but it craps out on complex ones. How are you determining your intersections and the resulting lines?