parameters.lisp 7.56 KB
Newer Older
1
;;
2
;; Copyright 2002-2011 Genworks International 
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;; 
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; Affero General Public License for more details.
;; 
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file.  If not, see
;; <http://www.gnu.org/licenses/>.
;; 

(in-package :geom-base)

24 25


26
(eval-when (:compile-toplevel :load-toplevel :execute)
27
  (defmacro make-vector (&rest args)
28 29
    "0D, 1D, 2D, 3D, or 4D Vector. (Internally this is the same as a Point) 
Returns a vector of double-floats from up to 4 numbers."
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    (let ((array (gensym)))
      (ecase (length args)
        (0 `(make-array 0))
        (1 `(let ((,array (make-array 1)))
              (setf (svref ,array 0) (coerce ,(first args) 'double-float)) ,array))
        (2 `(let ((,array (make-array 2)))
              (setf (svref ,array 0) (coerce ,(first args) 'double-float))
              (setf (svref ,array 1) (coerce ,(second args) 'double-float)) ,array))
        (3 `(let ((,array (make-array 3)))
              (setf (svref ,array 0) (coerce ,(first args) 'double-float))
              (setf (svref ,array 1) (coerce ,(second args) 'double-float))
              (setf (svref ,array 2) (coerce ,(third args) 'double-float)) ,array))
        (4 `(let ((,array (make-array 4)))
              (setf (svref ,array 0) (coerce ,(first args) 'double-float))
              (setf (svref ,array 1) (coerce ,(second args) 'double-float))
              (setf (svref ,array 2) (coerce ,(third args) 'double-float))
              (setf (svref ,array 3) (coerce ,(fourth args) 'double-float)) ,array)))))

  (defmacro make-point (&rest args)
    "3D Point. (Internally this is the same as a 3D Vector) Returns a vector of double-floats from up to 4 numbers."
    `(make-vector ,@args)))



(defvar *debug?* nil)

56 57 58
(glisp:define-constant *nominal-x-vector* (make-vector 1 0 0))
(glisp:define-constant *nominal-y-vector* (make-vector 0 1 0))
(glisp:define-constant *nominal-z-vector* (make-vector 0 0 1))
59

60 61 62
(glisp:define-constant *nominal-x-vector-r* (make-vector -1 0 0))
(glisp:define-constant *nominal-y-vector-r* (make-vector 0 -1 0))
(glisp:define-constant *nominal-z-vector-r* (make-vector 0 0 -1))
63 64


65 66 67
(glisp:define-constant *nominal-x-array* #2a((1.0d0 0.0d0 0.0d0)))
(glisp:define-constant *nominal-y-array* #2a((0.0d0 1.0d0 0.0d0)))
(glisp:define-constant *nominal-z-array* #2a((0.0d0 0.0d0 1.0d0)))
68 69


70 71 72
(glisp:define-constant *nominal-x-array-r* #2a((-1.0d0 0.0d0 0.0d0)))
(glisp:define-constant *nominal-y-array-r* #2a((0.0d0 -1.0d0 0.0d0)))
(glisp:define-constant *nominal-z-array-r* #2a((0.0d0 0.0d0 -1.0d0)))
73

74
(glisp:define-constant *trimetric-normal-vector* (make-vector 0.8342367128320977 -0.4377640254359154 0.3352786378480434))
75 76
    ;;(make-vector 0.83425635 -0.43777433 0.33528653)

77
(glisp:define-constant *trimetric-normal-vector-left* (make-vector -0.8342367128320977 -0.4377640254359154 0.3352786378480434))
78 79
   ;;(make-vector -0.83425635 -0.43777433 0.33528653)

80
(glisp:define-constant *trimetric-normal-vector-right-rear* (make-vector 0.8342367128320977 0.4377640254359154 0.3352786378480434))
81 82
  ;;(make-vector 0.83425635 0.43777433 0.33528653)

83
(glisp:define-constant *trimetric-normal-vector-left-rear* (make-vector -0.8342367128320977 0.4377640254359154 0.3352786378480434))
84 85
 ;;(make-vector -0.83425635 0.43777433 0.33528653)

86
(glisp:define-constant +nominal-origin+ (make-point 0 0 0))
87

88 89
(glisp:define-constant +half-sqrt-2+ (half (sqrt 2.0)))

90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

(defparameter *standard-face-hts* (make-hash-table :test #'equalp))

(defparameter *line-thickness-default* 0.5)

(defparameter *standard-views*
    (list :top    *nominal-z-vector*
          :bottom *nominal-z-vector-r*
          :left   *nominal-x-vector-r*
          :right  *nominal-x-vector*
          :front  *nominal-y-vector-r*
          :rear   *nominal-y-vector*
          :trimetric *trimetric-normal-vector*
          :tri-r-r *trimetric-normal-vector-right-rear*
          :tri-l *trimetric-normal-vector-left*
          :tri-l-r *trimetric-normal-vector-left-rear*))


(defparameter *gs-text-alpha-bits* 4 "Integer. The amount of anti-aliasing for Ghostscript to apply
to text when making PNG or JPEG images. Defaults to 4. Set to 0 for no antialiasing.")

(defparameter *gs-graphics-alpha-bits* 4 "Integer. The amount of anti-aliasing for Ghostscript to apply
to graphics when making PNG or JPEG images. Defaults to 4. Set to 0 for no antialiasing.")


(defun point-expression (point)
  `(make-point ,(get-x point) ,(get-y point) ,(get-z point)))

118
(glisp:define-constant +postnet-bits+
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
    (make-array 10 :initial-contents '((t t nil nil nil) ;;0
                                       (nil nil nil t t) ;;1 
                                       (nil nil t nil t) ;;2 
                                       (nil nil t t nil) ;;3
                                       (nil t nil nil t) ;;4 
                                       (nil t nil t nil) ;;5
                                       (nil t t nil nil) ;;6
                                       (t nil nil nil t) ;;7
                                       (t nil nil t nil) ;;8
                                       (t nil t nil nil)))
  
  "[Constant] 2D Array of Boolean. Represents the encodings used by the US Post Office Postnet barcoding system.
this will be included and documented in a future version of the GDL PDF output format.")

(defparameter *hash-transforms?* t
  "Boolean. Controls whether the transformations of points from three-dimensional world coordinates
to two-dimensional display coordinates are cached in memory. Set this to NIL to save memory at the
expense of some execution speed. <i>Note: in the current GDL release, transform caching is temporarily
disabled, so this parameter will have no effect.</i> Defaults to T.")


(defparameter *view-transform-inverses-hash* (make-hash-table :test #'equalp))

;;
;; used as dynamically bound variable in obj format and maybe other
;; formats which have to keep track of vertex counts.
;;
(defparameter *vertex-count* nil)



150
(glisp:define-constant +identity-3x3+ 
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
    (make-array (list 3 3)
                :initial-contents '((1d0 0d0 0d0)
                                    (0d0 1d0 0d0)
                                    (0d0 0d0 1d0))))


(defparameter *zero-vector-checking?* t 
  "Boolean. Indicates whether GDL should perform checks for zero-length vectors 
where nonzero-length vectors are expected. Defaults to T. Setting to NIL will 
increase execution speed marginally, at the cost of decreased safety. Modify 
the value of this parameter at your own risk.")


(defparameter *break-leaders?* t "Boolean. Indicates whether to try making a gap in dimension leaders for the text block. Defaults to t.")

(defparameter *dxf-translation* (make-vector 0 0))
(defparameter *raphael-translation* (make-vector 0 0))
168 169
(glisp:define-constant +rear-vector+ (make-vector 0 1 0))
(glisp:define-constant +top-vector+ (make-vector 0 0 1))
170

171
(defparameter +lh-identity-matrix+ #2A((1.0 0.0 0.0)(0.0 -1.0 0.0)(0.0 0.0 1.0)))
172