Author Topic: Triangulation (re-visited)  (Read 317737 times)

0 Members and 2 Guests are viewing this topic.

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #510 on: December 03, 2015, 02:46:15 PM »
Rick,

In "Triang", there is already a subroutine "mk_3dp" that does the same as your "mk_bnd"

Code - Auto/Visual Lisp: [Select]
  1. ;;                                                                            ;
  2. ;; mk_3dp    by Alan J Thompson                                               ;
  3. ;;                                                                            ;
  4. ;; Argument: l, A list of points (2d or 3d)                                   ;
  5. ;;                                                                            ;
  6. ;; Create an LWPolyline at Elevation 0, on Current Layer.                     ;
  7. ;; Return: Polyline Object                                                    ;
  8. ;;                                                                            ;
  9.  
  10. (defun mk_3dp (l / x)
  11.    (en2obj
  12.       (if (and (> (length l) 1)
  13.                (entmakex (list '(0 . "POLYLINE") '(10 0. 0. 0.) '(70 . 8)))
  14.                (foreach x l (entmakex (list '(0 . "VERTEX") (cons 10 x) '(70 . 32))))
  15.           )
  16.         (cdr (assoc 330 (entget (entmakex '((0 . "SEQEND"))))))
  17.       )
  18.    )
  19. )
  20.  

Closing the poly should be a task done in the main.

This way we keep the routine a little more generic.

ymg

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #511 on: December 04, 2015, 09:53:01 AM »
YMG,

Thanks for telling me how to create the code windows... I had been wondering.

I had tried to use mk_3dp before I did the mk_bnd. It wasn't closing, so in the interest of simply demonstrating the code, I made mk_bnd. I now see how to close a poly and still use mk_3dp.

Code: [Select]
;; begin patch
(defun c:bnd (/ tmp grdmod grdval plst get_bnd) ;; was c:bound
   (if (not csurf) (setq csurf "Natural Ground"))
   (if (/= "" (setq tmp (getstring (strcat "\nCreate a Boundary for TIN <" csurf ">: "))))
       (setq csurf tmp)
       )   
   (mk_layer (list "Boundary" 2))
   
   (setq grdval (getvar "elevation")) ; save preset elevation (normally 0.0)
   (setq grdmod (getvar "OSNAPZ")) ; save elevation snap-mode
   (setvar "OSNAPZ" 0) ; set snap to object-grade

   (defun get_bnd (/ lst pt OK)
      (if (car (setq lst (list (getpoint "\nFirst clockwise Boundary point: ")))) ;; if test
          (progn
             (while (setq pt
        (if (> (length lst) 1)
                        (progn
          (initget "Undo")
          (getpoint (car lst) "\nNext clockwise Boundary point [Undo]: ")
              ) ;; end if=yes
                        (getpoint (car lst) "\nNext clockwise Boundary point: ")
                        ) ;; end if length
                    ) ;; end while test
                    (redraw)
                    (mapcar '(lambda (a b) (grdraw a b 1 1)) (setq lst (if (eq pt "Undo") (cdr lst) (cons pt lst))) (cdr lst))
              ) ;; end while
            (cond ((> (length lst) 1) lst)) ;; post list
            ) ;; end progn if=yes
           ) ; end if
      ) ;; end _getpoints   

   (if (and (setq plst (get_bnd))
            (if (> (length plst) 2)
    (setq OK 1) ;; valid list
    (alert "Boundary must exceed 2 points")
)
) ;; end test
       (progn (if (equal (car plst) (last plst) 0.001)
                  (setq OK 1) ;; valid loop
              (setq plst (append plst (list (car plst)))) ;; close loop
                  )  
          (mk_3dp plst)
  (setq *bounden* (entlast))
  (redraw)
  ) ;; end progn
   ) ;; end if
 
   (setvar "OSNAPZ" grdmod) ; restore elevation snap-mode
   (setvar "elevation" grdval) ; restore preset-elevation (normally 0.0)
   ;;(*error* nil) ;; no error catch implemented (I don't know what parameters should be used)
   (princ)
) ;; end BND
;; end *upgrade patch*

I have kept the BND name so you can compare operation with BOUND. I haven't done the *error* catch because I don't know what parameters should be used with this type of poly.

I have done some testing on making boundaries that most user's would never do. They cut across where natural TIN's would be built, and in particular, through breaklines. The result is that it did not delete any TIN's that are contiguous to a breakline. I think that is proper.

But (still with the sloppy Boundary that I made) it appeared as if holes were left in the TIN in certain places against the Boundary. I couldn't get a TIN to highlight when I hovered over where I expected one to be. So I set the Boundary under the TIN's and the "hole TIN's" were there. The Boundary just overrode the object highlighting.

It seems that everything is proper. The contours built well.

Rick

Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

TopoWAR

  • Newt
  • Posts: 135
Re: Triangulation (re-visited)
« Reply #512 on: December 08, 2015, 12:30:06 PM »
hello, the function "TIN" works well :-D, the "CONT" does not work :-(, see DWG. thanks

I used autocad 2007 and 2015, win 7 ultimate x86
I get the error 40%

Code: [Select]
autocad 2007/2015 x86 win7 ultimate
Error: bad argument type: 2D/3D point: nil

;;funcion lisp
(defun ratiopoint (a b r) (polar a (angle a b) (* (distance a b) r)))

---> error ( b ) = nil


argument a = (5148.52 2400.0)
argument b = nil
argument r = 0.5

ERROR!!
CHECKING. Here the Vertex 2 EQUALS 3 SEE PICTURE
« Last Edit: December 10, 2015, 01:22:46 PM by TopoWAR »
Thanks for help

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #513 on: December 09, 2015, 07:42:33 AM »
TopoWar,

I tried the file. CONT appears to work on my machine. There aren't very many contours.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

TopoWAR

  • Newt
  • Posts: 135
Re: Triangulation (re-visited)
« Reply #514 on: December 09, 2015, 10:32:04 AM »
my not work for me :-(
It is very strange, just give me error if I make a single selection of everything, but if I do I work in 2 parts !!
« Last Edit: December 09, 2015, 10:38:10 AM by TopoWAR »
Thanks for help

pedroantonio

  • Guest
Re: Triangulation (re-visited)
« Reply #515 on: December 09, 2015, 03:59:31 PM »
Hi ymg. Can you put the Depression Contour in a new layer or give as an option if we want to draw it or not because in close contours is very ugly and became a mess.

Thanks

TopoWAR

  • Newt
  • Posts: 135
Re: Triangulation (re-visited)
« Reply #516 on: December 10, 2015, 02:54:12 PM »
by the time I managed to avoid the error by adding a condition in the variables that cause the error (A1 and A3)

Code: [Select]
(t (setq cn1 (list (/ (+ (car p1) (car p2) (car p3)) 3) (/ (+ (cadr p1) (cadr p2) (cadr p3)) 3))
        cn2 (list (/ (+ (car p1) (car p3) (car p4)) 3) (/ (+ (cadr p1) (cadr p3) (cadr p4)) 3))
         a1 (cond
       ((inters cn1 p1 v1 v2))
       ((inters cn1 p3 v1 v2))    
    )
                         a3 (cond
       ((inters cn2 p1 v2 v3))
       ((inters cn2 p3 v2 v3))
    )          
   
                  )
;;;;;modification
(if (and a1 a3)
  (progn
    (setq b1 (ratiopoint a1 v2 hfac)
  b2 (ratiopoint v2 a3 hfac)
  c1 (midpoint b1 b2)
  ps (list (list a1 b1 c1) (list c1 b2 a3)))
  )
)

for some reason the value of v1 v2 v3 were the same, I hope to find the error background, Greetings
Thanks for help

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #517 on: December 10, 2015, 05:39:35 PM »
All the error in Contour are still related to contours being
smack on a triangle.

Thought I had covered every base but it seems I didn't

Will post a revision when I have a solution.

@topographer

If you use qselect and select according to linetype, you can
isolate the depression contour.

ymg
« Last Edit: December 10, 2015, 05:43:51 PM by ymg »

TopoWAR

  • Newt
  • Posts: 135
Re: Triangulation (re-visited)
« Reply #518 on: December 10, 2015, 05:46:01 PM »
ymg , Thanks for the answer, a question may be used without modification problem I did?
Thanks for help

pedroantonio

  • Guest
Re: Triangulation (re-visited)
« Reply #519 on: December 10, 2015, 06:24:45 PM »
Quote
If you use qselect and select according to linetype, you can
isolate the depression contour.

Hi ymg . I thought if you can add an option in the dcl file to choose if want to draw them or not.

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #520 on: December 11, 2015, 08:05:43 PM »
topographer,

It can be done quite easily.

However the Dialog Box is getting a little overloaded.

Will put a checkbox for it in next version.

ymg

pedroantonio

  • Guest
Re: Triangulation (re-visited)
« Reply #521 on: December 12, 2015, 02:13:39 AM »
Thank you ymg

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #522 on: December 26, 2015, 04:18:49 PM »
YMG,

When I first tested the TOPOWAR drawing I hadn't selected all the TINS. It appeared to work fine.

I have tried some scenarios to isolate where the error occurs. It only happens after you have selected a certain number of TINS.

I selected from the top down until I found the error. Then I selected from the bottom up, overlapping the error area. No error.

I selected an area between them that overlaps the error. No error.

I don't think it is a division by zero problem. I think it is how many objects are being processed.

Whether I select the top portion or bottom, if I get too many TINS it has an error.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #523 on: December 26, 2015, 08:33:27 PM »
Rick,

I believe I have located the error.

It is all related to points of the 3dface being at the same elevation as the contour.

Will need to add a test there and everything should be OK.

ay take a little while as I am quite busy at the moment.

ymg

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #524 on: December 28, 2015, 09:02:50 AM »
YMG,

In DEMOZ, either the value "p" or "pnt" is not assigned a value...

(setq p (cadr pnt) tn (triloc p))

It crashes after the above code... Error: bad argument type: consp nil

Rick

*** I just realized that part of this could possibly be from an out of session use.

I inserted the following code before (chglayer '("TIN" ... code
(if (not csurf) (setq csurf "Natural Ground")) ;; *** fix for out of session use ***

I also noticed that (chglayer '("Points" needs to be "Point"

These changes eliminated random crashes, but not the "consp nil" problem.
I am assuming that you can't use DEMOZ out of session. Too bad. It would be nice.

Rick

Works great within a TIN session.
« Last Edit: December 28, 2015, 02:31:55 PM by rw2691 »
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."