Ability to create point surfaces by reading x, y, z coordinates from an ASCII file


Users expressed their desire to be able to create a relatively
large number of point surfaces (20+) through TUI commans by taking the input of the X, Y, Z coordinates of the
points from an ASCII file.


The Scheme file showed below implements the requested functionality.
The ASCII file containing the X, Y, Z coordinates has to verify a certain
format requirement described below.

The comments in the begininng of the Scheme file contain all the
info needed to write valid input ASCII files and using the Scheme
function. If any questions or difficulties appear with the usage
of this Scheme function please email the originator of this Solution.

;;===================================================
;;; This Scheme tool reads x, y, and z triplets
;;; of coordinates from an ASCII input file and
;;; creates the point surfaces corresponding to
;;; these triplets

;;; The point coordinates have to fit inside the
;;; computational domain, otherwise surface
;;; creation routine will fail for those
;;; points outside the domain

;;; Example of a valid input file:

;;; 0 0 0
;;; 1 1 1
;;; 2 2 2

;;; (remove the ";;;" before using it)

;;; !! If the input file does not verify
;;; this type of format, erroneus results
;;; will be obtained

;;;
;;; Usage:

;;; 1) Read case and data files.

;;; 2) Have a copy of the ASCII input file in the working directory.

;;; 3) File>Read>Scheme .. this file (read-pf.scm)
;;; or through TUI command
;;; (load "read-pf.scm")

;;; 4) TUI command to use the Scheme tool (generic syntax):

;;; (read-points-file i-min i-max file-name prefix-for-surfaces)

;;; where:

;;; i-min and i-max allow selection of preferred triplets
;;; in the input file

;;; file-name is a string designating the input ASCII file

;;; prefix-for-surfaces is a string designating the common
;;; root for the names of the newly created point-surfaces

;;; For example:

;;; (read-points-file 10 100 "points.xyz" "sensor")

;;; will read the file points.xyz and use the triplets
;;; starting with the 10th and ending with the 100th one
;;; to create point-surfaces called "sensor-10", "sensor-11",
;;; ... "sensor-100".
;;; With this example, if there are less than 10 triplets in the file
;;; no point surfaces are created. If there are less than 100 triplets
;;; in the file a corresponding smaller number of point surfaces is created
.
;;;
;;; Do not change below this line without calling for support
;;; ==========================================================
(define (set-point-surface name coordinates)
(let ((sid))
(set! sid (new-surface-id))
(point-surface sid (cons coordinates '()))
(ti-menu-load-string (string-append "/su/re-su " (number->string sid) " " name
))
))
;;;;;;
(define (read-points-file imin imax file-name prefix-name)
(let ((pt))
(set! pt (open-input-file file-name))
(let loop ((i 1))
(if (< i (+ imax 1))
(begin
(let ((x)(y)(z)(lc)(i-name))
(set! x (read pt))
(set! y (read pt))
(set! z (read pt))
(if (and (not (eof-object? x))(> i (- imin 1)))
(begin
(set! lc (list x y z))
;;;;
(set! i-name (string-append prefix-name "-" (number->string i)))
(set-point-surface i-name lc)
)))
;;;
(loop (+ i 1))))
)))





Show Form
No comments yet. Be the first to add a comment!