
(/VERSIONCHECK 2) 

(DEFUN |EXP3D;faceIndex| (|subSp| $)
  (PROG (|faceIndexList| #1=#:G1815 |poly|)
    (RETURN
     (SEQ (LETT |faceIndexList| NIL . #2=(|EXP3D;faceIndex|))
          (SEQ (LETT |poly| NIL . #2#)
               (LETT #1# (SPADCALL |subSp| (QREFELT $ 8)) . #2#) G190
               (COND
                ((OR (ATOM #1#) (PROGN (LETT |poly| (CAR #1#) . #2#) NIL))
                 (GO G191)))
               (SEQ
                (EXIT
                 (LETT |faceIndexList|
                       (CONS (SPADCALL |poly| (QREFELT $ 10)) |faceIndexList|)
                       . #2#)))
               (LETT #1# (CDR #1#) . #2#) (GO G190) G191 (EXIT NIL))
          (EXIT (REVERSE |faceIndexList|)))))) 

(DEFUN |EXP3D;writePolygon| (|f1| |curves| $)
  (PROG (|s| #1=#:G1823 |i| |faceIndexList| #2=#:G1822 |curve|)
    (RETURN
     (SEQ (LETT |faceIndexList| NIL . #3=(|EXP3D;writePolygon|))
          (SEQ (LETT |curve| NIL . #3#) (LETT #2# |curves| . #3#) G190
               (COND
                ((OR (ATOM #2#) (PROGN (LETT |curve| (CAR #2#) . #3#) NIL))
                 (GO G191)))
               (SEQ
                (EXIT
                 (LETT |faceIndexList|
                       (APPEND |faceIndexList| (|EXP3D;faceIndex| |curve| $))
                       . #3#)))
               (LETT #2# (CDR #2#) . #3#) (GO G190) G191 (EXIT NIL))
          (LETT |s| "f " . #3#)
          (SEQ (LETT |i| NIL . #3#) (LETT #1# |faceIndexList| . #3#) G190
               (COND
                ((OR (ATOM #1#) (PROGN (LETT |i| (CAR #1#) . #3#) NIL))
                 (GO G191)))
               (SEQ (LETT |s| (STRCONC |s| (STRINGIMAGE |i|)) . #3#)
                    (EXIT (LETT |s| (STRCONC |s| " ") . #3#)))
               (LETT #1# (CDR #1#) . #3#) (GO G190) G191 (EXIT NIL))
          (EXIT (SPADCALL |f1| |s| (QREFELT $ 13))))))) 

(DEFUN |EXP3D;writeMesh| (|f1| |curves| $)
  (PROG (|s| #1=#:G1842 |j| #2=#:G1841 |i| |colLength| |rowLength|
         |meshIndexArray| #3=#:G1840 |curve|)
    (RETURN
     (SEQ (LETT |meshIndexArray| NIL . #4=(|EXP3D;writeMesh|))
          (SEQ (LETT |curve| NIL . #4#) (LETT #3# |curves| . #4#) G190
               (COND
                ((OR (ATOM #3#) (PROGN (LETT |curve| (CAR #3#) . #4#) NIL))
                 (GO G191)))
               (SEQ
                (EXIT
                 (LETT |meshIndexArray|
                       (CONS (|EXP3D;faceIndex| |curve| $) |meshIndexArray|)
                       . #4#)))
               (LETT #3# (CDR #3#) . #4#) (GO G190) G191 (EXIT NIL))
          (LETT |meshIndexArray| (REVERSE |meshIndexArray|) . #4#)
          (LETT |rowLength| (LENGTH |meshIndexArray|) . #4#)
          (LETT |colLength|
                (SPADCALL (SPADCALL |meshIndexArray| 1 (QREFELT $ 17))
                          (QREFELT $ 18))
                . #4#)
          (EXIT
           (SEQ (LETT |i| 1 . #4#) (LETT #2# (- |rowLength| 1) . #4#) G190
                (COND ((QSGREATERP |i| #2#) (GO G191)))
                (SEQ
                 (EXIT
                  (SEQ (LETT |j| 1 . #4#) (LETT #1# (- |colLength| 1) . #4#)
                       G190 (COND ((QSGREATERP |j| #1#) (GO G191)))
                       (SEQ
                        (LETT |s|
                              (SPADCALL
                               (LIST "f "
                                     (STRINGIMAGE
                                      (SPADCALL
                                       (SPADCALL |meshIndexArray| |i|
                                                 (QREFELT $ 17))
                                       |j| (QREFELT $ 19)))
                                     " "
                                     (STRINGIMAGE
                                      (SPADCALL
                                       (SPADCALL |meshIndexArray| (+ |i| 1)
                                                 (QREFELT $ 17))
                                       |j| (QREFELT $ 19)))
                                     " "
                                     (STRINGIMAGE
                                      (SPADCALL
                                       (SPADCALL |meshIndexArray| (+ |i| 1)
                                                 (QREFELT $ 17))
                                       (+ |j| 1) (QREFELT $ 19)))
                                     " "
                                     (STRINGIMAGE
                                      (SPADCALL
                                       (SPADCALL |meshIndexArray| |i|
                                                 (QREFELT $ 17))
                                       (+ |j| 1) (QREFELT $ 19))))
                               (QREFELT $ 20))
                              . #4#)
                        (EXIT (SPADCALL |f1| |s| (QREFELT $ 13))))
                       (LETT |j| (QSADD1 |j|) . #4#) (GO G190) G191
                       (EXIT NIL))))
                (LETT |i| (QSADD1 |i|) . #4#) (GO G190) G191 (EXIT NIL))))))) 

(DEFUN |EXP3D;toString| (|d| $)
  (SPADCALL (SPADCALL |d| (QREFELT $ 23)) (QREFELT $ 24))) 

(DEFUN |EXP3D;writeObj;SsSV;5| (|subSp| |filename| $)
  (PROG (|curves| #1=#:G1854 |component| #2=#:G1853 |v| |verts| |f1|)
    (RETURN
     (SEQ
      (LETT |f1|
            (SPADCALL (SPADCALL |filename| (QREFELT $ 26)) "output"
                      (QREFELT $ 27))
            . #3=(|EXP3D;writeObj;SsSV;5|))
      (SPADCALL |f1| "# mesh generated by axiom" (QREFELT $ 13))
      (LETT |verts| (SPADCALL |subSp| (QREFELT $ 29)) . #3#)
      (SEQ (LETT |v| NIL . #3#) (LETT #2# |verts| . #3#) G190
           (COND
            ((OR (ATOM #2#) (PROGN (LETT |v| (CAR #2#) . #3#) NIL)) (GO G191)))
           (SEQ
            (EXIT
             (COND
              ((< (SPADCALL |v| (QREFELT $ 31)) 3)
               (|error| "Can't write OBJ file from 2D points"))
              ('T
               (SPADCALL |f1|
                         (SPADCALL
                          (LIST "v "
                                (|EXP3D;toString|
                                 (SPADCALL |v| 1 (QREFELT $ 32)) $)
                                " "
                                (|EXP3D;toString|
                                 (SPADCALL |v| 2 (QREFELT $ 32)) $)
                                " "
                                (|EXP3D;toString|
                                 (SPADCALL |v| 3 (QREFELT $ 32)) $))
                          (QREFELT $ 20))
                         (QREFELT $ 13))))))
           (LETT #2# (CDR #2#) . #3#) (GO G190) G191 (EXIT NIL))
      (SEQ (LETT |component| NIL . #3#)
           (LETT #1# (SPADCALL |subSp| (QREFELT $ 8)) . #3#) G190
           (COND
            ((OR (ATOM #1#) (PROGN (LETT |component| (CAR #1#) . #3#) NIL))
             (GO G191)))
           (SEQ (LETT |curves| (SPADCALL |component| (QREFELT $ 8)) . #3#)
                (COND
                 ((< (LENGTH |curves|) 2)
                  (|sayTeX| "Can't write point or curve to OBJ file")))
                (EXIT
                 (COND
                  ((SPADCALL (LENGTH |curves|) 1 (QREFELT $ 34))
                   (SEQ
                    (COND
                     ((EQL
                       (SPADCALL (SPADCALL |curves| 1 (QREFELT $ 36))
                                 (QREFELT $ 37))
                       1)
                      (|EXP3D;writePolygon| |f1| |curves| $)))
                    (EXIT
                     (COND
                      ((SPADCALL
                        (SPADCALL (SPADCALL |curves| 1 (QREFELT $ 36))
                                  (QREFELT $ 37))
                        1 (QREFELT $ 34))
                       (|EXP3D;writeMesh| |f1| |curves| $)))))))))
           (LETT #1# (CDR #1#) . #3#) (GO G190) G191 (EXIT NIL))
      (EXIT (SPADCALL |f1| (QREFELT $ 38))))))) 

(DEFUN |Export3D| #1=()
  (PROG #1#
    (RETURN
     (PROG (#2=#:G1856)
       (RETURN
        (COND
         ((LETT #2# (HGET |$ConstructorCache| '|Export3D|) . #3=(|Export3D|))
          (|CDRwithIncrement| (CDAR #2#)))
         ('T
          (UNWIND-PROTECT
              (PROG1
                  (CDDAR
                   (HPUT |$ConstructorCache| '|Export3D|
                         (LIST (CONS NIL (CONS 1 (|Export3D;|))))))
                (LETT #2# T . #3#))
            (COND ((NOT #2#) (HREM |$ConstructorCache| '|Export3D|))))))))))) 

(DEFUN |Export3D;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|Export3D|) . #1=(|Export3D|))
      (LETT $ (GETREFV 41) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|Export3D| NIL (CONS 1 $))
      (|stuffDomainSlots| $)
      (SETF |pv$| (QREFELT $ 3))
      $)))) 

(MAKEPROP '|Export3D| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|List| $) (|SubSpace| '3 22)
              (0 . |children|) (|NonNegativeInteger|) (5 . |extractIndex|)
              (|String|) (|TextFile|) (10 . |writeLine!|) (|List| 9)
              (|Integer|) (|List| 14) (16 . |elt|) (22 . |#|) (27 . |elt|)
              (33 . |concat|) (|InputForm|) (|DoubleFloat|) (38 . |convert|)
              (43 . |unparse|) (|FileName|) (48 . |coerce|) (53 . |open|)
              (|List| 30) (59 . |pointData|) (|Point| 22) (64 . |#|)
              (69 . |elt|) (|Boolean|) (75 . >) (|List| 7) (81 . |elt|)
              (87 . |numberOfChildren|) (92 . |close!|) (|Void|)
              |EXP3D;writeObj;SsSV;5|)
           '#(|writeObj| 97) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 40
                                                 '(1 7 6 0 8 1 7 9 0 10 2 12 11
                                                   0 11 13 2 16 14 0 15 17 1 14
                                                   9 0 18 2 14 9 0 15 19 1 11 0
                                                   6 20 1 22 21 0 23 1 21 11 0
                                                   24 1 25 0 11 26 2 12 0 25 11
                                                   27 1 7 28 0 29 1 30 9 0 31 2
                                                   30 22 0 15 32 2 9 33 0 0 34
                                                   2 35 7 0 15 36 1 7 9 0 37 1
                                                   12 0 0 38 2 0 39 7 11
                                                   40)))))
           '|lookupComplete|)) 

(MAKEPROP '|Export3D| 'NILADIC T) 
