squirreldip,
I have tested your revision. All but one of the functions worked well. The TIN:READ has a few problems. I am a VL challenged person, so I rewrote the code with plain LISP. As such it also works well. In doing so I also had to add a function to replace the VL routines. It is TIN:GETSTRPOS.
I am glad you have done this because I have been wanting to have a READ/WRITE to files for the TIN's. Having that inclusion will allow the system to be more flexible and repeatable. I have also wanted a PICK ELEVATION function for design purposes.
Whether your entire concept should be adopted, however, I can't speak to... except that it looks like a lot of code changes and debugging to pull it off. Nevertheless, I can say that reviewing your code has caused me to have a better grasp of the TRIANGULATION program.
; find a string in a string - returns position of first letter - zero if none
(defun TIN:GETSTRPOS (ssub sall / lsub lall i n ret)
(setq lall (strlen sall)
lsub (strlen ssub)
)
(setq ssub (strcase ssub))
(setq sall (strcase sall))
(setq ret nil)
(cond ((> lsub lall) 0)
((<= lsub lall) (setq i 1 n (1+ (- lall lsub)))
(while (and (not ret) (<= i n))
(if (= ssub (substr sall i lsub))
(setq ret i)
(setq i (1+ i))
)
)
(if (= ret nil) (setq ret 0))
ret
)
(T (if (= ssub sall) 1))
)
)
; TIN:READ reads the input file and returns a triangle list (lists of 3 3dpoint lists)
(defun TIN:READ (DiskFileName / DataFile DataLine P1 P2 P3 TL TLF X Y Z pos1 dat)
(setq TLF nil dat 0)
(if (setq DataFile (open DiskFileName "r"))
(progn
(while (setq DataLine (read-line DataFile))
(setq dat (+ dat 1))
(setq pos1 (TIN:GETSTRPOS "," DataLine))
(setq X (atof (substr DataLine 1 (- pos1 1)))) ;; get X element of point
(setq DataLine (substr DataLine (+ pos1 1))) ;; reduce DataLine to remainder
(setq pos1 (TIN:GETSTRPOS "," DataLine))
(setq Y (atof (substr DataLine 1 (- pos1 1)))) ;; get Y element of point
(setq DataLine (substr DataLine (+ pos1 1))) ;; reduce DataLine to remainder
(setq pos1 (TIN:GETSTRPOS "," DataLine))
(setq Z (atof (substr DataLine 1 (- pos1 1)))) ;; get Z element of point
(setq DataLine (substr DataLine (+ pos1 1))) ;; reduce DataLine to remainder
(setq P1 (list X Y Z))
(setq pos1 (TIN:GETSTRPOS "," DataLine))
(setq X (atof (substr DataLine 1 (- pos1 1)))) ;; get X element of point
(setq DataLine (substr DataLine (+ pos1 1))) ;; reduce DataLine to remainder
(setq pos1 (TIN:GETSTRPOS "," DataLine))
(setq Y (atof (substr DataLine 1 (- pos1 1)))) ;; get Y element of point
(setq DataLine (substr DataLine (+ pos1 1))) ;; reduce DataLine to remainder
(setq pos1 (TIN:GETSTRPOS "," DataLine))
(setq Z (atof (substr DataLine 1 (- pos1 1)))) ;; get Z element of point
(setq DataLine (substr DataLine (+ pos1 1))) ;; reduce DataLine to remainder
(setq P2 (list X Y Z))
(setq pos1 (TIN:GETSTRPOS "," DataLine))
(setq X (atof (substr DataLine 1 (- pos1 1)))) ;; get X element of point
(setq DataLine (substr DataLine (+ pos1 1))) ;; reduce DataLine to remainder
(setq pos1 (TIN:GETSTRPOS "," DataLine))
(setq Y (atof (substr DataLine 1 (- pos1 1)))) ;; get Y element of point
(setq DataLine (substr DataLine (+ pos1 1))) ;; reduce DataLine to remainder
(setq Z (atof DataLine)) ;; DataLine no longer has a delimiter
(setq P3 (list X Y Z))
(setq TL (list P1 P2 P3))
(setq TLF (append TLF (list TL)))
) ;; end while
(close DataFile)
) ; end progn
) ; end if
(alert (strcat (itoa dat) " TIN's are imported."))
TLF
) ; end TIN:READ
Thanks again for the new functions. They are important to me.
Rick.