diff options
Diffstat (limited to 'Build/source/utils')
136 files changed, 12601 insertions, 3674 deletions
diff --git a/Build/source/utils/README b/Build/source/utils/README index 2b697e5410c..68cd3657391 100644 --- a/Build/source/utils/README +++ b/Build/source/utils/README @@ -4,7 +4,7 @@ Public domain. Originally written 2005 by Karl Berry. Extra utilities we (optionally) compile for TeX Live. See comments in ../texk/README. -asymptote 1.94 - checked 9may10 +asymptote 1.96 - checked 8jun10 update to TL from CTAN, to include prebuilt doc. see http://tug.org/texlive/build.html#asymptote and tlpkg/bin/tl-update-asy diff --git a/Build/source/utils/asymptote/ChangeLog b/Build/source/utils/asymptote/ChangeLog index 8fc2ecbac2c..4d1fba7e7ed 100644 --- a/Build/source/utils/asymptote/ChangeLog +++ b/Build/source/utils/asymptote/ChangeLog @@ -1,4 +1,631 @@ ------------------------------------------------------------------------ +r4964 | jcbowman | 2010-06-06 08:19:42 -0600 (Sun, 06 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/algebra3.cc + M /trunk/asymptote/algebra3.h + M /trunk/asymptote/fftw++.cc + M /trunk/asymptote/fftw++.h + M /trunk/asymptote/glrender.cc + M /trunk/asymptote/prc/oPRCFile.cc + M /trunk/asymptote/prc/writePRC.h + M /trunk/asymptote/quaternion.cc + M /trunk/asymptote/tr.cc + +Remove M_PI. + +------------------------------------------------------------------------ +r4963 | jcbowman | 2010-06-06 07:40:50 -0600 (Sun, 06 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/examples/100d.views + M /trunk/asymptote/examples/BezierSurface.asy + M /trunk/asymptote/examples/pdb.asy + +Update viewpoint, views, and examples. + +------------------------------------------------------------------------ +r4962 | jcbowman | 2010-06-05 19:23:09 -0600 (Sat, 05 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/configure.ac + +Increment version to 1.96svn. +------------------------------------------------------------------------ +r4961 | jcbowman | 2010-06-05 17:20:23 -0600 (Sat, 05 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/algebra3.h + M /trunk/asymptote/prc/writePRC.h + M /trunk/asymptote/tr.cc + +Define M_PI. +------------------------------------------------------------------------ +r4960 | jcbowman | 2010-06-05 11:20:07 -0600 (Sat, 05 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/bezulate.asy + M /trunk/asymptote/base/embed.asy + M /trunk/asymptote/base/geometry.asy + M /trunk/asymptote/base/graph3.asy + M /trunk/asymptote/base/labelpath3.asy + M /trunk/asymptote/base/lmfit.asy + M /trunk/asymptote/base/plain_arrows.asy + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/base/three_tube.asy + M /trunk/asymptote/doc/asymptote.texi + M /trunk/asymptote/fftw++.h + +Reformat. + +------------------------------------------------------------------------ +r4959 | jcbowman | 2010-06-05 10:25:26 -0600 (Sat, 05 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/graph3.asy + M /trunk/asymptote/base/solids.asy + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/base/three_tube.asy + M /trunk/asymptote/doc/asymptote.texi + M /trunk/asymptote/doc/latexusage.tex + M /trunk/asymptote/drawsurface.h + M /trunk/asymptote/examples/NURBSsphere.asy + M /trunk/asymptote/examples/sphere.asy + M /trunk/asymptote/runpicture.in + +Improve interace to render options. + +------------------------------------------------------------------------ +r4958 | jcbowman | 2010-06-05 02:12:43 -0600 (Sat, 05 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_tube.asy + +Remove tubesectors; simplify tube construction. + +------------------------------------------------------------------------ +r4957 | jcbowman | 2010-06-05 01:46:06 -0600 (Sat, 05 Jun 2010) | 10 lines +Changed paths: + M /trunk/asymptote/base/graph3.asy + M /trunk/asymptote/base/solids.asy + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/base/three_tube.asy + M /trunk/asymptote/drawgroup.h + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/examples/pipeintersection.asy + M /trunk/asymptote/runpicture.in + +Implement render structure containing PRC rendering parameters. + +Use begingroup3/endgroup3 consistently for both 3D pictures and frames, +respective default rendering parameters. + +Add render(merge=true) to pipeintersection.asy to improve rendering speed. + +Improve PRC line capping. Use spheres for curved joints and roundcap. +Use a higher resolution disk for squarecap/extendcap. + +------------------------------------------------------------------------ +r4956 | jcbowman | 2010-06-04 21:41:47 -0600 (Fri, 04 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/glrender.cc + +Fix zoom. + +------------------------------------------------------------------------ +r4955 | jcbowman | 2010-06-04 16:46:49 -0600 (Fri, 04 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/drawgroup.h + M /trunk/asymptote/examples/pipeintersection.asy + M /trunk/asymptote/prc/oPRCFile.cc + M /trunk/asymptote/prc/oPRCFile.h + M /trunk/asymptote/prc/writePRC.cc + M /trunk/asymptote/prc/writePRC.h + M /trunk/asymptote/runpicture.in + +Expose granularity. +------------------------------------------------------------------------ +r4954 | jcbowman | 2010-06-04 14:53:45 -0600 (Fri, 04 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/base/three_arrows.asy + +Remove linesectors. +------------------------------------------------------------------------ +r4953 | jcbowman | 2010-06-04 14:52:15 -0600 (Fri, 04 Jun 2010) | 4 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_tube.asy + +Implement Circular spline type corresponding to Bezier unitcircle approximation. + +Rename linesectors to tubesectors and change default value to 4. + +------------------------------------------------------------------------ +r4952 | jcbowman | 2010-06-04 12:58:16 -0600 (Fri, 04 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/graph3.asy + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/base/three_tube.asy + +Optimize tube spline routines. + +------------------------------------------------------------------------ +r4951 | jcbowman | 2010-06-04 01:35:59 -0600 (Fri, 04 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/graph3.asy + M /trunk/asymptote/base/math.asy + M /trunk/asymptote/base/solids.asy + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/drawelement.h + M /trunk/asymptote/drawgroup.h + M /trunk/asymptote/drawpath3.cc + M /trunk/asymptote/drawpath3.h + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/drawsurface.h + M /trunk/asymptote/picture.cc + M /trunk/asymptote/picture.h + +Improve group naming. + +------------------------------------------------------------------------ +r4950 | hammera | 2010-06-02 19:51:22 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/Makefile.in + M /trunk/asymptote/builtin.cc + A /trunk/asymptote/findsym.pl + M /trunk/asymptote/opsymbols.pl + M /trunk/asymptote/runtime.pl + M /trunk/asymptote/symbol.cc + M /trunk/asymptote/types.cc + +Added pre-translation of runtime symbols. + +------------------------------------------------------------------------ +r4949 | hammera | 2010-06-02 15:53:23 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/Makefile.in + M /trunk/asymptote/runtime.pl + M /trunk/asymptote/runtimebase.in + +Use pre-translated operator symbols in runtime files. + +------------------------------------------------------------------------ +r4948 | hammera | 2010-06-02 15:38:52 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/builtin.cc + +Use pre-translated operator symbols in builtin.cc. + +------------------------------------------------------------------------ +r4947 | hammera | 2010-06-02 15:35:23 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/doc/asymptote.texi + +Added var documentation. + +------------------------------------------------------------------------ +r4946 | hammera | 2010-06-02 15:25:28 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/Makefile.in + M /trunk/asymptote/TODO + M /trunk/asymptote/builtin.cc + M /trunk/asymptote/builtin.h + M /trunk/asymptote/camp.l + A /trunk/asymptote/opsymbols.pl + M /trunk/asymptote/runtime.pl + M /trunk/asymptote/symbol.cc + M /trunk/asymptote/symbol.h + M /trunk/asymptote/types.cc + M /trunk/asymptote/types.h + +Pre-translate operator symbols. + +------------------------------------------------------------------------ +r4945 | hammera | 2010-06-02 15:23:49 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/errors + +Update errors for ambiguous cast to error. + +------------------------------------------------------------------------ +r4944 | hammera | 2010-06-02 15:09:17 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/application.cc + M /trunk/asymptote/entry.cc + M /trunk/asymptote/entry.h + M /trunk/asymptote/env.h + M /trunk/asymptote/exp.cc + M /trunk/asymptote/exp.h + M /trunk/asymptote/fundec.cc + M /trunk/asymptote/name.cc + M /trunk/asymptote/name.h + M /trunk/asymptote/newexp.cc + M /trunk/asymptote/newexp.h + +Added a (disabled) experimental function resolution optimization. + +------------------------------------------------------------------------ +r4943 | jcbowman | 2010-06-02 13:48:16 -0600 (Wed, 02 Jun 2010) | 6 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_tube.asy + M /trunk/asymptote/doc/join3.asy + M /trunk/asymptote/drawsurface.cc + +Improve 3D line capping. + +Improve tube center calculation. + +Remove PRCtube setting. + +------------------------------------------------------------------------ +r4942 | jcbowman | 2010-06-02 09:59:36 -0600 (Wed, 02 Jun 2010) | 5 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_tube.asy + +Use half sphere for PRC tube connectors. + +Revert to NURBSsphere again now that the rendering problems have been fixed +(by using a nonzero granularity). + +------------------------------------------------------------------------ +r4941 | jcbowman | 2010-06-02 02:51:24 -0600 (Wed, 02 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/runpicture.in + +Complete last revision. +------------------------------------------------------------------------ +r4940 | jcbowman | 2010-06-02 02:45:37 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/drawgroup.h + M /trunk/asymptote/prc/oPRCFile.h + M /trunk/asymptote/runpicture.in + +Expose PRCoptions via begingroup. + +------------------------------------------------------------------------ +r4939 | jcbowman | 2010-06-02 01:39:39 -0600 (Wed, 02 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/prc/writePRC.cc + +Reduce PDF loading time without sacrificing quality by setting granularity=1.0. + +------------------------------------------------------------------------ +r4938 | jcbowman | 2010-06-02 01:38:18 -0600 (Wed, 02 Jun 2010) | 10 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/base/three_tube.asy + M /trunk/asymptote/drawpath3.cc + M /trunk/asymptote/drawpath3.h + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/drawsurface.h + M /trunk/asymptote/runpicture.in + +Make PRCsphere the default until numerical transform issues with NURBSsphere +are resolved. + +Add half=false option to PRCsphere. + +Implement PRCcylinder, PRCdisk, and PRCtube primitives. + +Use PRC primitives for drawing thick lines. PRC tubes (which may contain +cracks) are drawn for curved lines only if PRCtube=true (the default). + +------------------------------------------------------------------------ +r4937 | jcbowman | 2010-06-01 14:12:34 -0600 (Tue, 01 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/errors + +Update errors. +------------------------------------------------------------------------ +r4936 | jcbowman | 2010-06-01 14:04:40 -0600 (Tue, 01 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/prc/oPRCFile.cc + +Simplify code. +------------------------------------------------------------------------ +r4935 | hammera | 2010-06-01 11:39:32 -0600 (Tue, 01 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/tests/types/resolve.asy + +Added more overloading resolution tests. + +------------------------------------------------------------------------ +r4934 | hammera | 2010-06-01 11:30:59 -0600 (Tue, 01 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/dec.cc + M /trunk/asymptote/errors + M /trunk/asymptote/errortest.asy + M /trunk/asymptote/primitives.h + A /trunk/asymptote/tests/types/var.asy + +Added experimental inferred variable types. + +------------------------------------------------------------------------ +r4933 | jcbowman | 2010-06-01 01:59:35 -0600 (Tue, 01 Jun 2010) | 4 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_light.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/drawelement.h + M /trunk/asymptote/drawgroup.h + M /trunk/asymptote/drawpath3.cc + M /trunk/asymptote/drawpath3.h + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/drawsurface.h + M /trunk/asymptote/examples/Klein.asy + M /trunk/asymptote/picture.cc + M /trunk/asymptote/prc/oPRCFile.cc + M /trunk/asymptote/prc/oPRCFile.h + M /trunk/asymptote/prc/test.cc + M /trunk/asymptote/prc/writePRC.cc + M /trunk/asymptote/prc/writePRC.h + M /trunk/asymptote/runpicture.in + +Fix grouping. + +Make part names and compression group properties. + +------------------------------------------------------------------------ +r4932 | jcbowman | 2010-05-31 14:28:30 -0600 (Mon, 31 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/prc/oPRCFile.cc + M /trunk/asymptote/prc/oPRCFile.h + +Remove context list. +------------------------------------------------------------------------ +r4931 | jcbowman | 2010-05-30 21:07:52 -0600 (Sun, 30 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/asymptote.nsi + +Disable 384MB Cygwin memory limit. +------------------------------------------------------------------------ +r4930 | jcbowman | 2010-05-30 02:17:21 -0600 (Sun, 30 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/drawelement.h + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/drawsurface.h + M /trunk/asymptote/runpicture.in + +Implement optimized PRCsphere and NURBsphere. + +------------------------------------------------------------------------ +r4929 | jcbowman | 2010-05-29 21:39:38 -0600 (Sat, 29 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/pipestream.h + +Replace SIGQUIT by SIGTERM. + +------------------------------------------------------------------------ +r4928 | jcbowman | 2010-05-22 22:24:32 -0600 (Sat, 22 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/drawsurface.cc + +Fix invalid memory access. +------------------------------------------------------------------------ +r4927 | jcbowman | 2010-05-19 23:48:25 -0600 (Wed, 19 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/examples/teapot.asy + +Fix example. +------------------------------------------------------------------------ +r4926 | jcbowman | 2010-05-19 22:00:44 -0600 (Wed, 19 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_light.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/doc/cube.asy + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/drawsurface.h + M /trunk/asymptote/examples/parametricsurface.asy + M /trunk/asymptote/examples/pdb.asy + M /trunk/asymptote/examples/teapot.asy + M /trunk/asymptote/prc/oPRCFile.cc + M /trunk/asymptote/prc/oPRCFile.h + M /trunk/asymptote/prc/test.cc + M /trunk/asymptote/prc/writePRC.cc + M /trunk/asymptote/prc/writePRC.h + M /trunk/asymptote/runpicture.in + +Remove granularity setting. + +------------------------------------------------------------------------ +r4925 | jcbowman | 2010-05-19 13:23:56 -0600 (Wed, 19 May 2010) | 4 lines +Changed paths: + M /trunk/asymptote/arrayop.h + M /trunk/asymptote/base/math.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/doc/asymptote.texi + +Prune duplicate 3D dots. + +Implement new functions unique and lexorder in math.asy. + +------------------------------------------------------------------------ +r4924 | jcbowman | 2010-05-18 12:35:45 -0600 (Tue, 18 May 2010) | 2 lines +Changed paths: + A /trunk/asymptote/prc/test.asy + +Add embedder for PRC test. + +------------------------------------------------------------------------ +r4923 | jcbowman | 2010-05-18 12:30:07 -0600 (Tue, 18 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/Makefile.in + M /trunk/asymptote/prc/Makefile + +Fix prc dependency. + +------------------------------------------------------------------------ +r4922 | jcbowman | 2010-05-18 10:48:08 -0600 (Tue, 18 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/prc/writePRC.cc + M /trunk/asymptote/prc/writePRC.h + +Remove debugging comments. +------------------------------------------------------------------------ +r4921 | jcbowman | 2010-05-17 22:53:48 -0600 (Mon, 17 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/drawsurface.cc + +Fix compression limit. + +------------------------------------------------------------------------ +r4920 | jcbowman | 2010-05-17 10:47:00 -0600 (Mon, 17 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/GUI/xasyMainWin.py + M /trunk/asymptote/doc/asymptote.texi + +Update URLs. +------------------------------------------------------------------------ +r4919 | jcbowman | 2010-05-17 08:55:40 -0600 (Mon, 17 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/prc/oPRCFile.cc + +Use Adobe compression factor. + +------------------------------------------------------------------------ +r4918 | jcbowman | 2010-05-17 00:46:27 -0600 (Mon, 17 May 2010) | 3 lines +Changed paths: + M /trunk/asymptote/base/graph3.asy + M /trunk/asymptote/base/plain_picture.asy + M /trunk/asymptote/base/solids.asy + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/examples/Klein.asy + +Distinguish again between the 3D begingroup3/endgroup3 and the 2D +begingroup/endgroup pairs. + +------------------------------------------------------------------------ +r4917 | jcbowman | 2010-05-16 23:52:15 -0600 (Sun, 16 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/doc/latexusage.tex + +Update hyperref comment. +------------------------------------------------------------------------ +r4916 | jcbowman | 2010-05-16 21:33:37 -0600 (Sun, 16 May 2010) | 3 lines +Changed paths: + M /trunk/asymptote/doc/latexusage.tex + +Add example of using rendermargin to avoid rendering residue in included 3D +images. + +------------------------------------------------------------------------ +r4915 | jcbowman | 2010-05-16 19:11:42 -0600 (Sun, 16 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + +Adjust default tubegranularity; remove spurious line. + +------------------------------------------------------------------------ +r4914 | jcbowman | 2010-05-16 17:52:09 -0600 (Sun, 16 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_tube.asy + +Use a reduced tubegranularity for constructing tubes. + +------------------------------------------------------------------------ +r4913 | jcbowman | 2010-05-16 17:24:07 -0600 (Sun, 16 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/prc/writePRC.cc + +Fix floating point exception in PRC compression routines. + +------------------------------------------------------------------------ +r4912 | jcbowman | 2010-05-16 02:50:12 -0600 (Sun, 16 May 2010) | 3 lines +Changed paths: + M /trunk/asymptote/base/graph3.asy + M /trunk/asymptote/base/plain_picture.asy + M /trunk/asymptote/base/solids.asy + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_light.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/drawelement.h + M /trunk/asymptote/drawgroup.h + M /trunk/asymptote/drawpath3.cc + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/drawsurface.h + M /trunk/asymptote/examples/Klein.asy + A /trunk/asymptote/examples/label3zoom.asy + M /trunk/asymptote/prc/PRC.h + M /trunk/asymptote/prc/PRCdouble.h + M /trunk/asymptote/prc/oPRCFile.cc + M /trunk/asymptote/prc/oPRCFile.h + M /trunk/asymptote/prc/test.cc + M /trunk/asymptote/prc/writePRC.cc + M /trunk/asymptote/prc/writePRC.h + M /trunk/asymptote/prcfile.h + M /trunk/asymptote/runpicture.in + +Add some of Michail's PRC enhancements, including lossy compression of +surfaces. + +------------------------------------------------------------------------ +r4911 | jcbowman | 2010-05-13 21:03:06 -0600 (Thu, 13 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/fftw++.h + +Fix portability issue. +------------------------------------------------------------------------ +r4910 | jcbowman | 2010-05-13 12:46:21 -0600 (Thu, 13 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/memory.h + +Remove space. +------------------------------------------------------------------------ +r4909 | jcbowman | 2010-05-12 23:17:46 -0600 (Wed, 12 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/doc/asymptote.texi + M /trunk/asymptote/texfile.cc + +Only quote filenames where necessary (e.g. to support obsolete versions of asymptote.sty). + +------------------------------------------------------------------------ +r4908 | jcbowman | 2010-05-12 11:31:23 -0600 (Wed, 12 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/runmath.in + +Always use 256 bytes for random state array. +------------------------------------------------------------------------ +r4907 | jcbowman | 2010-05-08 23:17:36 -0600 (Sat, 08 May 2010) | 2 lines +Changed paths: + D /trunk/asymptote/Compile + M /trunk/asymptote/asymptote.spec + +Remove unused file. + +------------------------------------------------------------------------ +r4906 | jcbowman | 2010-05-07 14:32:28 -0600 (Fri, 07 May 2010) | 2 lines +Changed paths: + M /trunk/asymptote/fftw++.cc + M /trunk/asymptote/fftw++.h + M /trunk/asymptote/runarray.in + +Use fftwpp namespace. + +------------------------------------------------------------------------ +r4905 | jcbowman | 2010-05-07 00:43:32 -0600 (Fri, 07 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/fftw++.h + +Update fftw++.h to v1.06. +------------------------------------------------------------------------ +r4904 | jcbowman | 2010-05-04 16:53:28 -0600 (Tue, 04 May 2010) | 1 line +Changed paths: + M /trunk/asymptote/configure.ac + +Increment version to 1.95svn. +------------------------------------------------------------------------ r4903 | jcbowman | 2010-05-04 14:47:23 -0600 (Tue, 04 May 2010) | 2 lines Changed paths: M /trunk/asymptote/settings.cc diff --git a/Build/source/utils/asymptote/Compile b/Build/source/utils/asymptote/Compile deleted file mode 100644 index e7a9e237a4d..00000000000 --- a/Build/source/utils/asymptote/Compile +++ /dev/null @@ -1,10 +0,0 @@ -MAGIC=magic # Hide asy rule from Makefile. -include Makefile - -asy: $(FILES:=.o) - $(CXX) $(OPTS) -o $(NAME) $(FILES:=.o) $(LIBS) - -msdos: $(FILES:=.o) asy.o - $(CXX) $(OPTS) -o $(NAME) $(FILES:=.o) asy.o $(LIBS) - -include $(FILES:=.d) diff --git a/Build/source/utils/asymptote/GUI/xasyMainWin.py b/Build/source/utils/asymptote/GUI/xasyMainWin.py index 95dd4fb7cbc..2876d014a56 100755 --- a/Build/source/utils/asymptote/GUI/xasyMainWin.py +++ b/Build/source/utils/asymptote/GUI/xasyMainWin.py @@ -57,9 +57,9 @@ class xasyMainWin: self.createWidgets() self.resetGUI() if sys.platform[:3] == "win": - site="http://effbot.org/downloads/PIL-1.1.7b1.win32-py2.6.exe" + site="http://effbot.org/downloads/PIL-1.1.7.win32-py2.6.exe" else: - site="http://effbot.org/downloads/Imaging-1.1.7b1.tar.gz" + site="http://effbot.org/downloads/Imaging-1.1.7.tar.gz" if not PILAvailable: tkMessageBox.showerror("Failed Dependencies","An error occurred loading the required PIL library. Please install "+site) self.parent.destroy() diff --git a/Build/source/utils/asymptote/Makefile.in b/Build/source/utils/asymptote/Makefile.in index 5da2b48b6d3..92b9e0bdbff 100644 --- a/Build/source/utils/asymptote/Makefile.in +++ b/Build/source/utils/asymptote/Makefile.in @@ -11,6 +11,8 @@ GCLIBS = $(GCPPLIB) $(GCLIB) LFLAGS = @LDFLAGS@ LIBS = $(LFLAGS) @LIBS@ $(GCLIBS) +vpath %.cc prc + CAMP = camperror path drawpath drawlabel picture psfile texfile util settings \ guide flatguide knot drawfill path3 drawpath3 drawsurface @@ -18,7 +20,10 @@ RUNTIME_FILES = runtime runbacktrace runpicture runlabel runhistory runarray \ runfile runsystem runpair runtriple runpath runpath3d runstring \ runmath -PRC = prc/PRCbitStream prc/oPRCFile prc/PRCdouble prc/writePRC +# Files to be scanned for pre-translated symbols defined by SYM(name). +SYMBOL_FILES = types builtin $(RUNTIME_FILES) + +PRC = PRCbitStream oPRCFile PRCdouble writePRC FILES = $(CAMP) $(RUNTIME_FILES) env genv main stm dec errormsg \ callable name symbol types entry exp newexp stack camp.tab lex.yy \ @@ -41,8 +46,8 @@ LATEXFILES = asymptote.sty asycolors.sty ocg.sty CONTEXTFILES = colo-asy.tex ASY = ./asy -dir base -config "" -render=0 -DEFS = @DEFS@ @OPTIONS@ -CFLAGS = @CPPFLAGS@ @CFLAGS@ +DEFS = @DEFS@ @OPTIONS@ -DPRESYM +CFLAGS = @CPPFLAGS@ @CFLAGS@ OPTS = $(DEFS) $(CFLAGS) INCL = -I . @INCL@ @@ -73,7 +78,7 @@ last = `cat svnrevision.cc | sed -e 's/.*\"\(.*\)\";/\\1/'` export prefix docdir exampledir mandir infodir INSTALL MAKE DESTDIR TEXI2DVI -asy: $(GCLIB) $(FILES:=.o) prc +asy: $(GCLIB) $(FILES:=.o) if test "$(revision)" != "$(last)"; then \ echo $(REVISION)\"$(revision)\"\; > svnrevision.cc; \ $(CXX) $(OPTS) $(INCL) -o svnrevision.o -c svnrevision.cc; \ @@ -89,7 +94,7 @@ asy: $(GCLIB) $(FILES:=.o) prc svnrevision.cc: echo $(REVISION)\"\"\; > svnrevision.cc; -msdos: $(GCLIB) $(FILES:=.o) prc asy.o +msdos: $(GCLIB) $(FILES:=.o) asy.o echo string VERSION=\"@VERSION@\"\; > base/version.asy echo @set VERSION @VERSION@ > doc/version.texi echo @set Datadir @datadir@ >> doc/version.texi @@ -131,9 +136,19 @@ man: asy faq: asy cd doc && $(MAKE) faq -$(RUNTIME_FILES:=.cc): %.cc: runtime.pl runtimebase.in %.in +$(RUNTIME_FILES:=.cc): %.cc: runtime.pl opsymbols.h runtimebase.in %.in ./runtime.pl $(@:.cc=) +$(SYMBOL_FILES:=.symbols.h): %.symbols.h: findsym.pl %.cc + ./findsym.pl $@ $(@:.symbols.h=.cc) + +$(SYMBOL_FILES:=.o): %.o: %.symbols.h + +allsymbols.h: findsym.pl $(SYMBOL_FILES:=.cc) + ./findsym.pl $@ $(SYMBOL_FILES:=.cc) + +symbol.o: opsymbols.h allsymbols.h + camp.tab.cc: camp.y $(BISON) -dvt -b camp camp.y && mv camp.tab.c camp.tab.cc @@ -144,9 +159,12 @@ lex.yy.cc: camp.l lex.yy.d: $(GCLIB) lex.yy.cc camp.tab.h -keywords.cc: keywords.pl camp.l +keywords.cc: keywords.pl camp.l process.cc ./keywords.pl +opsymbols.h: opsymbols.pl camp.l + ./opsymbols.pl + envcompleter.d: keywords.cc asy-keywords.el: asy @@ -214,10 +232,7 @@ uninstall-asy: uninstall-man: cd doc && $(MAKE) uninstall -prc-clean: FORCE - -rm -f prc/*.o prc/*.d - -clean: FORCE prc-clean +clean: FORCE -rm -f asy *.o *.d *mon.out $(CLEAN) gc-clean: FORCE clean diff --git a/Build/source/utils/asymptote/ReleaseNotes b/Build/source/utils/asymptote/ReleaseNotes index 0ba45e48a1c..f06b4616c50 100644 --- a/Build/source/utils/asymptote/ReleaseNotes +++ b/Build/source/utils/asymptote/ReleaseNotes @@ -1,6 +1,20 @@ +Release Notes for Version 1.96 + +The viewpoint function and some examples were updated. + +Release Notes for Version 1.95 + +The PRC driver has been overhauled to support model tree groups, lossy +compression, efficient representations of elementary geometrical objects, +and specialized rendering options. More efficient OpenGL thick tubes were +implemented; the capping of 3D curves was improved. The SIGQUIT signal was +replaced by SIGTERM. Under MSWindows, the 384MB Cygwin memory limit is now +automatically disabled by the Asymptote installer. Inferred variable types +were added and operator symbols are now pretranslated. + Release Notes for Version 1.94 -Work arounds for MSWindows registry problems and obsolete runtime libraries +Workarounds for MSWindows registry problems and obsolete runtime libraries were implemented. The SimpleHead arrowhead was fixed. Additional matrix routines and casts were implemented. The pair dir(path, path) routine now returns a unit vector. Variable conflicts coming from the contour module @@ -1615,5 +1629,3 @@ the frame for filling with a background color; they also return the boundary as a guide. A workaround was added for a bug in gcc version 3.3 to facilitate compilation under Darwin (MacOS). Many internal coding improvements were made. - - LocalWords: arounds diff --git a/Build/source/utils/asymptote/TODO b/Build/source/utils/asymptote/TODO index aacbd1bb17d..bb9fec483a5 100644 --- a/Build/source/utils/asymptote/TODO +++ b/Build/source/utils/asymptote/TODO @@ -1,3 +1,15 @@ +Andy: possible optimizations: + only hash first 3 or 4 args of signature + hashify symbol table + rm transToType from varinitArg::trans + run a perfect match through multimatch first (no casting allowed) + STATIC_SYMBOL(name) define to avoid retranslating symbols in addOps + change camp.y to flag arglists with named args + remove addFunctionOps in favor of == and != defined in types.h + remove most makesymbols in camp.l + +Andy: operator tuple, to let people define their own tuples + Andy: implement operator init(A a) copy constructors. Andy and John: (if possible) automatically turn expressions with array diff --git a/Build/source/utils/asymptote/algebra3.cc b/Build/source/utils/asymptote/algebra3.cc index 7dafd2d5839..203b430c2ed 100644 --- a/Build/source/utils/asymptote/algebra3.cc +++ b/Build/source/utils/asymptote/algebra3.cc @@ -75,6 +75,8 @@ #include "algebra3.h" #include <cmath> +static const double radians=acos(-1)/180.0; + #ifdef VEC_ERROR_FATAL #ifndef VEC_ERROR #define VEC_ERROR(E) { printf( "VERROR %s\n", E ); exit(1); } @@ -1502,7 +1504,7 @@ mat3 translation2D(const vec2 &v) mat3 rotation2D(const vec2 &Center, float angleDeg) { - float angleRad = (float) (angleDeg * M_PI / 180.0); + float angleRad = (float) (angleDeg * radians); float c = (float) cos(angleRad); float s = (float) sin(angleRad); @@ -1540,7 +1542,7 @@ mat4 translation3D(const vec3 &v) mat4 rotation3D(const vec3 &Axis, float angleDeg) { - float angleRad = (float) (angleDeg * M_PI / 180.0); + float angleRad = (float) (angleDeg * radians); float c = (float) cos(angleRad); float s = (float) sin(angleRad); float t = 1.0f - c; diff --git a/Build/source/utils/asymptote/algebra3.h b/Build/source/utils/asymptote/algebra3.h index 0e6602c3cad..7043ff3c75f 100644 --- a/Build/source/utils/asymptote/algebra3.h +++ b/Build/source/utils/asymptote/algebra3.h @@ -86,8 +86,6 @@ #define MIN(a,b) ((a)<(b) ? (a) : (b)) #endif -#define DEG2RAD(x) ((x)/180.0*M_PI) -#define RAD2DEG(x) ((x)/M_PI*180.0) #define FUDGE .00001 // this line defines a new type: pointer to a function which returns a @@ -100,10 +98,6 @@ class vec4; class mat3; class mat4; -#ifndef M_PI -#define M_PI 3.141592654 -#endif - enum axes {VX, VY, VZ, VW}; /* enum planes {PA, PB, PC, PD}; diff --git a/Build/source/utils/asymptote/allsymbols.h b/Build/source/utils/asymptote/allsymbols.h new file mode 100644 index 00000000000..73e7564aa49 --- /dev/null +++ b/Build/source/utils/asymptote/allsymbols.h @@ -0,0 +1,685 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(AND); +ADDSYMBOL(Ai); +ADDSYMBOL(Ai_deriv); +ADDSYMBOL(Ai_deriv_scaled); +ADDSYMBOL(Ai_scaled); +ADDSYMBOL(Bi); +ADDSYMBOL(Bi_deriv); +ADDSYMBOL(Bi_deriv_scaled); +ADDSYMBOL(Bi_scaled); +ADDSYMBOL(CLZ); +ADDSYMBOL(CTZ); +ADDSYMBOL(Ceil); +ADDSYMBOL(Chi); +ADDSYMBOL(Ci); +ADDSYMBOL(Cos); +ADDSYMBOL(D); +ADDSYMBOL(Degrees); +ADDSYMBOL(E); +ADDSYMBOL(E1); +ADDSYMBOL(E2); +ADDSYMBOL(Ei); +ADDSYMBOL(Ei3); +ADDSYMBOL(En); +ADDSYMBOL(F); +ADDSYMBOL(FermiDirac); +ADDSYMBOL(FermiDirac0); +ADDSYMBOL(FermiDirac1); +ADDSYMBOL(FermiDirac2); +ADDSYMBOL(FermiDirac3Half); +ADDSYMBOL(FermiDiracHalf); +ADDSYMBOL(FermiDiracInc0); +ADDSYMBOL(FermiDiracM1); +ADDSYMBOL(FermiDiracMHalf); +ADDSYMBOL(Floor); +ADDSYMBOL(H3d); +ADDSYMBOL(H3d0); +ADDSYMBOL(H3d1); +ADDSYMBOL(I); +ADDSYMBOL(I0); +ADDSYMBOL(I0_scaled); +ADDSYMBOL(I1); +ADDSYMBOL(I1_scaled); +ADDSYMBOL(I_scaled); +ADDSYMBOL(J); +ADDSYMBOL(J0); +ADDSYMBOL(J1); +ADDSYMBOL(Jn); +ADDSYMBOL(K); +ADDSYMBOL(K0); +ADDSYMBOL(K0_scaled); +ADDSYMBOL(K1); +ADDSYMBOL(K1_scaled); +ADDSYMBOL(K_scaled); +ADDSYMBOL(L); +ADDSYMBOL(L1); +ADDSYMBOL(L2); +ADDSYMBOL(L3); +ADDSYMBOL(NOT); +ADDSYMBOL(OR); +ADDSYMBOL(P); +ADDSYMBOL(P1); +ADDSYMBOL(P2); +ADDSYMBOL(P3); +ADDSYMBOL(Pl); +ADDSYMBOL(Plm); +ADDSYMBOL(Q0); +ADDSYMBOL(Q1); +ADDSYMBOL(Ql); +ADDSYMBOL(RC); +ADDSYMBOL(RD); +ADDSYMBOL(RF); +ADDSYMBOL(RJ); +ADDSYMBOL(Round); +ADDSYMBOL(Shi); +ADDSYMBOL(Si); +ADDSYMBOL(Sin); +ADDSYMBOL(Tan); +ADDSYMBOL(U); +ADDSYMBOL(VERSION); +ADDSYMBOL(W0); +ADDSYMBOL(Wm1); +ADDSYMBOL(XOR); +ADDSYMBOL(Y); +ADDSYMBOL(Y0); +ADDSYMBOL(Y1); +ADDSYMBOL(Yn); +ADDSYMBOL(Z); +ADDSYMBOL(_begingroup3); +ADDSYMBOL(_cputime); +ADDSYMBOL(_draw); +ADDSYMBOL(_eval); +ADDSYMBOL(_image); +ADDSYMBOL(_labelpath); +ADDSYMBOL(_projection); +ADDSYMBOL(_strokepath); +ADDSYMBOL(_texpath); +ADDSYMBOL(a); +ADDSYMBOL(aCos); +ADDSYMBOL(aI); +ADDSYMBOL(aR); +ADDSYMBOL(aSin); +ADDSYMBOL(aTan); +ADDSYMBOL(abort); +ADDSYMBOL(abs); +ADDSYMBOL(acc); +ADDSYMBOL(accel); +ADDSYMBOL(acos); +ADDSYMBOL(acosh); +ADDSYMBOL(add); +ADDSYMBOL(adjust); +ADDSYMBOL(alias); +ADDSYMBOL(align); +ADDSYMBOL(all); +ADDSYMBOL(ambient); +ADDSYMBOL(angle); +ADDSYMBOL(animate); +ADDSYMBOL(antialias); +ADDSYMBOL(append); +ADDSYMBOL(arclength); +ADDSYMBOL(arctime); +ADDSYMBOL(args); +ADDSYMBOL(array); +ADDSYMBOL(asin); +ADDSYMBOL(asinh); +ADDSYMBOL(assert); +ADDSYMBOL(asydir); +ADDSYMBOL(atLeast); +ADDSYMBOL(atan); +ADDSYMBOL(atan2); +ADDSYMBOL(atanh); +ADDSYMBOL(atanint); +ADDSYMBOL(atbreakpoint); +ADDSYMBOL(atexit); +ADDSYMBOL(atleast); +ADDSYMBOL(atupdate); +ADDSYMBOL(axialshade); +ADDSYMBOL(azimuth); +ADDSYMBOL(b); +ADDSYMBOL(background); +ADDSYMBOL(basealign); +ADDSYMBOL(beginclip); +ADDSYMBOL(begingroup); +ADDSYMBOL(beta); +ADDSYMBOL(bezier); +ADDSYMBOL(bezierP); +ADDSYMBOL(bezierPP); +ADDSYMBOL(bezierPPP); +ADDSYMBOL(binput); +ADDSYMBOL(blend); +ADDSYMBOL(boutput); +ADDSYMBOL(breakpoint); +ADDSYMBOL(breakpoints); +ADDSYMBOL(byte); +ADDSYMBOL(c); +ADDSYMBOL(c0); +ADDSYMBOL(c1); +ADDSYMBOL(cbrt); +ADDSYMBOL(cd); +ADDSYMBOL(ceil); +ADDSYMBOL(center); +ADDSYMBOL(change2); +ADDSYMBOL(check); +ADDSYMBOL(choose); +ADDSYMBOL(clausen); +ADDSYMBOL(clear); +ADDSYMBOL(clip); +ADDSYMBOL(close); +ADDSYMBOL(closed); +ADDSYMBOL(cmyk); +ADDSYMBOL(colatitude); +ADDSYMBOL(colorless); +ADDSYMBOL(colors); +ADDSYMBOL(colorspace); +ADDSYMBOL(comment); +ADDSYMBOL(complement); +ADDSYMBOL(compression); +ADDSYMBOL(concat); +ADDSYMBOL(conicalP_0); +ADDSYMBOL(conicalP_1); +ADDSYMBOL(conicalP_cyl_reg); +ADDSYMBOL(conicalP_half); +ADDSYMBOL(conicalP_mhalf); +ADDSYMBOL(conicalP_sph_reg); +ADDSYMBOL(conj); +ADDSYMBOL(controlSpecifier); +ADDSYMBOL(convert); +ADDSYMBOL(copy); +ADDSYMBOL(cos); +ADDSYMBOL(cosh); +ADDSYMBOL(coupling_3j); +ADDSYMBOL(coupling_6j); +ADDSYMBOL(coupling_9j); +ADDSYMBOL(cross); +ADDSYMBOL(csv); +ADDSYMBOL(cubicroots); +ADDSYMBOL(curlSpecifier); +ADDSYMBOL(currentpen); +ADDSYMBOL(cyclic); +ADDSYMBOL(d); +ADDSYMBOL(data); +ADDSYMBOL(dawson); +ADDSYMBOL(debye_1); +ADDSYMBOL(debye_2); +ADDSYMBOL(debye_3); +ADDSYMBOL(debye_4); +ADDSYMBOL(debye_5); +ADDSYMBOL(debye_6); +ADDSYMBOL(deconstruct); +ADDSYMBOL(defaultpen); +ADDSYMBOL(deg); +ADDSYMBOL(degrees); +ADDSYMBOL(delete); +ADDSYMBOL(deletepreamble); +ADDSYMBOL(depth); +ADDSYMBOL(dest); +ADDSYMBOL(determinant); +ADDSYMBOL(diagonal); +ADDSYMBOL(diffuse); +ADDSYMBOL(digits); +ADDSYMBOL(dilog); +ADDSYMBOL(dimension); +ADDSYMBOL(dir); +ADDSYMBOL(dirSpecifier); +ADDSYMBOL(dirtime); +ADDSYMBOL(divisor); +ADDSYMBOL(dobreak); +ADDSYMBOL(dot); +ADDSYMBOL(doublefact); +ADDSYMBOL(downcase); +ADDSYMBOL(draw); +ADDSYMBOL(drawPRCcylinder); +ADDSYMBOL(drawPRCdisk); +ADDSYMBOL(drawPRCsphere); +ADDSYMBOL(drawPRCtube); +ADDSYMBOL(dval); +ADDSYMBOL(dxmax); +ADDSYMBOL(e); +ADDSYMBOL(edges); +ADDSYMBOL(embedded); +ADDSYMBOL(empty); +ADDSYMBOL(endclip); +ADDSYMBOL(endgroup); +ADDSYMBOL(endgroup3); +ADDSYMBOL(eof); +ADDSYMBOL(eol); +ADDSYMBOL(epsilon); +ADDSYMBOL(erase); +ADDSYMBOL(erf); +ADDSYMBOL(erf_Q); +ADDSYMBOL(erf_Z); +ADDSYMBOL(erfc); +ADDSYMBOL(error); +ADDSYMBOL(eta); +ADDSYMBOL(exit); +ADDSYMBOL(exp); +ADDSYMBOL(exp_mult); +ADDSYMBOL(expi); +ADDSYMBOL(expm1); +ADDSYMBOL(exprel); +ADDSYMBOL(exprel_2); +ADDSYMBOL(extension); +ADDSYMBOL(f); +ADDSYMBOL(fabs); +ADDSYMBOL(fact); +ADDSYMBOL(factorial); +ADDSYMBOL(fcmp); +ADDSYMBOL(fft); +ADDSYMBOL(file); +ADDSYMBOL(fill); +ADDSYMBOL(fillrule); +ADDSYMBOL(final); +ADDSYMBOL(find); +ADDSYMBOL(floor); +ADDSYMBOL(flush); +ADDSYMBOL(fmod); +ADDSYMBOL(font); +ADDSYMBOL(fontcommand); +ADDSYMBOL(fontsize); +ADDSYMBOL(format); +ADDSYMBOL(fprime); +ADDSYMBOL(from); +ADDSYMBOL(functionshade); +ADDSYMBOL(fuzz); +ADDSYMBOL(g); +ADDSYMBOL(gamma); +ADDSYMBOL(gamma_P); +ADDSYMBOL(gamma_Q); +ADDSYMBOL(gammainv); +ADDSYMBOL(gammastar); +ADDSYMBOL(gegenpoly); +ADDSYMBOL(gegenpoly_1); +ADDSYMBOL(gegenpoly_2); +ADDSYMBOL(gegenpoly_3); +ADDSYMBOL(generate_random_backtrace); +ADDSYMBOL(getc); +ADDSYMBOL(gouraudshade); +ADDSYMBOL(granularity); +ADDSYMBOL(gray); +ADDSYMBOL(grestore); +ADDSYMBOL(gsave); +ADDSYMBOL(gsl); +ADDSYMBOL(half); +ADDSYMBOL(hazard); +ADDSYMBOL(height); +ADDSYMBOL(hex); +ADDSYMBOL(history); +ADDSYMBOL(hy0F1); +ADDSYMBOL(hy1F1); +ADDSYMBOL(hy2F0); +ADDSYMBOL(hy2F1); +ADDSYMBOL(hy2F1_conj); +ADDSYMBOL(hy2F1_conj_renorm); +ADDSYMBOL(hy2F1_renorm); +ADDSYMBOL(hydrogenicR); +ADDSYMBOL(hydrogenicR_1); +ADDSYMBOL(hypot); +ADDSYMBOL(hzeta); +ADDSYMBOL(i); +ADDSYMBOL(i0_scaled); +ADDSYMBOL(i1_scaled); +ADDSYMBOL(i2_scaled); +ADDSYMBOL(i_scaled); +ADDSYMBOL(identity); +ADDSYMBOL(imports); +ADDSYMBOL(in); +ADDSYMBOL(incircle); +ADDSYMBOL(index); +ADDSYMBOL(inf); +ADDSYMBOL(infinity); +ADDSYMBOL(initial); +ADDSYMBOL(initialized); +ADDSYMBOL(input); +ADDSYMBOL(insert); +ADDSYMBOL(inside); +ADDSYMBOL(intMax); +ADDSYMBOL(intMin); +ADDSYMBOL(interaction); +ADDSYMBOL(interactive); +ADDSYMBOL(interactivewrite); +ADDSYMBOL(interp); +ADDSYMBOL(intersect); +ADDSYMBOL(intersections); +ADDSYMBOL(inverse); +ADDSYMBOL(invisible); +ADDSYMBOL(is3D); +ADDSYMBOL(iterations); +ADDSYMBOL(j); +ADDSYMBOL(j0); +ADDSYMBOL(j1); +ADDSYMBOL(j2); +ADDSYMBOL(justify); +ADDSYMBOL(k); +ADDSYMBOL(k0_scaled); +ADDSYMBOL(k1_scaled); +ADDSYMBOL(k2_scaled); +ADDSYMBOL(k_scaled); +ADDSYMBOL(key); +ADDSYMBOL(keys); +ADDSYMBOL(knot); +ADDSYMBOL(l); +ADDSYMBOL(label); +ADDSYMBOL(labels); +ADDSYMBOL(lambda); +ADDSYMBOL(latex); +ADDSYMBOL(latitude); +ADDSYMBOL(latticeshade); +ADDSYMBOL(layer); +ADDSYMBOL(ldexp); +ADDSYMBOL(length); +ADDSYMBOL(lighton); +ADDSYMBOL(lights); +ADDSYMBOL(line); +ADDSYMBOL(linecap); +ADDSYMBOL(linejoin); +ADDSYMBOL(lineskip); +ADDSYMBOL(linetype); +ADDSYMBOL(linewidth); +ADDSYMBOL(list); +ADDSYMBOL(lnK); +ADDSYMBOL(lnbeta); +ADDSYMBOL(lnchoose); +ADDSYMBOL(lncosh); +ADDSYMBOL(lndoublefact); +ADDSYMBOL(lnfact); +ADDSYMBOL(lngamma); +ADDSYMBOL(lnpoch); +ADDSYMBOL(lnsinh); +ADDSYMBOL(locale); +ADDSYMBOL(locatefile); +ADDSYMBOL(location); +ADDSYMBOL(log); +ADDSYMBOL(log10); +ADDSYMBOL(log1p); +ADDSYMBOL(log1pm); +ADDSYMBOL(log_erfc); +ADDSYMBOL(logabs); +ADDSYMBOL(longitude); +ADDSYMBOL(m); +ADDSYMBOL(magnification); +ADDSYMBOL(makepen); +ADDSYMBOL(map); +ADDSYMBOL(max); +ADDSYMBOL(max3); +ADDSYMBOL(maxbezier); +ADDSYMBOL(maxbound); +ADDSYMBOL(maxratio); +ADDSYMBOL(maxtimes); +ADDSYMBOL(microseconds); +ADDSYMBOL(min); +ADDSYMBOL(min3); +ADDSYMBOL(minbezier); +ADDSYMBOL(minbound); +ADDSYMBOL(minratio); +ADDSYMBOL(mintimes); +ADDSYMBOL(miterlimit); +ADDSYMBOL(mode); +ADDSYMBOL(n); +ADDSYMBOL(name); +ADDSYMBOL(nativeformat); +ADDSYMBOL(newpage); +ADDSYMBOL(newton); +ADDSYMBOL(nib); +ADDSYMBOL(nobreak); +ADDSYMBOL(norm); +ADDSYMBOL(normal); +ADDSYMBOL(normalize); +ADDSYMBOL(nowarn); +ADDSYMBOL(nu); +ADDSYMBOL(nurb); +ADDSYMBOL(nx); +ADDSYMBOL(ny); +ADDSYMBOL(nz); +ADDSYMBOL(offset); +ADDSYMBOL(opacity); +ADDSYMBOL(openFunc); +ADDSYMBOL(out); +ADDSYMBOL(outname); +ADDSYMBOL(output); +ADDSYMBOL(overwrite); +ADDSYMBOL(p); +ADDSYMBOL(palette); +ADDSYMBOL(path3); +ADDSYMBOL(pattern); +ADDSYMBOL(pdf); +ADDSYMBOL(pena); +ADDSYMBOL(penb); +ADDSYMBOL(perm); +ADDSYMBOL(perp); +ADDSYMBOL(phi); +ADDSYMBOL(pi); +ADDSYMBOL(piecewisestraight); +ADDSYMBOL(poch); +ADDSYMBOL(pochrel); +ADDSYMBOL(point); +ADDSYMBOL(polar); +ADDSYMBOL(pop); +ADDSYMBOL(pos); +ADDSYMBOL(position); +ADDSYMBOL(post); +ADDSYMBOL(postcontrol); +ADDSYMBOL(postscript); +ADDSYMBOL(pow); +ADDSYMBOL(pow10); +ADDSYMBOL(prc); +ADDSYMBOL(prcshininess); +ADDSYMBOL(pre); +ADDSYMBOL(preamble); +ADDSYMBOL(precision); +ADDSYMBOL(precontrol); +ADDSYMBOL(prefix); +ADDSYMBOL(prepend); +ADDSYMBOL(print_random_addresses); +ADDSYMBOL(project); +ADDSYMBOL(prompt); +ADDSYMBOL(psi); +ADDSYMBOL(psi1); +ADDSYMBOL(psi_1piy); +ADDSYMBOL(purge); +ADDSYMBOL(push); +ADDSYMBOL(q); +ADDSYMBOL(quadraticroots); +ADDSYMBOL(quotient); +ADDSYMBOL(r); +ADDSYMBOL(ra); +ADDSYMBOL(radialshade); +ADDSYMBOL(radians); +ADDSYMBOL(radius); +ADDSYMBOL(rand); +ADDSYMBOL(randMax); +ADDSYMBOL(rb); +ADDSYMBOL(read); +ADDSYMBOL(readline); +ADDSYMBOL(realDigits); +ADDSYMBOL(realEpsilon); +ADDSYMBOL(realMax); +ADDSYMBOL(realMin); +ADDSYMBOL(realmult); +ADDSYMBOL(reflect); +ADDSYMBOL(relativedistance); +ADDSYMBOL(remainder); +ADDSYMBOL(rename); +ADDSYMBOL(replace); +ADDSYMBOL(resetdefaultpen); +ADDSYMBOL(reverse); +ADDSYMBOL(rfind); +ADDSYMBOL(rgb); +ADDSYMBOL(rotate); +ADDSYMBOL(round); +ADDSYMBOL(s); +ADDSYMBOL(saveline); +ADDSYMBOL(scale); +ADDSYMBOL(search); +ADDSYMBOL(seconds); +ADDSYMBOL(seed); +ADDSYMBOL(seek); +ADDSYMBOL(seekeof); +ADDSYMBOL(sequence); +ADDSYMBOL(sgn); +ADDSYMBOL(shader); +ADDSYMBOL(shift); +ADDSYMBOL(shiftless); +ADDSYMBOL(shininess); +ADDSYMBOL(shipout); +ADDSYMBOL(shipout3); +ADDSYMBOL(side); +ADDSYMBOL(sign); +ADDSYMBOL(signedint); +ADDSYMBOL(simpson); +ADDSYMBOL(sin); +ADDSYMBOL(sinc); +ADDSYMBOL(singleint); +ADDSYMBOL(singlereal); +ADDSYMBOL(sinh); +ADDSYMBOL(size); +ADDSYMBOL(size3); +ADDSYMBOL(slant); +ADDSYMBOL(sleep); +ADDSYMBOL(solve); +ADDSYMBOL(sort); +ADDSYMBOL(spec); +ADDSYMBOL(specular); +ADDSYMBOL(sphPlm); +ADDSYMBOL(sqrt); +ADDSYMBOL(srand); +ADDSYMBOL(src); +ADDSYMBOL(stop); +ADDSYMBOL(store); +ADDSYMBOL(straight); +ADDSYMBOL(straightness); +ADDSYMBOL(string); +ADDSYMBOL(stripdirectory); +ADDSYMBOL(stripextension); +ADDSYMBOL(stripfile); +ADDSYMBOL(stroke); +ADDSYMBOL(subpath); +ADDSYMBOL(substr); +ADDSYMBOL(suffix); +ADDSYMBOL(sum); +ADDSYMBOL(synchrotron_1); +ADDSYMBOL(synchrotron_2); +ADDSYMBOL(system); +ADDSYMBOL(t); +ADDSYMBOL(tabcompletion); +ADDSYMBOL(tan); +ADDSYMBOL(tanh); +ADDSYMBOL(taylorcoeff); +ADDSYMBOL(tell); +ADDSYMBOL(tensionSpecifier); +ADDSYMBOL(tensorshade); +ADDSYMBOL(tessellate); +ADDSYMBOL(test); +ADDSYMBOL(tex); +ADDSYMBOL(texpreamble); +ADDSYMBOL(texreset); +ADDSYMBOL(texsize); +ADDSYMBOL(textpath); +ADDSYMBOL(theta); +ADDSYMBOL(time); +ADDSYMBOL(tin); +ADDSYMBOL(to); +ADDSYMBOL(tok); +ADDSYMBOL(tout); +ADDSYMBOL(transform); +ADDSYMBOL(translate); +ADDSYMBOL(transport_2); +ADDSYMBOL(transport_3); +ADDSYMBOL(transport_4); +ADDSYMBOL(transport_5); +ADDSYMBOL(transpose); +ADDSYMBOL(triangulate); +ADDSYMBOL(tridiagonal); +ADDSYMBOL(two_ja); +ADDSYMBOL(two_jb); +ADDSYMBOL(two_jc); +ADDSYMBOL(two_jd); +ADDSYMBOL(two_je); +ADDSYMBOL(two_jf); +ADDSYMBOL(two_jg); +ADDSYMBOL(two_jh); +ADDSYMBOL(two_ji); +ADDSYMBOL(two_ma); +ADDSYMBOL(two_mb); +ADDSYMBOL(two_mc); +ADDSYMBOL(type); +ADDSYMBOL(u); +ADDSYMBOL(uknot); +ADDSYMBOL(unit); +ADDSYMBOL(unitrand); +ADDSYMBOL(unstraighten); +ADDSYMBOL(upcase); +ADDSYMBOL(update); +ADDSYMBOL(uptodate); +ADDSYMBOL(usleep); +ADDSYMBOL(v); +ADDSYMBOL(value); +ADDSYMBOL(verbose); +ADDSYMBOL(view); +ADDSYMBOL(viewportlighting); +ADDSYMBOL(vknot); +ADDSYMBOL(w); +ADDSYMBOL(w0); +ADDSYMBOL(w1); +ADDSYMBOL(w2); +ADDSYMBOL(w3); +ADDSYMBOL(wait); +ADDSYMBOL(warn); +ADDSYMBOL(warning); +ADDSYMBOL(weights); +ADDSYMBOL(width); +ADDSYMBOL(windingnumber); +ADDSYMBOL(word); +ADDSYMBOL(write); +ADDSYMBOL(x); +ADDSYMBOL(x1); +ADDSYMBOL(x2); +ADDSYMBOL(xform); +ADDSYMBOL(xinput); +ADDSYMBOL(xoutput); +ADDSYMBOL(xpart); +ADDSYMBOL(xscale); +ADDSYMBOL(xx); +ADDSYMBOL(xy); +ADDSYMBOL(y); +ADDSYMBOL(y0); +ADDSYMBOL(y1); +ADDSYMBOL(y2); +ADDSYMBOL(ypart); +ADDSYMBOL(yscale); +ADDSYMBOL(yx); +ADDSYMBOL(yy); +ADDSYMBOL(z); +ADDSYMBOL(z0); +ADDSYMBOL(z1); +ADDSYMBOL(z2); +ADDSYMBOL(z3); +ADDSYMBOL(zero_Ai); +ADDSYMBOL(zero_Ai_deriv); +ADDSYMBOL(zero_Bi); +ADDSYMBOL(zero_Bi_deriv); +ADDSYMBOL(zero_J); +ADDSYMBOL(zero_J0); +ADDSYMBOL(zero_J1); +ADDSYMBOL(zeta); +ADDSYMBOL(zetam1); +ADDSYMBOL(zin); +ADDSYMBOL(zoom); +ADDSYMBOL(zout); +ADDSYMBOL(zpart); diff --git a/Build/source/utils/asymptote/application.cc b/Build/source/utils/asymptote/application.cc index 551ab70e80e..5a287bf2559 100644 --- a/Build/source/utils/asymptote/application.cc +++ b/Build/source/utils/asymptote/application.cc @@ -243,6 +243,10 @@ bool application::matchSignature(env &e, types::signature *source, arglist &al) { formal_vector &f=source->formals; +#if 0 + cout << "num args: " << f.size() << endl; +#endif + // First, match all of the named (non-rest) arguments. for (size_t i=0; i<f.size(); ++i) if (f[i].name) @@ -326,14 +330,27 @@ app_list multimatch(env &e, app_list l; +#if DEBUG_GETAPP + bool perfect=false; +#endif + for(ty_vector::iterator t=o->sub.begin(); t!=o->sub.end(); ++t) { if ((*t)->kind==ty_function) { +#if DEBUG_GETAPP + function *ft = dynamic_cast<function *>(*t); + if (equivalent(ft->getSignature(), source)) + perfect = true; +#endif application *a=application::match(e, (function *)(*t), source, al); if (a) l.push_back(a); } } +#if DEBUG_GETAPP + cout << (perfect ? "PERFECT" : "IMPERFECT") << endl; +#endif + if (l.size() > 1) { // Return the most specific candidates. maximizer m; diff --git a/Build/source/utils/asymptote/arrayop.h b/Build/source/utils/asymptote/arrayop.h index 7832c1f64dc..dd21a80a1d6 100644 --- a/Build/source/utils/asymptote/arrayop.h +++ b/Build/source/utils/asymptote/arrayop.h @@ -289,18 +289,16 @@ void sortArray2(vm::stack *s) s->push(c); } -// Search a sorted ordered array of n elements to find an interval containing -// a given key. Returns n-1 if the key is greater than or equal to the last -// element, -1 if the key is less than the first element, and otherwise the -// index corresponding to the left-hand endpoint of the matching interval. +// Search a sorted ordered array a of n elements for key, returning the index i +// if a[i] <= key < a[i+1], -1 if key is less than all elements of a, or +// n-1 if key is greater than or equal to the last element of a. template<class T> void searchArray(vm::stack *s) { T key=pop<T>(s); array *a=pop<array*>(s); Int size=(Int) a->size(); - if(size == 0) {s->push(0); return;} - if(key < read<T>(a,0)) {s->push(-1); return;} + if(size == 0 || key < read<T>(a,0)) {s->push(-1); return;} Int u=size-1; if(key >= read<T>(a,u)) {s->push(u); return;} Int l=0; diff --git a/Build/source/utils/asymptote/asy-keywords.el b/Build/source/utils/asymptote/asy-keywords.el index d0e2246eaad..1328eae5e2c 100644 --- a/Build/source/utils/asymptote/asy-keywords.el +++ b/Build/source/utils/asymptote/asy-keywords.el @@ -2,7 +2,7 @@ ;; This file is automatically generated by asy-list.pl. ;; Changes will be overwritten. ;; -(defvar asy-keywords-version "1.94") +(defvar asy-keywords-version "1.96") (defvar asy-keyword-name '( and controls tension atleast curl if else while for do return break continue struct typedef new access import unravel from include quote static public private restricted this explicit true false null cycle newframe operator )) @@ -11,7 +11,7 @@ and controls tension atleast curl if else while for do return break continue str Braid FitResult Label Legend Segment Solution TreeNode abscissa arc arrowhead binarytree binarytreeNode block bool bool3 bounds bqe circle conic coord coordsys cputime ellipse file filltype frame grid3 guide horner hsv hyperbola indexedTransform int inversion key light line linefit marginT marker mass object pair parabola path path3 pen picture point position projection real revolution scaleT scientific segment side slice solution splitface string surface tensionSpecifier ticklocate ticksgridT tickvalues transform transformation tree triangle trilinear triple vector vertex void )) (defvar asy-function-name '( -AND Arc ArcArrow ArcArrows Arrow Arrows Automatic AvantGarde BBox BWRainbow BWRainbow2 Bar Bars BeginArcArrow BeginArrow BeginBar BeginDotMargin BeginMargin BeginPenMargin Blank Bookman Bottom BottomTop Bounds Break Broken BrokenLog CLZ CTZ Ceil Circle CircleBarIntervalMarker Cos Courier CrossIntervalMarker DefaultFormat DefaultLogFormat Degrees Dir DotMargin DotMargins Dotted Draw Drawline Embed EndArcArrow EndArrow EndBar EndDotMargin EndMargin EndPenMargin Fill FillDraw Floor Format Full Gaussian Gaussrand Gaussrandpair Gradient Grayscale Helvetica Hermite HookHead InOutTicks InTicks Jn Label Landscape Left LeftRight LeftTicks Legend Linear Link Log LogFormat Margin Margins Mark MidArcArrow MidArrow NOT NewCenturySchoolBook NoBox NoMargin NoModifier NoTicks NoTicks3 NoZero NoZeroFormat None OR OmitFormat OmitTick OmitTickInterval OmitTickIntervals OutTicks Ox Oy Palatino PaletteTicks Pen PenMargin PenMargins Pentype Portrait RadialShade RadialShadeDraw Rainbow Range Relative Right RightTicks Rotate Round SQR Scale ScaleX ScaleY ScaleZ Seascape Segment Shift Sin Slant Spline StickIntervalMarker Straight Symbol Tan TeXify Ticks Ticks3 TildeIntervalMarker TimesRoman Top TrueMargin UnFill UpsideDown Wheel X XEquals XOR XY XYEquals XYZero XYgrid XZEquals XZZero XZero XZgrid Y YEquals YXgrid YZ YZEquals YZZero YZero YZgrid Yn Z ZX ZXgrid ZYgrid ZapfChancery ZapfDingbats _cputime _draw _eval _image _labelpath _projection _strokepath _texpath aCos aSin aTan abort abs accel acos acosh acot acsc activatequote add addArrow addMargins addSaveFunction addnode addnodes addpenarc addpenline adjust alias align all altitude angabscissa angle angpoint animate annotate anticomplementary antipedal apply approximate arc arcarrowsize arccircle arcdir arcfromcenter arcfromfocus arclength arcnodesnumber arcpoint arcsubtended arcsubtendedcenter arctime arctopath array arrow arrow2 arrowbase arrowbasepoints arrowsize asec asin asinh ask assert asy asycode asydir asyfigure asyfilecode asyinclude asywrite atan atan2 atanh atbreakpoint atexit atime attach attract atupdate autoformat autoscale autoscale3 axes axes3 axialshade axis axiscoverage azimuth babel background bangles bar barmarksize barsize basealign baseline bbox beep begin beginclip begingroup beginpoint between bevel bezier bezierP bezierPP bezierPPP bezulate bibliography bibliographystyle binarytree binarytreeNode binomial binput bins bisector bisectorpoint blend blockconnector boutput box bqe breakpoint breakpoints brick buildRestoreDefaults buildRestoreThunk buildcycle bulletcolor byte canonical canonicalcartesiansystem cartesiansystem case1 case2 case3 case4 cbrt cd ceil center centerToFocus centroid cevian change2 changecoordsys checkSegment checkconditionlength checker checkincreasing checklengths checkposition checktriangle choose circle circlebarframe circlemarkradius circlenodesnumber circumcenter circumcircle clamped clear clip clipdraw close cmyk code colatitude collect collinear color colorless colors colorspace comma compassmark complement complementary concat concurrent cone conic conicnodesnumber conictype conj connect connected connectedindex containmentTree contains contour contour3 contouredges controlSpecifier convert coordinates coordsys copy cos cosh cot countIntersections cputime crop cropcode cross crossframe crosshatch crossmarksize csc cubicroots curabscissa curlSpecifier curpoint currentarrow currentexitfunction currentmomarrow currentpolarconicroutine curve cut cutafter cutbefore cyclic cylinder deactivatequote debugger deconstruct defaultdir defaultformat defaultpen defined degenerate degrees delete deletepreamble determinant diagonal diamond diffdiv dir dirSpecifier dirtime display distance divisors do_overpaint dot dotframe dotsize downcase draw drawAll drawDoubleLine drawFermion drawGhost drawGluon drawMomArrow drawPhoton drawScalar drawVertex drawVertexBox drawVertexBoxO drawVertexBoxX drawVertexO drawVertexOX drawVertexTriangle drawVertexTriangleO drawVertexX drawarrow drawarrow2 drawline drawtick duplicate elle ellipse ellipsenodesnumber embed embed3 empty enclose end endScript endclip endgroup endl endpoint endpoints eof eol equation equations erase erasestep erf erfc error errorbar errorbars eval excenter excircle exit exitXasyMode exitfunction exp expfactors expi expm1 exradius extend extension extouch fabs factorial fermat fft fhorner figure file filecode fill filldraw filloutside fillrule filltype find finite finiteDifferenceJacobian firstcut firstframe fit fit2 fixedscaling floor flush fmdefaults fmod focusToCenter font fontcommand fontsize foot format frac frequency fromCenter fromFocus fspline functionshade gamma generate_random_backtrace generateticks gergonne getc getint getpair getreal getstring gettriple gluon gouraudshade graph graphic gray grestore grid grid3 gsave halfbox hatch hdiffdiv hermite hex histogram history hline hprojection hsv hyperbola hyperbolanodesnumber hyperlink hypot identity image incenter incentral incircle increasing incrementposition indexedTransform indexedfigure initXasyMode initdefaults input inradius insert inside integrate interactive interior interp interpolate intersect intersection intersectionpoint intersectionpoints intersections intouch inverse inversion invisible is3D isCCW isDuplicate isogonal isogonalconjugate isotomic isotomicconjugate isparabola italic item key kurtosis kurtosisexcess label labelaxis labelmargin labelpath labels labeltick labelx labelx3 labely labely3 labelz labelz3 lastcut latex latitude latticeshade layer layout ldexp leastsquares legend legenditem length lift light limits line linear linecap lineinversion linejoin linemargin lineskip linetype linewidth link list lm_enorm lm_evaluate_default lm_lmdif lm_lmpar lm_minimize lm_print_default lm_print_quiet lm_qrfac lm_qrsolv locale locate locatefile location log log10 log1p logaxiscoverage longitude lookup magnetize makeNode makedraw makepen map margin markangle markangleradius markanglespace markarc marker markinterval marknodes markrightangle markuniform mass masscenter massformat math max max3 maxbezier maxbound maxcoords maxlength maxratio maxtimes mean medial median midpoint min min3 minbezier minbound minipage minratio mintimes miterlimit momArrowPath momarrowsize monotonic multifigure nativeformat natural needshipout newl newpage newslide newton newtree nextframe nextnormal nextpage nib nodabscissa none norm normalvideo notaknot nowarn numberpage nurb object offset onpath opacity opposite orientation orig_circlenodesnumber orig_circlenodesnumber1 orig_draw orig_ellipsenodesnumber orig_ellipsenodesnumber1 orig_hyperbolanodesnumber orig_parabolanodesnumber origin orthic orthocentercenter outformat outline outname outprefix output overloadedMessage overwrite pack pad pairs palette parabola parabolanodesnumber parallel parallelogram partialsum path path3 pattern pause pdf pedal periodic perp perpendicular perpendicularmark phantom phi1 phi2 phi3 photon piecewisestraight point polar polarconicroutine polargraph polygon postcontrol postscript pow10 ppoint prc prc0 precision precontrol prepend print_random_addresses project projection purge pwhermite quadrant quadraticroots quantize quarticroots quotient radialshade radians radicalcenter radicalline radius rand randompath rd readline realmult realquarticroots rectangle rectangular rectify reflect relabscissa relative relativedistance reldir relpoint reltime remainder remark removeDuplicates rename replace report resetdefaultpen restore restoredefaults reverse reversevideo rf rfind rgb rgba rgbint rms rotate rotateO rotation round roundbox roundedpath roundrectangle same samecoordsys sameside sample save savedefaults saveline scale scale3 scaleO scaleT scaleless scientific search searchindex searchtree sec secondaryX secondaryY seconds section sector seek seekeof segment sequence setcontour setpens sgn sgnd sharpangle sharpdegrees shift shiftless shipout shipout3 show side simeq simpson sin single sinh size size3 skewness skip slant sleep slope slopefield solve solveBVP sort sourceline sphere split sqrt square srand standardizecoordsys startScript startTrembling stdev step stickframe stickmarksize stickmarkspace stop straight straightness string stripdirectory stripextension stripfile strokepath subdivide subitem subpath substr sum surface symmedial symmedian system tab tableau tan tangent tangential tangents tanh tell tensionSpecifier tensorshade tex texcolor texify texpath texpreamble texreset texshipout texsize textpath thick thin tick tickMax tickMax3 tickMin tickMin3 ticklabelshift ticklocate tildeframe tildemarksize tile tiling time times title titlepage topbox transform transformation transpose tremble trembleFuzz tremble_circlenodesnumber tremble_circlenodesnumber1 tremble_draw tremble_ellipsenodesnumber tremble_ellipsenodesnumber1 tremble_hyperbolanodesnumber tremble_marknodes tremble_markuniform tremble_parabolanodesnumber triangle triangleAbc triangleabc triangulate tricoef tridiagonal trilinear trim trueMagnetize truepoint tube uncycle unfill uniform unit unitrand unitsize unityroot unstraighten upcase updatefunction uperiodic upscale uptodate usepackage usersetting usetypescript usleep value variance variancebiased vbox vector vectorfield verbatim view vline vperiodic vprojection warn warning windingnumber write xaxis xaxis3 xaxis3At xaxisAt xequals xinput xlimits xoutput xpart xscale xscaleO xtick xtick3 xtrans yaxis yaxis3 yaxis3At yaxisAt yequals ylimits ypart yscale yscaleO ytick ytick3 ytrans zaxis3 zaxis3At zero zero3 zlimits zpart ztick ztick3 ztrans )) +AND Arc ArcArrow ArcArrows Arrow Arrows Automatic AvantGarde BBox BWRainbow BWRainbow2 Bar Bars BeginArcArrow BeginArrow BeginBar BeginDotMargin BeginMargin BeginPenMargin Blank Bookman Bottom BottomTop Bounds Break Broken BrokenLog CLZ CTZ Ceil Circle CircleBarIntervalMarker Cos Courier CrossIntervalMarker DefaultFormat DefaultLogFormat Degrees Dir DotMargin DotMargins Dotted Draw Drawline Embed EndArcArrow EndArrow EndBar EndDotMargin EndMargin EndPenMargin Fill FillDraw Floor Format Full Gaussian Gaussrand Gaussrandpair Gradient Grayscale Helvetica Hermite HookHead InOutTicks InTicks Jn Label Landscape Left LeftRight LeftTicks Legend Linear Link Log LogFormat Margin Margins Mark MidArcArrow MidArrow NOT NewCenturySchoolBook NoBox NoMargin NoModifier NoTicks NoTicks3 NoZero NoZeroFormat None OR OmitFormat OmitTick OmitTickInterval OmitTickIntervals OutTicks Ox Oy Palatino PaletteTicks Pen PenMargin PenMargins Pentype Portrait RadialShade RadialShadeDraw Rainbow Range Relative Right RightTicks Rotate Round SQR Scale ScaleX ScaleY ScaleZ Seascape Segment Shift Sin Slant Spline StickIntervalMarker Straight Symbol Tan TeXify Ticks Ticks3 TildeIntervalMarker TimesRoman Top TrueMargin UnFill UpsideDown Wheel X XEquals XOR XY XYEquals XYZero XYgrid XZEquals XZZero XZero XZgrid Y YEquals YXgrid YZ YZEquals YZZero YZero YZgrid Yn Z ZX ZXgrid ZYgrid ZapfChancery ZapfDingbats _begingroup3 _cputime _draw _eval _image _labelpath _projection _strokepath _texpath aCos aSin aTan abort abs accel acos acosh acot acsc activatequote add addArrow addMargins addSaveFunction addnode addnodes addpenarc addpenline adjust alias align all altitude angabscissa angle angpoint animate annotate anticomplementary antipedal apply approximate arc arcarrowsize arccircle arcdir arcfromcenter arcfromfocus arclength arcnodesnumber arcpoint arcsubtended arcsubtendedcenter arctime arctopath array arrow arrow2 arrowbase arrowbasepoints arrowsize asec asin asinh ask assert asy asycode asydir asyfigure asyfilecode asyinclude asywrite atan atan2 atanh atbreakpoint atexit atime attach attract atupdate autoformat autoscale autoscale3 axes axes3 axialshade axis axiscoverage azimuth babel background bangles bar barmarksize barsize basealign baseline bbox beep begin beginclip begingroup beginpoint between bevel bezier bezierP bezierPP bezierPPP bezulate bibliography bibliographystyle binarytree binarytreeNode binomial binput bins bisector bisectorpoint bispline blend blockconnector boutput box bqe breakpoint breakpoints brick buildRestoreDefaults buildRestoreThunk buildcycle bulletcolor byte canonical canonicalcartesiansystem cartesiansystem case1 case2 case3 case4 cbrt cd ceil center centerToFocus centroid cevian change2 changecoordsys checkSegment checkconditionlength checker checkincreasing checklengths checkposition checktriangle choose circle circlebarframe circlemarkradius circlenodesnumber circumcenter circumcircle clamped clear clip clipdraw close cmyk code colatitude collect collinear color colorless colors colorspace comma compassmark complement complementary concat concurrent cone conic conicnodesnumber conictype conj connect connected connectedindex containmentTree contains contour contour3 contouredges controlSpecifier convert coordinates coordsys copy cos cosh cot countIntersections cputime crop cropcode cross crossframe crosshatch crossmarksize csc cubicroots curabscissa curlSpecifier curpoint currentarrow currentexitfunction currentmomarrow currentpolarconicroutine curve cut cutafter cutbefore cyclic cylinder deactivatequote debugger deconstruct defaultdir defaultformat defaultpen defined degenerate degrees delete deletepreamble determinant diagonal diamond diffdiv dir dirSpecifier dirtime display distance divisors do_overpaint dot dotframe dotsize downcase draw drawAll drawDoubleLine drawFermion drawGhost drawGluon drawMomArrow drawPRCcylinder drawPRCdisk drawPRCsphere drawPRCtube drawPhoton drawScalar drawVertex drawVertexBox drawVertexBoxO drawVertexBoxX drawVertexO drawVertexOX drawVertexTriangle drawVertexTriangleO drawVertexX drawarrow drawarrow2 drawline drawtick duplicate elle ellipse ellipsenodesnumber embed embed3 empty enclose end endScript endclip endgroup endgroup3 endl endpoint endpoints eof eol equation equations erase erasestep erf erfc error errorbar errorbars eval excenter excircle exit exitXasyMode exitfunction exp expfactors expi expm1 exradius extend extension extouch fabs factorial fermat fft fhorner figure file filecode fill filldraw filloutside fillrule filltype find finite finiteDifferenceJacobian firstcut firstframe fit fit2 fixedscaling floor flush fmdefaults fmod focusToCenter font fontcommand fontsize foot format frac frequency fromCenter fromFocus fspline functionshade gamma generate_random_backtrace generateticks gergonne getc getint getpair getreal getstring gettriple gluon gouraudshade graph graphic gray grestore grid grid3 gsave halfbox hatch hdiffdiv hermite hex histogram history hline hprojection hsv hyperbola hyperbolanodesnumber hyperlink hypot identity image incenter incentral incircle increasing incrementposition indexedTransform indexedfigure initXasyMode initdefaults input inradius insert inside integrate interactive interior interp interpolate intersect intersection intersectionpoint intersectionpoints intersections intouch inverse inversion invisible is3D isCCW isDuplicate isogonal isogonalconjugate isotomic isotomicconjugate isparabola italic item key kurtosis kurtosisexcess label labelaxis labelmargin labelpath labels labeltick labelx labelx3 labely labely3 labelz labelz3 lastcut latex latitude latticeshade layer layout ldexp leastsquares legend legenditem length lexorder lift light limits line linear linecap lineinversion linejoin linemargin lineskip linetype linewidth link list lm_enorm lm_evaluate_default lm_lmdif lm_lmpar lm_minimize lm_print_default lm_print_quiet lm_qrfac lm_qrsolv locale locate locatefile location log log10 log1p logaxiscoverage longitude lookup magnetize makeNode makedraw makepen map margin markangle markangleradius markanglespace markarc marker markinterval marknodes markrightangle markuniform mass masscenter massformat math max max3 maxbezier maxbound maxcoords maxlength maxratio maxtimes mean medial median midpoint min min3 minbezier minbound minipage minratio mintimes miterlimit momArrowPath momarrowsize monotonic multifigure nativeformat natural needshipout newl newpage newslide newton newtree nextframe nextnormal nextpage nib nodabscissa none norm normalvideo notaknot nowarn numberpage nurb object offset onpath opacity opposite orientation orig_circlenodesnumber orig_circlenodesnumber1 orig_draw orig_ellipsenodesnumber orig_ellipsenodesnumber1 orig_hyperbolanodesnumber orig_parabolanodesnumber origin orthic orthocentercenter outformat outline outname outprefix output overloadedMessage overwrite pack pad pairs palette parabola parabolanodesnumber parallel parallelogram partialsum path path3 pattern pause pdf pedal periodic perp perpendicular perpendicularmark phantom phi1 phi2 phi3 photon piecewisestraight point polar polarconicroutine polargraph polygon postcontrol postscript pow10 ppoint prc prc0 precision precontrol prepend print_random_addresses project projection purge pwhermite quadrant quadraticroots quantize quarticroots quotient radialshade radians radicalcenter radicalline radius rand randompath rd readline realmult realquarticroots rectangle rectangular rectify reflect relabscissa relative relativedistance reldir relpoint reltime remainder remark removeDuplicates rename replace report resetdefaultpen restore restoredefaults reverse reversevideo rf rfind rgb rgba rgbint rms rotate rotateO rotation round roundbox roundedpath roundrectangle same samecoordsys sameside sample save savedefaults saveline scale scale3 scaleO scaleT scaleless scientific search searchindex searchtree sec secondaryX secondaryY seconds section sector seek seekeof segment sequence setcontour setpens sgn sgnd sharpangle sharpdegrees shift shiftless shipout shipout3 show side simeq simpson sin single sinh size size3 skewness skip slant sleep slope slopefield solve solveBVP sort sourceline sphere split sqrt square srand standardizecoordsys startScript startTrembling stdev step stickframe stickmarksize stickmarkspace stop straight straightness string stripdirectory stripextension stripfile strokepath subdivide subitem subpath substr sum surface symmedial symmedian system tab tableau tan tangent tangential tangents tanh tell tensionSpecifier tensorshade tex texcolor texify texpath texpreamble texreset texshipout texsize textpath thick thin tick tickMax tickMax3 tickMin tickMin3 ticklabelshift ticklocate tildeframe tildemarksize tile tiling time times title titlepage topbox transform transformation transpose tremble trembleFuzz tremble_circlenodesnumber tremble_circlenodesnumber1 tremble_draw tremble_ellipsenodesnumber tremble_ellipsenodesnumber1 tremble_hyperbolanodesnumber tremble_marknodes tremble_markuniform tremble_parabolanodesnumber triangle triangleAbc triangleabc triangulate tricoef tridiagonal trilinear trim trueMagnetize truepoint tube uncycle unfill uniform unique unit unitrand unitsize unityroot unstraighten upcase updatefunction uperiodic upscale uptodate usepackage usersetting usetypescript usleep value variance variancebiased vbox vector vectorfield verbatim view vline vperiodic vprojection warn warning windingnumber write xaxis xaxis3 xaxis3At xaxisAt xequals xinput xlimits xoutput xpart xscale xscaleO xtick xtick3 xtrans yaxis yaxis3 yaxis3At yaxisAt yequals ylimits ypart yscale yscaleO ytick ytick3 ytrans zaxis3 zaxis3At zero zero3 zlimits zpart ztick ztick3 ztrans )) (defvar asy-variable-name '( AliceBlue Align Allow AntiqueWhite Apricot Aqua Aquamarine Aspect Azure BeginPoint Beige Bisque Bittersweet Black BlanchedAlmond Blue BlueGreen BlueViolet Both Break BrickRed Brown BurlyWood BurntOrange CCW CW CadetBlue CarnationPink Center Centered Cerulean Chartreuse Chocolate Coeff Coral CornflowerBlue Cornsilk Crimson Crop Cyan Dandelion DarkBlue DarkCyan DarkGoldenrod DarkGray DarkGreen DarkKhaki DarkMagenta DarkOliveGreen DarkOrange DarkOrchid DarkRed DarkSalmon DarkSeaGreen DarkSlateBlue DarkSlateGray DarkTurquoise DarkViolet DeepPink DeepSkyBlue DefaultHead DimGray DodgerBlue Dotted Down Draw E ENE EPS ESE E_Euler E_PC E_RK2 E_RK3BS Emerald EndPoint Euler Fill FillDraw FireBrick FloralWhite ForestGreen Fuchsia Gainsboro GhostWhite Gold Goldenrod Gray Green GreenYellow Honeydew HookHead Horizontal HotPink I IgnoreAspect IndianRed Indigo Ivory JOIN_IN JOIN_OUT JungleGreen Khaki LM_DWARF LM_MACHEP LM_SQRT_DWARF LM_SQRT_GIANT LM_USERTOL Label Lavender LavenderBlush LawnGreen Left LeftJustified LeftSide LemonChiffon LightBlue LightCoral LightCyan LightGoldenrodYellow LightGreen LightGrey LightPink LightSalmon LightSeaGreen LightSkyBlue LightSlateGray LightSteelBlue LightYellow Lime LimeGreen Linear Linen Log Logarithmic Magenta Mahogany Mark MarkFill Maroon Max MediumAquamarine MediumBlue MediumOrchid MediumPurple MediumSeaGreen MediumSlateBlue MediumSpringGreen MediumTurquoise MediumVioletRed Melon MidPoint MidnightBlue Min MintCream MistyRose Moccasin Move MoveQuiet Mulberry N NE NNE NNW NW NavajoWhite Navy NavyBlue NoAlign NoCrop NoFill NoSide OldLace Olive OliveDrab OliveGreen Orange OrangeRed Orchid Ox Oy PC PaleGoldenrod PaleGreen PaleTurquoise PaleVioletRed PapayaWhip Peach PeachPuff Periwinkle Peru PineGreen Pink Plum PowderBlue ProcessBlue Purple RK2 RK3 RK3BS RK4 RK5 RK5DP RK5F RawSienna Red RedOrange RedViolet Rhodamine Right RightJustified RightSide RosyBrown RoyalBlue RoyalPurple RubineRed S SE SSE SSW SW SaddleBrown Salmon SandyBrown SeaGreen Seashell Sepia Sienna Silver SimpleHead SkyBlue SlateBlue SlateGray Snow SpringGreen SteelBlue Suppress SuppressQuiet Tan TeXHead Teal TealBlue Thistle Ticksize Tomato Turquoise UnFill Up VERSION Value Vertical Violet VioletRed W WNW WSW Wheat White WhiteSmoke WildStrawberry XYAlign YAlign Yellow YellowGreen YellowOrange addpenarc addpenline align allowstepping angularsystem animationdelay appendsuffix arcarrowangle arcarrowfactor arrow2sizelimit arrowangle arrowbarb arrowdir arrowfactor arrowhookfactor arrowlength arrowsizelimit arrowtexfactor authorpen axis axiscoverage axislabelfactor background backgroundcolor backgroundpen barfactor barmarksizefactor basealign baselinetemplate beveljoin bigvertexpen bigvertexsize black blue bm bottom bp brown bullet byfoci byvertices camerafactor chartreuse circlemarkradiusfactor circlenodesnumberfactor circleprecision circlescale cm codefile codepen codeskip colorPen coloredNodes coloredSegments conditionlength conicnodesfactor count cputimeformat crossmarksizefactor currentcoordsys currentlight currentpatterns currentpen currentpicture currentposition currentprojection curvilinearsystem cuttings cyan darkblue darkbrown darkcyan darkgray darkgreen darkgrey darkmagenta darkolive darkred dashdotted dashed datepen dateskip debuggerlines debugging deepblue deepcyan deepgray deepgreen deepgrey deepmagenta deepred default defaultControl defaultS defaultbackpen defaultcoordsys defaultexcursion defaultfilename defaultformat defaultmassformat defaultpen diagnostics differentlengths dot dotfactor dotframe dotted doublelinepen doublelinespacing down duplicateFuzz edge ellipsenodesnumberfactor eps epsgeo epsilon evenodd extendcap exterior fermionpen figureborder figuremattpen firstnode firststep foregroundcolor fuchsia fuzz gapfactor ghostpen gluonamplitude gluonpen gluonratio gray green grey hatchepsilon havepagenumber heavyblue heavycyan heavygray heavygreen heavygrey heavymagenta heavyred hline hwratio hyperbola hyperbolanodesnumberfactor identity4 ignore inXasyMode inch inches includegraphicscommand inf infinity institutionpen intMax intMin interior invert invisible itempen itemskip itemstep labelmargin landscape lastnode left legendhskip legendlinelength legendmargin legendmarkersize legendmaxrelativewidth legendvskip lightblue lightcyan lightgray lightgreen lightgrey lightmagenta lightolive lightred lightyellow line linemargin lm_infmsg lm_shortmsg longdashdotted longdashed magenta magneticPoints magneticRadius mantissaBits markangleradius markangleradiusfactor markanglespace markanglespacefactor mediumblue mediumcyan mediumgray mediumgreen mediumgrey mediummagenta mediumred mediumyellow middle minDistDefault minblockheight minblockwidth mincirclediameter minipagemargin minipagewidth minvertexangle miterjoin mm momarrowfactor momarrowlength momarrowmargin momarrowoffset momarrowpen monoPen morepoints nCircle newbulletcolor ngraph nil nmesh nobasealign nodeMarginDefault nodesystem nomarker nopoint noprimary nullpath nullpen numarray ocgindex oldbulletcolor olive orange origin overpaint page pageheight pagemargin pagenumberalign pagenumberpen pagenumberposition pagewidth paleblue palecyan palegray palegreen palegrey palemagenta palered paleyellow parabolanodesnumberfactor perpfactor phi photonamplitude photonpen photonratio pi pink plain plus preamblenodes pt purple r3 r4a r4b randMax realDigits realEpsilon realMax realMin red relativesystem reverse right roundcap roundjoin royalblue salmon saveFunctions scalarpen sequencereal settings shipped signedtrailingzero solid springgreen sqrtEpsilon squarecap squarepen startposition stdin stdout stepfactor stepfraction steppagenumberpen stepping stickframe stickmarksizefactor stickmarkspacefactor textpen ticksize tildeframe tildemarksizefactor tinv titlealign titlepagepen titlepageposition titlepen titleskip top trailingzero treeLevelStep treeMinNodeWidth treeNodeStep trembleAngle trembleFrequency trembleRandom tremblingMode undefined unitcircle unitsquare up urlpen urlskip version vertexpen vertexsize viewportmargin viewportsize vline white wye xformStack yellow ylabelwidth zerotickfuzz zerowinding )) diff --git a/Build/source/utils/asymptote/asymptote.nsi b/Build/source/utils/asymptote/asymptote.nsi index 3eb151840b1..725245d06eb 100644 --- a/Build/source/utils/asymptote/asymptote.nsi +++ b/Build/source/utils/asymptote/asymptote.nsi @@ -133,6 +133,7 @@ Section -Post WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "Path" "$INSTDIR" WriteRegStr HKLM "${PRODUCT_FILE_TYPE_REGKEY1}" "" "ASYFile" WriteRegStr HKLM "${PRODUCT_FILE_TYPE_REGKEY2}" "" '"$INSTDIR\asy.bat" "%1"' + WriteRegDWORD HKLM "SOFTWARE\Cygnus Solutions\Cygwin" "heap_chunk_in_mb" 0xFFFFFFFF ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "CYGWIN" ${If} $0 == "" WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "CYGWIN" "nodosfilewarning" diff --git a/Build/source/utils/asymptote/asymptote.spec b/Build/source/utils/asymptote/asymptote.spec index 1066415ee0b..d1990a7bca0 100644 --- a/Build/source/utils/asymptote/asymptote.spec +++ b/Build/source/utils/asymptote/asymptote.spec @@ -1,7 +1,7 @@ %{!?_texmf: %define _texmf %(eval "echo `kpsewhich -expand-var '$TEXMFLOCAL'`")} Name: asymptote -Version: 1.94 +Version: 1.96 Release: 1%{?dist} Summary: Descriptive vector graphics language diff --git a/Build/source/utils/asymptote/base/bezulate.asy b/Build/source/utils/asymptote/base/bezulate.asy index d935d358989..f3817a47bcf 100644 --- a/Build/source/utils/asymptote/base/bezulate.asy +++ b/Build/source/utils/asymptote/base/bezulate.asy @@ -24,20 +24,20 @@ path[][] containmentTree(path[] paths) bool classified=false; // check if current curve contains or is contained in a group of curves for(int j=0; !classified && j < result.length; ++j) - { - int test = inside(paths[i],result[j][0],zerowinding); - if(test == 1) // current curve contains group's toplevel curve { - // replace toplevel curve with current curve - result[j].insert(0,paths[i]); - classified = true; - } - else if(test == -1) // current curve contained in group's toplevel curve - { - result[j].push(paths[i]); - classified = true; + int test = inside(paths[i],result[j][0],zerowinding); + if(test == 1) // current curve contains group's toplevel curve + { + // replace toplevel curve with current curve + result[j].insert(0,paths[i]); + classified = true; + } + else if(test == -1) // current curve contained in group's toplevel curve + { + result[j].push(paths[i]); + classified = true; + } } - } // create a new group if this curve does not belong to another group if(!classified) result.push(new path[] {paths[i]}); @@ -92,11 +92,11 @@ void connect(path[] paths, path[] result, path[] patch) path[] remainingCurves; path[] inners; for(path[] innerGroup:innerTree) - { - inners.push(innerGroup[0]); - if(innerGroup.length>1) - remainingCurves.append(innerGroup[1:]); - } + { + inners.push(innerGroup[0]); + if(innerGroup.length>1) + remainingCurves.append(innerGroup[1:]); + } connect(remainingCurves,result,patch); real d=2*abs(max(outer)-min(outer)); while(inners.length > 0) { @@ -134,36 +134,36 @@ void connect(path[] paths, path[] result, path[] patch) while(!found && timeoffset > fuzz) { timeoffset /= 2; if(countIntersections(allCurves,start, - point(outer,endtime+timeoffset)) == 2) - { - portion = subpath(outer,endtime,endtime+timeoffset)--start--cycle; - found=true; - // check if an inner curve is inside the portion - for(int k = 0; found && k < inners.length; ++k) + point(outer,endtime+timeoffset)) == 2) { - if(k!=curveIndex && - inside(portion,point(inners[k],0),zerowinding)) - found = false; + portion = subpath(outer,endtime,endtime+timeoffset)--start--cycle; + found=true; + // check if an inner curve is inside the portion + for(int k = 0; found && k < inners.length; ++k) + { + if(k!=curveIndex && + inside(portion,point(inners[k],0),zerowinding)) + found = false; + } } - } } if(!found) timeoffset=-2; while(!found && timeoffset < -fuzz) { timeoffset /= 2; if(countIntersections(allCurves,start, - point(outer,endtime+timeoffset))==2) - { - portion = subpath(outer,endtime+timeoffset,endtime)--start--cycle; - found = true; - // check if an inner curve is inside the portion - for(int k = 0; found && k < inners.length; ++k) + point(outer,endtime+timeoffset))==2) { - if(k!=curveIndex && - inside(portion,point(inners[k],0),zerowinding)) - found = false; + portion = subpath(outer,endtime+timeoffset,endtime)--start--cycle; + found = true; + // check if an inner curve is inside the portion + for(int k = 0; found && k < inners.length; ++k) + { + if(k!=curveIndex && + inside(portion,point(inners[k],0),zerowinding)) + found = false; + } } - } } assert(found); endtime=min(endtime,endtime+timeoffset); @@ -171,8 +171,8 @@ void connect(path[] paths, path[] result, path[] patch) // depends on the curves having opposite orientations path remainder=section(outer,endtime+timeoffset,endtime) - --uncycle(inners[curveIndex], - starttime)--cycle; + --uncycle(inners[curveIndex], + starttime)--cycle; inners.delete(curveIndex); outer = remainder; patch.append(portion); diff --git a/Build/source/utils/asymptote/base/embed.asy b/Build/source/utils/asymptote/base/embed.asy index 504b3af66b0..dc6c7d4101a 100644 --- a/Build/source/utils/asymptote/base/embed.asy +++ b/Build/source/utils/asymptote/base/embed.asy @@ -1,6 +1,6 @@ if(latex()) { -usepackage("hyperref"); -texpreamble("\hypersetup{"+settings.hyperrefOptions+"}"); + usepackage("hyperref"); + texpreamble("\hypersetup{"+settings.hyperrefOptions+"}"); texpreamble(" \ifx\pdfhorigin\undefined% \usepackage[3D,dvipdfmx]{movie15} diff --git a/Build/source/utils/asymptote/base/geometry.asy b/Build/source/utils/asymptote/base/geometry.asy index 8679ada4c75..41a6397de64 100644 --- a/Build/source/utils/asymptote/base/geometry.asy +++ b/Build/source/utils/asymptote/base/geometry.asy @@ -6432,7 +6432,7 @@ point operator *(inversion i, point P) void lineinversion() { - warning("lineinversion","the inversion of the line is not a circle. + warning("lineinversion","the inversion of the line is not a circle. The returned circle has an infinite radius, circle.l has been set."); } diff --git a/Build/source/utils/asymptote/base/graph3.asy b/Build/source/utils/asymptote/base/graph3.asy index 32f66851e75..9c6529a74dd 100644 --- a/Build/source/utils/asymptote/base/graph3.asy +++ b/Build/source/utils/asymptote/base/graph3.asy @@ -59,7 +59,7 @@ void drawtick(picture pic, transform3 T, path3 g, path3 g2, G=(sign == 0) ? locate1.V-Size*locate1.dir--locate1.V+Size*locate1.dir : locate1.V--locate1.V+Size*sign*locate1.dir; - draw(pic,G,p); + draw(pic,G,p,name="tick"); } triple ticklabelshift(triple align, pen p=currentpen) @@ -216,7 +216,10 @@ ticks3 Ticks3(int sign, Label F="", ticklabel ticklabel=null, } else ticklabel=Format(format); } - begingroup3(pic); + bool labelaxis=L.s != "" && primary; + + begingroup3(pic,"axis"); + if(primary) draw(pic,margin(G,p).g,p,arrow); else draw(pic,G,p); @@ -230,8 +233,7 @@ ticks3 Ticks3(int sign, Label F="", ticklabel ticklabel=null, if(val >= a && val <= b) drawtick(pic,t,g,g2,locate,val,size,sign,ptick,extend); } - endgroup3(pic); - + if(N == 0) N=1; if(Size > 0 && primary) { for(int i=(beginlabel ? 0 : 1); @@ -243,8 +245,10 @@ ticks3 Ticks3(int sign, Label F="", ticklabel ticklabel=null, } } } - if(L.s != "" && primary) + if(labelaxis) labelaxis(pic,t,L,G,locate,Sign,ticklabels); + + endgroup3(pic); }; } @@ -1570,8 +1574,8 @@ surface surface(triple[][] f, bool[][] cond={}) for(int j=0; j < ny; ++j) { if(all || (condi[j] && condi[j+1] && condp[j] && condp[j+1])) s.s[++k]=patch(new triple[] {fi[j],fp[j],fp[j+1],fi[j+1]}); - indexi[j]=k; - } + indexi[j]=k; + } } if(count == nx*ny) { @@ -1582,6 +1586,123 @@ surface surface(triple[][] f, bool[][] cond={}) return s; } +surface bispline(real[][] z, real[][] p, real[][] q, real[][] r, + real[] x, real[] y, bool[][] cond={}) +{ // z[i][j] is the value at (x[i],y[j]) + // p and q are the first derivatives with respect to x and y, respectively + // r is the second derivative ddu/dxdy + int n=x.length-1; + int m=y.length-1; + + bool all=cond.length == 0; + + int count; + if(all) + count=n*m; + else { + count=0; + for(int i=0; i < n; ++i) { + bool[] condi=cond[i]; + for(int j=0; j < m; ++j) + if(condi[j]) ++count; + } + } + + surface s=surface(count); + s.index=new int[n][m]; + int k=-1; + for(int i=0; i < n; ++i) { + bool[] condi=all ? null : cond[i]; + real xi=x[i]; + real[] zi=z[i]; + real[] zp=z[i+1]; + real[] ri=r[i]; + real[] rp=r[i+1]; + real[] pi=p[i]; + real[] pp=p[i+1]; + real[] qi=q[i]; + real[] qp=q[i+1]; + real xp=x[i+1]; + real hx=(xp-xi)/3; + int[] indexi=s.index[i]; + for(int j=0; j < m; ++j) { + real yj=y[j]; + real yp=y[j+1]; + if(all || condi[j]) { + triple[][] P=array(4,array(4,O)); + real hy=(yp-yj)/3; + real hxy=hx*hy; + // x and y directions + for(int k=0; k < 4; ++k) { + P[0][k] += xi*X; + P[k][0] += yj*Y; + P[1][k] += (xp+2*xi)/3*X; + P[k][1] += (yp+2*yj)/3*Y; + P[2][k] += (2*xp+xi)/3*X; + P[k][2] += (2*yp+yj)/3*Y; + P[3][k] += xp*X; + P[k][3] += yp*Y; + } + // z: value + P[0][0] += zi[j]*Z; + P[3][0] += zp[j]*Z; + P[0][3] += zi[j+1]*Z; + P[3][3] += zp[j+1]*Z; + // z: first derivative + P[1][0] += (P[0][0].z+hx*pi[j])*Z; + P[1][3] += (P[0][3].z+hx*pi[j+1])*Z; + P[2][0] += (P[3][0].z-hx*pp[j])*Z; + P[2][3] += (P[3][3].z-hx*pp[j+1])*Z; + P[0][1] += (P[0][0].z+hy*qi[j])*Z; + P[3][1] += (P[3][0].z+hy*qp[j])*Z; + P[0][2] += (P[0][3].z-hy*qi[j+1])*Z; + P[3][2] += (P[3][3].z-hy*qp[j+1])*Z; + // z: second derivative + P[1][1] += (P[0][1].z+P[1][0].z-P[0][0].z+hxy*ri[j])*Z; + P[1][2] += (P[0][2].z+P[1][3].z-P[0][3].z-hxy*ri[j+1])*Z; + P[2][1] += (P[2][0].z+P[3][1].z-P[3][0].z-hxy*rp[j])*Z; + P[2][2] += (P[2][3].z+P[3][2].z-P[3][3].z+hxy*rp[j+1])*Z; + s.s[++k]=patch(P); + indexi[j]=k; + } + } + } + + return s; +} + +// return the surface described by a real matrix f, interpolated with +// xsplinetype and ysplinetype. +surface surface(real[][] f, real[] x, real[] y, + splinetype xsplinetype=null, splinetype ysplinetype=xsplinetype, + bool[][] cond={}) +{ + real epsilon=sqrtEpsilon*norm(y); + if(xsplinetype == null) + xsplinetype=(abs(x[0]-x[x.length-1]) <= epsilon) ? periodic : notaknot; + if(ysplinetype == null) + ysplinetype=(abs(y[0]-y[y.length-1]) <= epsilon) ? periodic : notaknot; + int n=x.length; int m=y.length; + real[][] ft=transpose(f); + real[][] tp=new real[m][]; + for(int j=0; j < m; ++j) + tp[j]=xsplinetype(x,ft[j]); + real[][] q=new real[n][]; + for(int i=0; i < n; ++i) + q[i]=ysplinetype(y,f[i]); + real[][] qt=transpose(q); + real[] d1=xsplinetype(x,qt[0]); + real[] d2=xsplinetype(x,qt[m-1]); + real[][] r=new real[n][]; + real[][] p=transpose(tp); + for(int i=0; i < n; ++i) + r[i]=clamped(d1[i],d2[i])(y,p[i]); + surface s=bispline(f,p,q,r,x,y,cond); + if(xsplinetype == periodic) s.ucyclic(true); + if(ysplinetype == periodic) s.vcyclic(true); + return s; +} + // return the surface described by a real matrix f, interpolated with // xsplinetype and ysplinetype. surface surface(real[][] f, pair a, pair b, splinetype xsplinetype, @@ -1730,30 +1851,36 @@ guide3[][] lift(real f(pair z), guide[][] g, interpolate3 join=operator --) } void draw(picture pic=currentpicture, Label[] L=new Label[], - guide3[][] g, pen[] p) + guide3[][] g, pen[] p, light light=currentlight, string name="", + render render=defaultrender, + interaction interaction=LabelInteraction()) { pen thin=is3D() ? thin() : defaultpen; - begingroup3(pic); + if(g.length > 1) + begingroup3(pic,name == "" ? "contours" : name,render); for(int cnt=0; cnt < g.length; ++cnt) { guide3[] gcnt=g[cnt]; pen pcnt=thin+p[cnt]; for(int i=0; i < gcnt.length; ++i) - draw(pic,gcnt[i],pcnt); + draw(pic,gcnt[i],pcnt,light,name); if(L.length > 0) { Label Lcnt=L[cnt]; for(int i=0; i < gcnt.length; ++i) { if(Lcnt.s != "" && size(gcnt[i]) > 1) - label(pic,Lcnt,gcnt[i],pcnt); + label(pic,Lcnt,gcnt[i],pcnt,name,interaction); } } } - endgroup3(pic); + if(g.length > 1) + endgroup3(pic); } void draw(picture pic=currentpicture, Label[] L=new Label[], - guide3[][] g, pen p=currentpen) + guide3[][] g, pen p=currentpen, light light=currentlight, + string name="", interaction interaction=LabelInteraction()) { - draw(pic,L,g,sequence(new pen(int) {return p;},g.length)); + draw(pic,L,g,sequence(new pen(int) {return p;},g.length),light,name, + interaction); } real maxlength(triple f(pair z), pair a, pair b, int nu, int nv) diff --git a/Build/source/utils/asymptote/base/labelpath3.asy b/Build/source/utils/asymptote/base/labelpath3.asy index 8483a76a047..63b2290f1f2 100644 --- a/Build/source/utils/asymptote/base/labelpath3.asy +++ b/Build/source/utils/asymptote/base/labelpath3.asy @@ -48,10 +48,10 @@ surface labelpath(string s, path3 p, real angle=90, triple optional=O) path[] text=texpath(Label(s,(0,0),Align,basealign)); text=scale(1/(max(text).x-min(text).x))*text; path[][] decompose=containmentTree(text); - + real[][] xpos=new real[decompose.length][2]; surface sf; - for(int i=0; i < decompose.length; ++i) {// Identify positions along x-axis + for(int i=0; i < decompose.length; ++i) {// Identify positions along x-axis xpos[i][1]=i; real pos0=0.5(max(decompose[i]).x+min(decompose[i]).x); xpos[i][0]=pos0; diff --git a/Build/source/utils/asymptote/base/lmfit.asy b/Build/source/utils/asymptote/base/lmfit.asy index 72745625824..e70421074e5 100644 --- a/Build/source/utils/asymptote/base/lmfit.asy +++ b/Build/source/utils/asymptote/base/lmfit.asy @@ -28,7 +28,7 @@ the least-squares sum % \begin{equation*} - \sum_{i = 1}^n \left( \frac{y_i - f(a_1, \dots, a_m; x_i)}{\Delta y_i} \right)^2 + \sum_{i = 1}^n \left( \frac{y_i - f(a_1, \dots, a_m; x_i)}{\Delta y_i} \right)^2 \end{equation*} % with respect to the parameters $a_1, \dots, a_m$. @@ -822,13 +822,13 @@ struct FitResult { Fits data points to a function that depends on some parameters. Parameters: - - xdata: Array of x values. - - ydata: Array of y values. - - errors: Array of experimental errors; each element must be strictly positive - - function: Fit function. - - parameters: Parameter array. Before calling fit(), this must contain the initial guesses for the parameters. - Upon return, it will contain the solution parameters. - - control: object of type FitControl that controls various aspects of the fitting procedure. + - xdata: Array of x values. + - ydata: Array of y values. + - errors: Array of experimental errors; each element must be strictly positive + - function: Fit function. + - parameters: Parameter array. Before calling fit(), this must contain the initial guesses for the parameters. + Upon return, it will contain the solution parameters. + - control: object of type FitControl that controls various aspects of the fitting procedure. Returns: An object of type FitResult that conveys information about the fitting process. @@ -865,12 +865,12 @@ FitResult fit(real[] xdata, real[] ydata, real[] errors, real function(real[], r Fits data points to a function that depends on some parameters. Parameters: - - xdata: Array of x values. - - ydata: Array of y values. - - function: Fit function. - - parameters: Parameter array. Before calling fit(), this must contain the initial guesses for the parameters. - Upon return, it will contain the solution parameters. - - control: object of type FitControl that controls various aspects of the fitting procedure. + - xdata: Array of x values. + - ydata: Array of y values. + - function: Fit function. + - parameters: Parameter array. Before calling fit(), this must contain the initial guesses for the parameters. + Upon return, it will contain the solution parameters. + - control: object of type FitControl that controls various aspects of the fitting procedure. Returns: An object of type FitResult that conveys information about the fitting process. diff --git a/Build/source/utils/asymptote/base/math.asy b/Build/source/utils/asymptote/base/math.asy index ff267b955d7..a684307e5a5 100644 --- a/Build/source/utils/asymptote/base/math.asy +++ b/Build/source/utils/asymptote/base/math.asy @@ -144,6 +144,36 @@ int[][] segment(bool[] b) return segment; } +// If the sorted array a does not contain x, insert it sequentially, +// returning the index of x in the resulting array. +int unique(real[] a, real x) { + int i=search(a,x); + if(i == -1 || x != a[i]) { + ++i; + a.insert(i,x); + return i; + } + return i; +} + +int unique(string[] a, string x) { + int i=search(a,x); + if(i == -1 || x != a[i]) { + ++i; + a.insert(i,x); + return i; + } + return i; +} + +bool lexorder(pair a, pair b) { + return a.x < b.x || (a.x == b.x && a.y <= b.y); +} + +bool lexorder(triple a, triple b) { + return a.x < b.x || (a.x == b.x && (a.y < b.y || (a.y == b.y && a.z <= b.z))); +} + real[] zero(int n) { return sequence(new real(int) {return 0;},n); diff --git a/Build/source/utils/asymptote/base/plain_arrows.asy b/Build/source/utils/asymptote/base/plain_arrows.asy index 5284ee9650d..490f76f777c 100644 --- a/Build/source/utils/asymptote/base/plain_arrows.asy +++ b/Build/source/utils/asymptote/base/plain_arrows.asy @@ -546,18 +546,18 @@ void arrow(picture pic=currentpicture, Label L="", pair b, pair dir, // Fit an array of pictures simultaneously using the sizing of picture all. frame[] fit2(picture[] pictures, picture all) { - frame[] out; - if(!all.empty2()) { - transform t=all.calculateTransform(); - pair m=all.min(t); - pair M=all.max(t); - for(picture pic : pictures) { - frame f=pic.fit(t); - draw(f,m,nullpen); - draw(f,M,nullpen); - out.push(f); - } - } + frame[] out; + if(!all.empty2()) { + transform t=all.calculateTransform(); + pair m=all.min(t); + pair M=all.max(t); + for(picture pic : pictures) { + frame f=pic.fit(t); + draw(f,m,nullpen); + draw(f,M,nullpen); + out.push(f); + } + } return out; } diff --git a/Build/source/utils/asymptote/base/solids.asy b/Build/source/utils/asymptote/base/solids.asy index 7e5883bc884..c9be44552c9 100644 --- a/Build/source/utils/asymptote/base/solids.asy +++ b/Build/source/utils/asymptote/base/solids.asy @@ -347,11 +347,12 @@ surface surface(revolution r, int n=nslice, pen color(int i, real j)=null) void draw(picture pic=currentpicture, revolution r, int m=0, int n=nslice, pen frontpen=currentpen, pen backpen=frontpen, pen longitudinalpen=frontpen, pen longitudinalbackpen=backpen, - light light=currentlight, projection P=currentprojection) + light light=currentlight, string name="", + render render=defaultrender, projection P=currentprojection) { pen thin=is3D() ? thin() : defaultpen; skeleton s=r.skeleton(m,n,P); - begingroup3(pic); + begingroup3(pic,name == "" ? "skeleton" : name,render); if(frontpen != nullpen) { draw(pic,s.transverse.back,thin+defaultbackpen+backpen,light); draw(pic,s.transverse.front,thin+frontpen,light); diff --git a/Build/source/utils/asymptote/base/three.asy b/Build/source/utils/asymptote/base/three.asy index 5b3dd26aba7..b0d9c456faa 100644 --- a/Build/source/utils/asymptote/base/three.asy +++ b/Build/source/utils/asymptote/base/three.asy @@ -11,22 +11,78 @@ if(prc0()) { } } +// Useful lossy compression values. +restricted real Zero=0; +restricted real Low=0.0001; +restricted real Medium=0.001; +restricted real High=0.01; + +restricted int PRCsphere=0; // Renders slowly but produces smaller PRC files. +restricted int NURBSsphere=1; // Renders fast but produces larger PRC files. + +struct render +{ + // PRC parameters: + real compression; // lossy compression parameter (0=no compression) + real granularity; // PRC rendering granularity + + bool closed; // use one-sided rendering? + bool tessellate; // use tessellated mesh to store straight patches? + bool3 merge; // merge nodes before rendering, for lower quality + // but faster PRC rendering? + // (default=merge only transparent patches) + int sphere; // PRC sphere type (PRCsphere or NURBSsphere). + + // General parameters: + real margin; // shrink amount for rendered openGL viewport, in bp. + real tubegranularity; // granularity for rendering tubes + + static render defaultrender; + + void operator init(real compression=defaultrender.compression, + real granularity=defaultrender.granularity, + bool closed=defaultrender.closed, + bool tessellate=defaultrender.tessellate, + bool3 merge=defaultrender.merge, + int sphere=defaultrender.sphere, + real margin=defaultrender.margin, + real tubegranularity=defaultrender.tubegranularity) + { + this.compression=compression; + this.granularity=granularity; + this.closed=closed; + this.tessellate=tessellate; + this.merge=merge; + this.sphere=sphere; + this.margin=margin; + this.tubegranularity=tubegranularity; + } +} + +render operator init() {return render();} + +render defaultrender=render.defaultrender=new render; +defaultrender.compression=High; +defaultrender.granularity=Medium; +defaultrender.closed=false; +defaultrender.tessellate=false; +defaultrender.merge=false; +defaultrender.margin=0.02; +defaultrender.tubegranularity=0.005; +defaultrender.sphere=NURBSsphere; + real defaultshininess=0.25; -real defaultgranularity=0; -real linegranularity=0.005; -int linesectors=8; // Number of angular sectors. -real dotgranularity=0.0001; + real angleprecision=1e-5; // Precision for centering perspective projections. int maxangleiterations=25; -real rendermargin=0.02; string defaultembed3Doptions; string defaultembed3Dscript; real defaulteyetoview=63mm/1000mm; -string partname(string s, int i=0) +string partname(int i=0) { - return s == "" ? "" : s+"-"+string(i); + return string(i+1); } triple O=(0,0,0); @@ -733,7 +789,7 @@ struct Controls { // 3D extension of John Hobby's control point formula // (cf. The MetaFont Book, page 131), // as described in John C. Bowman and A. Hammerlindl, - // TUGBOAT: The Communications of th TeX Users Group 29:2 (2008). + // TUGBOAT: The Communications of the TeX Users Group 29:2 (2008). void operator init(triple v0, triple v1, triple d0, triple d1, real tout, real tin, bool atLeast) { @@ -1995,13 +2051,24 @@ path3 plane(triple u, triple v, triple O=O) include three_light; void draw(frame f, path3 g, material p=currentpen, light light=nolight, - string name="", projection P=currentprojection); + string name="", render render=defaultrender, + projection P=currentprojection); + +void begingroup3(frame f, string name="", render render=defaultrender, + triple center=O, int interaction=0) +{ + _begingroup3(f,name,render.compression,render.granularity,render.closed, + render.tessellate,render.merge == false, + render.merge == true,center,interaction); +} -void begingroup3(picture pic=currentpicture, string name="") +void begingroup3(picture pic=currentpicture, string name="", + render render=defaultrender, + triple center=O, int interaction=0) { pic.add(new void(frame f, transform3, picture pic, projection) { if(is3D()) - begingroup(f,name); + begingroup3(f,name,render,center,interaction); if(pic != null) begingroup(pic); },true); @@ -2011,7 +2078,7 @@ void endgroup3(picture pic=currentpicture) { pic.add(new void(frame f, transform3, picture pic, projection) { if(is3D()) - endgroup(f); + endgroup3(f); if(pic != null) endgroup(pic); },true); @@ -2060,13 +2127,14 @@ pair max(frame f, projection P) void draw(picture pic=currentpicture, Label L="", path3 g, align align=NoAlign, material p=currentpen, margin3 margin=NoMargin3, - light light=nolight, string name="") + light light=nolight, string name="", + render render=defaultrender) { pen q=(pen) p; pic.add(new void(frame f, transform3 t, picture pic, projection P) { path3 G=margin(t*g,q).g; if(is3D()) { - draw(f,G,p,light,name,null); + draw(f,G,p,light,name,render,null); if(pic != null && size(G) > 0) pic.addBox(min(G,P),max(G,P),min(q),max(q)); } @@ -2086,45 +2154,91 @@ include three_tube; draw=new void(frame f, path3 g, material p=currentpen, light light=nolight, string name="", + render render=defaultrender, projection P=currentprojection) { pen q=(pen) p; if(is3D()) { - p=material(p,(p.granularity >= 0) ? p.granularity : linegranularity); + p=material(p); void drawthick(path3 g) { if(settings.thick) { real width=linewidth(q); if(width > 0) { - tube T=tube(g,width,linesectors); + bool prc=prc(); + void cylinder(transform3) {}; + void sphere(transform3, bool half) {}; + void disk(transform3) {}; + void tube(path3, path3); + if(prc) { + cylinder=new void(transform3 t) {drawPRCcylinder(f,t,p,light);}; + sphere=new void(transform3 t, bool half) + {drawPRCsphere(f,t,half,p,light,render);}; + disk=new void(transform3 t) {draw(f,t*unitdisk,p,light);}; + tube=new void(path3 center, path3 g) + {drawPRCtube(f,center,g,p,light);}; + } + real linecap; + real r; + bool open=!cyclic(g); int L=length(g); + triple g0,gL; + if(open && L > 0) { + g0=point(g,0); + gL=point(g,L); + linecap=linecap(q); + r=0.5*width; + if(linecap == 2) { + g0 -= r*dir(g,0); + gL += r*dir(g,L); + g=g0..g..gL; + L += 2; + } + } + tube T=tube(g,width,render,cylinder,sphere,tube); + path3 c=T.center; if(L >= 0) { - if(!cyclic(g)) { - real r=0.5*width; - real linecap=linecap(q); - transform3 scale3r=scale3(r); - surface cap; - triple dirL=dir(g,L); + if(open) { + int Lc=length(c); + triple c0=point(c,0); + triple cL=point(c,Lc); triple dir0=dir(g,0); - if(linecap == 0) - cap=scale(r,r,1)*unitdisk; - else if(linecap == 1) - cap=scale3r*((dir0 == O || dirL == O) ? - unitsphere : unithemisphere); - else if(linecap == 2) { - cap=scale3r*unitcylinder; - cap.append(scale3r*shift(Z)*unitdisk); + triple dirL=dir(g,L); + triple dirc0=dir(c,0); + triple dircL=dir(c,Lc); + transform3 t0=shift(g0)*align(-dir0); + transform3 tL=shift(gL)*align(dirL); + transform3 tc0=shift(c0)*align(-dirc0); + transform3 tcL=shift(cL)*align(dircL); + if(linecap == 0 || linecap == 2){ + transform3 scale2r=scale(r,r,1); + T.s.append(t0*scale2r*unitdisk); + disk(tc0*scale2r); + if(L > 0) { + T.s.append(tL*scale2r*unitdisk); + disk(tcL*scale2r); + } + } else if(linecap == 1) { + transform3 scale3r=scale3(r); + T.s.append(t0*scale3r* + (dir0 != O ? unithemisphere : unitsphere)); + sphere(tc0*scale3r,half=straight(c,0)); + if(L > 0) { + T.s.append(tL*scale3r* + (dirL != O ? unithemisphere : unitsphere)); + sphere(tcL*scale3r,half=straight(c,Lc-1)); + } } - T.s.append(shift(point(g,0))*align(-dir0)*cap); - T.s.append(shift(point(g,L))*align(dirL)*cap); } if(opacity(q) == 1) - _draw(f,T.center,q,name); + _draw(f,c,q); } - for(int i=0; i < T.s.s.length; ++i) - draw3D(f,T.s.s[i],p,light,partname(name,i)); - } else _draw(f,g,q,name); - } else _draw(f,g,q,name); + for(patch s : T.s.s) + draw3D(f,s,p,light,prc=false); + } else _draw(f,g,q); + } else _draw(f,g,q); } real[] dash=linetype(adjust(q,arclength(g),cyclic(g))); + if(q != nullpen) + begingroup3(f,name == "" ? "curve" : name,render); if(dash.length == 0) drawthick(g); else { if(sum(dash) > 0) { @@ -2144,22 +2258,33 @@ draw=new void(frame f, path3 g, material p=currentpen, } } } + if(q != nullpen) + endgroup3(f); } else draw(f,project(g,P),q); }; void draw(frame f, explicit path3[] g, material p=currentpen, - light light=nolight, string name="", projection P=currentprojection) + light light=nolight, string name="", + render render=defaultrender, projection P=currentprojection) { + if(g.length > 1) + begingroup3(f,name == "" ? "curve" : name,render); for(int i=0; i < g.length; ++i) - draw(f,g[i],p,light,partname(name,i),P); + draw(f,g[i],p,light,partname(i),render,P); + if(g.length > 1) + endgroup3(f); } void draw(picture pic=currentpicture, explicit path3[] g, material p=currentpen, margin3 margin=NoMargin3, light light=nolight, - string name="") + string name="", render render=defaultrender) { + if(g.length > 1) + begingroup3(pic,name == "" ? "curves" : name,render); for(int i=0; i < g.length; ++i) - draw(pic,g[i],p,margin,light,partname(name,i)); + draw(pic,g[i],p,margin,light,partname(i),render); + if(g.length > 1) + endgroup3(pic); } include three_arrows; @@ -2167,24 +2292,34 @@ include three_arrows; void draw(picture pic=currentpicture, Label L="", path3 g, align align=NoAlign, material p=currentpen, arrowbar3 arrow, arrowbar3 bar=None, margin3 margin=NoMargin3, light light=nolight, - light arrowheadlight=currentlight, string name="") + light arrowheadlight=currentlight, string name="", + render render=defaultrender) { - begingroup3(pic); + bool group=arrow != None || bar != None; + if(group) + begingroup3(pic,name,render); bool drawpath=arrow(pic,g,p,margin,light,arrowheadlight); if(bar(pic,g,p,margin,light,arrowheadlight) && drawpath) - draw(pic,L,g,align,p,margin,light,name); - endgroup3(pic); + draw(pic,L,g,align,p,margin,light); + if(group) + endgroup3(pic); label(pic,L,g,align,(pen) p); } void draw(frame f, path3 g, material p=currentpen, arrowbar3 arrow, light light=nolight, light arrowheadlight=currentlight, - string name="", projection P=currentprojection) + string name="", render render=defaultrender, + projection P=currentprojection) { picture pic; + bool group=arrow != None; + if(group) + begingroup3(f,name,render); if(arrow(pic,g,p,NoMargin3,light,arrowheadlight)) - draw(f,g,p,light,name,P); + draw(f,g,p,light,P); add(f,pic.fit()); + if(group) + endgroup3(f); } void add(picture pic=currentpicture, void d(picture,transform3), @@ -2300,14 +2435,38 @@ private struct viewpoint { triple target,camera,up; real angle; void operator init(string s) { - s=replace(s,new string[][] {{" ",","},{"}{",","},{"{",""},{"}",""},}); - string[] S=split(s,","); - target=((real) S[0],(real) S[1],(real) S[2])*cm; - camera=target+(real) S[6]*((real) S[3],(real) S[4],(real) S[5])*cm; + s=replace(s,'\n'," "); + string[] S=split(s); + int pos(string s, string key) { + int pos=find(s,key); + if(pos < 0) return -1; + pos += length(key); + while(substr(s,pos,1) == " ") ++pos; + if(substr(s,pos,1) == "=") + return pos+1; + return -1; + } + triple C2C=X; + real ROO=1; + real ROLL=0; + angle=30; + int pos; + for(int k=0; k < S.length; ++k) { + if((pos=pos(S[k],"COO")) >= 0) + target=((real) substr(S[k],pos),(real) S[++k],(real) S[++k]); + else if((pos=pos(S[k],"C2C")) >= 0) + C2C=((real) substr(S[k],pos),(real) S[++k],(real) S[++k]); + else if((pos=pos(S[k],"ROO")) >= 0) + ROO=(real) substr(S[k],pos); + else if((pos=pos(S[k],"ROLL")) >= 0) + ROLL=(real) substr(S[k],pos); + else if((pos=pos(S[k],"AAC")) >= 0) + angle=(real) substr(S[k],pos); + } + camera=target+ROO*C2C; triple u=unit(target-camera); triple w=unit(Z-u.z*u); - up=rotate((real) S[7],O,u)*w; - angle=S[8] == "" ? 30 : (real) S[8]; + up=rotate(ROLL,O,u)*w; } } @@ -2393,13 +2552,13 @@ private string billboard(int[] index, triple[] center) if(index.length == 0) return ""; string s=" var zero=new Vector3(0,0,0); -var meshes=scene.meshes; -var count=meshes.count; +var nodes=scene.nodes; +var count=nodes.count; var index=new Array(); for(i=0; i < count; i++) { - var mesh=meshes.getByIndex(i); - var name=mesh.name; + var node=nodes.getByIndex(i); + var name=node.name; end=name.lastIndexOf(\".\")-1; if(end > 0) { if(name.substr(end,1) == \"\001\") { @@ -2407,7 +2566,7 @@ for(i=0; i < count; i++) { n=end-start; if(n > 0) { index[name.substr(start,n)]=i; - mesh.name=name.substr(0,start-1); + node.name=name.substr(0,start-1); } } } @@ -2416,7 +2575,7 @@ for(i=0; i < count; i++) { var center=new Array( "; for(int i=0; i < center.length; ++i) - s += "Vector3("+format(center[i]/cm,",")+"), + s += "Vector3("+format(center[i],",")+"), "; s += "); @@ -2431,12 +2590,12 @@ billboardHandler.onEvent=function(event) function f(i,k) { j=index[i]; if(j >= 0) { - var mesh=meshes.getByIndex(j); - var name=mesh.name; + var node=nodes.getByIndex(j); + var name=node.name; var R=Matrix4x4(); R.setView(zero,direction,up); var c=center[k]; - var T=mesh.transform; + var T=node.transform; T.setIdentity(); T.translateInPlace(c.scale(-1)); T.multiplyInPlace(R); @@ -2513,13 +2672,13 @@ string embed3D(string label="", string text=label, string prefix, if(script == "") script=defaultembed3Dscript; // Adobe Reader doesn't appear to support user-specified viewport lights. - string lightscript=light.on() && !light.viewport ? lightscript(light) : ""; + string lightscript=light.on() && light.viewport ? "" : lightscript(light); real viewplanesize; if(P.infinity) { triple lambda=max3(f)-min3(f); pair margin=viewportmargin((lambda.x,lambda.y)); - viewplanesize=(max(lambda.x+2*margin.x,lambda.y+2*margin.y))/(cm*P.zoom); + viewplanesize=(max(lambda.x+2*margin.x,lambda.y+2*margin.y))/P.zoom; } else if(!P.absolute) P.angle=2*aTan(Tan(0.5*P.angle)); @@ -2542,7 +2701,7 @@ string embed3D(string label="", string text=label, string prefix, P.viewportshift.y*lambda.y/P.zoom,0); } - triple v=P.vector()/cm; + triple v=P.vector(); triple u=unit(v); triple w=Z-u.z*u; real roll; @@ -2560,7 +2719,7 @@ string embed3D(string label="", string text=label, string prefix, ",toolbar="+(settings.toolbar ? "true" : "false")+ ",3Daac="+Format(P.angle)+ ",3Dc2c="+Format(u)+ - ",3Dcoo="+Format(target/cm)+ + ",3Dcoo="+Format(target)+ ",3Droll="+Format(roll)+ ",3Droo="+Format(abs(v))+ ",3Dbg="+Format(light.background()); @@ -2613,7 +2772,7 @@ struct scene if(this.P.center && settings.render != 0) { triple target=0.5*(m+M); this.P.target=target; - this.P.calculate(); + this.P.calculate(); } if(this.P.autoadjust || this.P.infinity) adjusted=adjusted | this.P.adjust(m,M); @@ -2796,7 +2955,7 @@ object embed(string label="", string text=label, string prefix=defaultfilename, } else if(M.z >= 0) abort("camera too close"); shipout3(prefix,f,preview ? nativeformat() : format, - S.width-rendermargin,S.height-rendermargin, + S.width-defaultrender.margin,S.height-defaultrender.margin, P.infinity ? 0 : 2aTan(Tan(0.5*P.angle)*P.zoom), P.zoom,m,M,P.viewportshift, tinv*inverse(modelview)*shift(0,0,zcenter),light.background(), diff --git a/Build/source/utils/asymptote/base/three_arrows.asy b/Build/source/utils/asymptote/base/three_arrows.asy index b4319219284..d81650ec948 100644 --- a/Build/source/utils/asymptote/base/three_arrows.asy +++ b/Build/source/utils/asymptote/base/three_arrows.asy @@ -106,7 +106,7 @@ struct arrowhead3 } if(draw) for(path3 g : H) - s.append(tube(g,width,linesectors).s); + s.append(tube(g,width).s); return shift(v)*s; } diff --git a/Build/source/utils/asymptote/base/three_light.asy b/Build/source/utils/asymptote/base/three_light.asy index 36ba9a34c19..eb85ed0c3e5 100644 --- a/Build/source/utils/asymptote/base/three_light.asy +++ b/Build/source/utils/asymptote/base/three_light.asy @@ -2,27 +2,24 @@ struct material { pen[] p; // diffusepen,ambientpen,emissivepen,specularpen real opacity; real shininess; - real granularity; void operator init(pen diffusepen=black, pen ambientpen=black, pen emissivepen=black, pen specularpen=mediumgray, real opacity=opacity(diffusepen), - real shininess=defaultshininess, - real granularity=-1) { + real shininess=defaultshininess) { p=new pen[] {diffusepen,ambientpen,emissivepen,specularpen}; this.opacity=opacity; this.shininess=shininess; - this.granularity=granularity; } - void operator init(material m, real granularity=m.granularity) { + void operator init(material m) { p=copy(m.p); opacity=m.opacity; shininess=m.shininess; - this.granularity=granularity; } pen diffuse() {return p[0];} pen ambient() {return p[1];} pen emissive() {return p[2];} pen specular() {return p[3];} + void diffuse(pen q) {p[0]=q;} void ambient(pen q) {p[1]=q;} void emissive(pen q) {p[2]=q;} @@ -39,7 +36,6 @@ void write(file file, string s="", material x, suffix suffix=none) write(file,", specular=",x.specular()); write(file,", opacity=",x.opacity); write(file,", shininess=",x.shininess); - write(file,", granularity=",x.granularity); write(file,"}",suffix); } @@ -51,7 +47,7 @@ void write(string s="", material x, suffix suffix=endl) bool operator == (material m, material n) { return all(m.p == n.p) && m.opacity == n.opacity && - m.shininess == n.shininess && m.granularity == n.granularity; + m.shininess == n.shininess; } material operator cast(pen p) @@ -69,10 +65,9 @@ pen operator ecast(material m) return m.p.length > 0 ? m.diffuse() : nullpen; } -material emissive(material m, real granularity=m.granularity) +material emissive(material m) { - return material(black+opacity(m.opacity),black,m.diffuse(),black,m.opacity,1, - granularity); + return material(black+opacity(m.opacity),black,m.diffuse(),black,m.opacity,1); } pen color(triple normal, material m, light light, transform3 T=light.T) { diff --git a/Build/source/utils/asymptote/base/three_surface.asy b/Build/source/utils/asymptote/base/three_surface.asy index 1be7eb0259c..e00acfa8367 100644 --- a/Build/source/utils/asymptote/base/three_surface.asy +++ b/Build/source/utils/asymptote/base/three_surface.asy @@ -4,6 +4,8 @@ private import interpolate; int nslice=12; real camerafactor=1.2; +string meshname(string name) {return name+" mesh";} + private real Fuzz=10.0*realEpsilon; private real nineth=1/9; @@ -1148,22 +1150,53 @@ interaction LabelInteraction() return settings.autobillboard ? Billboard : Embedded; } -void draw3D(frame f, patch s, triple center=O, material m, - light light=currentlight, string name="", - interaction interaction=Embedded) +private material material(material m, light light) +{ + return light.on() || invisible((pen) m) ? m : emissive(m); +} + +void draw3D(frame f, int type=0, patch s, triple center=O, material m, + light light=currentlight, interaction interaction=Embedded, + bool prc=true) { if(s.colors.length > 0) m=mean(s.colors); - bool lighton=light.on(); - if(!lighton && !invisible((pen) m)) - m=emissive(m); + m=material(m,light); real PRCshininess; if(prc()) PRCshininess=PRCshininess(m.shininess); - real granularity=m.granularity >= 0 ? m.granularity : defaultgranularity; + draw(f,s.P,center,s.straight,m.p,m.opacity,m.shininess,PRCshininess, - granularity,s.planar ? s.normal(0.5,0.5) : O,s.colors,lighton,name, - interaction.type); + s.planar ? s.normal(0.5,0.5) : O,s.colors, + light.on(),interaction.type,prc); +} + +void drawPRCsphere(frame f, transform3 t=identity4, bool half=false, material m, + light light=currentlight, render render=defaultrender) +{ + m=material(m,light); + drawPRCsphere(f,t,half,m.p,m.opacity,PRCshininess(m.shininess),render.sphere); +} + +void drawPRCcylinder(frame f, transform3 t=identity4, material m, + light light=currentlight) +{ + m=material(m,light); + drawPRCcylinder(f,t,m.p,m.opacity,PRCshininess(m.shininess)); +} + +void drawPRCdisk(frame f, transform3 t=identity4, material m, + light light=currentlight) +{ + m=material(m,light); + drawPRCdisk(f,t,m.p,m.opacity,PRCshininess(m.shininess)); +} + +void drawPRCtube(frame f, path3 center, path3 g, material m, + light light=currentlight) +{ + m=material(m,light); + drawPRCtube(f,center,g,m.p,m.opacity,PRCshininess(m.shininess)); } void tensorshade(transform t=identity(), frame f, patch s, @@ -1180,22 +1213,28 @@ nullpens.cyclic=true; void draw(transform t=identity(), frame f, surface s, int nu=1, int nv=1, material[] surfacepen, pen[] meshpen=nullpens, light light=currentlight, light meshlight=light, string name="", - projection P=currentprojection) + render render=defaultrender, projection P=currentprojection) { if(is3D()) { + begingroup3(f,name == "" ? "surface" : name,render); for(int i=0; i < s.s.length; ++i) - draw3D(f,s.s[i],surfacepen[i],light,partname(name,i)); + draw3D(f,s.s[i],surfacepen[i],light); + endgroup3(f); pen modifiers=thin()+squarecap; for(int k=0; k < s.s.length; ++k) { pen meshpen=meshpen[k]; if(!invisible(meshpen)) { + begingroup3(f,meshname(name),render); meshpen=modifiers+meshpen; real step=nu == 0 ? 0 : 1/nu; for(int i=0; i <= nu; ++i) - draw(f,s.s[k].uequals(i*step),meshpen,meshlight); + draw(f,s.s[k].uequals(i*step),meshpen,meshlight,partname(i), + render); step=nv == 0 ? 0 : 1/nv; for(int j=0; j <= nv; ++j) - draw(f,s.s[k].vequals(j*step),meshpen,meshlight); + draw(f,s.s[k].vequals(j*step),meshpen,meshlight,partname(j), + render); + endgroup3(f); } } } else { @@ -1232,18 +1271,19 @@ void draw(transform t=identity(), frame f, surface s, int nu=1, int nv=1, void draw(transform t=identity(), frame f, surface s, int nu=1, int nv=1, material surfacepen=currentpen, pen meshpen=nullpen, light light=currentlight, light meshlight=light, string name="", - projection P=currentprojection) + render render=defaultrender, projection P=currentprojection) { material[] surfacepen={surfacepen}; pen[] meshpen={meshpen}; surfacepen.cyclic=true; meshpen.cyclic=true; - draw(t,f,s,nu,nv,surfacepen,meshpen,light,meshlight,name,P); + draw(t,f,s,nu,nv,surfacepen,meshpen,light,meshlight,name,render,P); } void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen[] meshpen=nullpens, - light light=currentlight, light meshlight=light, string name="") + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender) { if(s.empty()) return; @@ -1257,7 +1297,7 @@ void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, pic.add(new void(frame f, transform3 t, picture pic, projection P) { surface S=t*s; if(is3D()) - draw(f,S,nu,nv,surfacepen,meshpen,light,meshlight,name); + draw(f,S,nu,nv,surfacepen,meshpen,light,meshlight,name,render); else if(pic != null) pic.add(new void(frame f, transform T) { draw(T,f,S,nu,nv,surfacepen,meshpen,light,meshlight,P); @@ -1288,22 +1328,24 @@ void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material surfacepen=currentpen, pen meshpen=nullpen, - light light=currentlight, light meshlight=light, string name="") + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender) { material[] surfacepen={surfacepen}; pen[] meshpen={meshpen}; surfacepen.cyclic=true; meshpen.cyclic=true; - draw(pic,s,nu,nv,surfacepen,meshpen,light,meshlight,name); + draw(pic,s,nu,nv,surfacepen,meshpen,light,meshlight,name,render); } void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen meshpen, - light light=currentlight, light meshlight=light, string name="") + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender) { pen[] meshpen={meshpen}; meshpen.cyclic=true; - draw(pic,s,nu,nv,surfacepen,meshpen,light,meshlight,name); + draw(pic,s,nu,nv,surfacepen,meshpen,light,meshlight,name,render); } surface extrude(path3 p, path3 q) @@ -1376,7 +1418,8 @@ private path[] path(Label L, pair z=0, projection P) void label(frame f, Label L, triple position, align align=NoAlign, pen p=currentpen, light light=nolight, - string name=L.s, interaction interaction=LabelInteraction(), + string name="", render render=defaultrender, + interaction interaction=LabelInteraction(), projection P=currentprojection) { Label L=L.copy(); @@ -1386,10 +1429,10 @@ void label(frame f, Label L, triple position, align align=NoAlign, L.T=L.T*scale(abs(P.camera-position)/abs(P.vector())); if(L.defaulttransform3) L.T3=transform3(P); + begingroup3(f,name == "" ? L.s : name,render); if(is3D()) { - int i=-1; for(patch S : surface(L,position).s) - draw3D(f,S,position,L.p,light,partname(name,++i),interaction); + draw3D(f,S,position,L.p,light,interaction); } else { pen p=color(L.T3*Z,L.p,light,shiftless(P.T.modelview)); if(L.defaulttransform3) { @@ -1404,11 +1447,13 @@ void label(frame f, Label L, triple position, align align=NoAlign, for(patch S : surface(L,position).s) fill(f,project(S.external(),P,1),p); } + endgroup3(f); } void label(picture pic=currentpicture, Label L, triple position, align align=NoAlign, pen p=currentpen, - light light=nolight, string name=L.s, + light light=nolight, string name="", + render render=defaultrender, interaction interaction=LabelInteraction()) { Label L=L.copy(); @@ -1421,18 +1466,18 @@ void label(picture pic=currentpicture, Label L, triple position, triple v=t*position; if(!align.is3D && L.align.relative && L.align.dir3 != O && determinant(P.t) != 0) - L.align(L.align.dir*unit(project(v+L.align.dir3,P.t)-project(v,P.t))); + L.align(L.align.dir*unit(project(v+L.align.dir3,P.t)-project(v,P.t))); if(interaction.targetsize && settings.render != 0) L.T=L.T*scale(abs(P.camera-v)/abs(P.vector())); if(L.defaulttransform3) L.T3=transform3(P); - if(is3D()) { - int i=-1; + surface S=surface(L,v); + begingroup3(f,name == "" ? L.s : name,render,v,interaction.type); + if(is3D()) for(patch S : surface(L,v).s) - draw3D(f,S,v,L.p,light,partname(name,++i),interaction); - } + draw3D(f,S,v,L.p,light,interaction); if(pic != null) { pen p=color(L.T3*Z,L.p,light,shiftless(P.T.modelview)); @@ -1450,6 +1495,7 @@ void label(picture pic=currentpicture, Label L, triple position, fill(f,T*project(S.external(),P,1),p); }); } + endgroup3(f); },!L.defaulttransform3); @@ -1467,7 +1513,7 @@ void label(picture pic=currentpicture, Label L, triple position, } void label(picture pic=currentpicture, Label L, path3 g, align align=NoAlign, - pen p=currentpen, string name=L.s, + pen p=currentpen, light light=nolight, string name="", interaction interaction=LabelInteraction()) { Label L=L.copy(); @@ -1480,11 +1526,11 @@ void label(picture pic=currentpicture, Label L, path3 g, align align=NoAlign, if(L.align.default) { align a; a.init(-I*(position <= sqrtEpsilon ? S : - position >= length(g)-sqrtEpsilon ? N : E),relative=true); + position >= length(g)-sqrtEpsilon ? N : E),relative=true); a.dir3=dir(g,position); // Pass 3D direction via unused field. L.align(a); } - label(pic,L,point(g,position),name,interaction); + label(pic,L,point(g,position),light,name,interaction); } surface extrude(Label L, triple axis=Z) @@ -1609,67 +1655,143 @@ restricted surface unitplane=surface(unitplane); restricted surface unitdisk=surface(unitcircle3); void dot(frame f, triple v, material p=currentpen, - light light=nolight, string name="", projection P=currentprojection) + light light=nolight, string name="", + render render=defaultrender, projection P=currentprojection) { pen q=(pen) p; if(is3D()) { - material m=material(p,p.granularity >= 0 ? p.granularity : dotgranularity); - int i=-1; + begingroup3(f,name == "" ? "dot" : name,render); + real size=0.5*linewidth(dotsize(q)+q); + transform3 T=shift(v)*scale3(size); for(patch s : unitsphere.s) - draw3D(f,shift(v)*scale3(0.5*linewidth(dotsize(q)+q))*s,m,light, - partname(name,++i)); + draw3D(f,T*s,v,p,light,prc=false); + if(prc()) + drawPRCsphere(f,T,p,light); + endgroup3(f); } else dot(f,project(v,P.t),q); } -void dot(frame f, path3 g, material p=currentpen, +void dot(frame f, triple[] v, material p=currentpen, light light=nolight, + string name="", render render=defaultrender, + projection P=currentprojection) +{ + if(v.length > 0) { + // Remove duplicate points. + v=sort(v,lexorder); + + triple last=v[0]; + dot(f,last,p,light,name,P); + for(int i=1; i < v.length; ++i) { + triple V=v[i]; + if(V != last) { + dot(f,V,p,light,name,render,P); + last=V; + } + } + } +} + +void dot(frame f, path3 g, material p=currentpen, light light=nolight, + string name="", render render=defaultrender, projection P=currentprojection) { - for(int i=0; i <= length(g); ++i) dot(f,point(g,i),p,P); + dot(f,sequence(new triple(int i) {return point(g,i);},size(g)), + p,light,name,render,P); } -void dot(frame f, path3[] g, material p=currentpen, +void dot(frame f, path3[] g, material p=currentpen, light light=nolight, + string name="", render render=defaultrender, projection P=currentprojection) { - for(int i=0; i < g.length; ++i) dot(f,g[i],p,P); + int sum; + for(path3 G : g) + sum += size(G); + int i,j; + dot(f,sequence(new triple(int) { + while(j >= size(g[i])) { + ++i; + j=0; + } + triple v=point(g[i],j); + ++j; + return v; + },sum),p,light,name,render,P); } void dot(picture pic=currentpicture, triple v, material p=currentpen, - light light=nolight, string name="") + light light=nolight, string name="", render render=defaultrender) { pen q=(pen) p; real size=0.5*linewidth(dotsize(q)+q); pic.add(new void(frame f, transform3 t, picture pic, projection P) { + triple V=t*v; if(is3D()) { - material m=material(p,p.granularity >= 0 ? p.granularity : - dotgranularity); - int i=-1; + begingroup3(f,name == "" ? "dot" : name,render); + transform3 T=shift(V)*scale3(size); for(patch s : unitsphere.s) - draw3D(f,shift(t*v)*scale3(size)*s,m,light,partname(name,++i)); + draw3D(f,T*s,V,p,light,prc=false); + if(prc()) + drawPRCsphere(f,T,p,light,render); + endgroup3(f); } if(pic != null) - dot(pic,project(t*v,P.t),q); + dot(pic,project(V,P.t),q); },true); triple R=size*(1,1,1); pic.addBox(v,v,-R,R); } -void dot(picture pic=currentpicture, triple[] v, material p=currentpen) +void dot(picture pic=currentpicture, triple[] v, material p=currentpen, + light light=nolight, string name="", render render=defaultrender) { - for(int i=0; i < v.length; ++i) dot(pic,v[i],p); + if(v.length > 0) { + // Remove duplicate points. + v=sort(v,lexorder); + + triple last=v[0]; + begingroup3(pic,name == "" ? "dots" : name,render); + dot(pic,last,p,light,partname(0),render); + int k=0; + for(int i=1; i < v.length; ++i) { + triple V=v[i]; + if(V != last) { + dot(pic,V,p,light,partname(++k),render); + last=V; + } + } + endgroup3(pic); + } } -void dot(picture pic=currentpicture, explicit path3 g, material p=currentpen) +void dot(picture pic=currentpicture, explicit path3 g, material p=currentpen, + light light=nolight, string name="", + render render=defaultrender) { - for(int i=0; i <= length(g); ++i) dot(pic,point(g,i),p); + dot(pic,sequence(new triple(int i) {return point(g,i);},size(g)), + p,light,name,render); } -void dot(picture pic=currentpicture, path3[] g, material p=currentpen) +void dot(picture pic=currentpicture, path3[] g, material p=currentpen, + light light=nolight, string name="", render render=defaultrender) { - for(int i=0; i < g.length; ++i) dot(pic,g[i],p); + int sum; + for(path3 G : g) + sum += size(G); + int i,j; + dot(pic,sequence(new triple(int) { + while(j >= size(g[i])) { + ++i; + j=0; + } + triple v=point(g[i],j); + ++j; + return v; + },sum),p,light,name,render); } void dot(picture pic=currentpicture, Label L, triple v, align align=NoAlign, - string format=defaultformat, material p=currentpen) + string format=defaultformat, material p=currentpen, + light light=nolight, string name="", render render=defaultrender) { Label L=L.copy(); if(L.s == "") { @@ -1679,8 +1801,8 @@ void dot(picture pic=currentpicture, Label L, triple v, align align=NoAlign, } L.align(align,E); L.p((pen) p); - dot(pic,v,p); - label(pic,L,v); + dot(pic,v,p,light,name,render); + label(pic,L,v,render); } pair minbound(triple[] A, projection P) @@ -1734,7 +1856,8 @@ triple[][] operator / (triple[][] a, real[][] b) // Draw a NURBS curve. void draw(picture pic=currentpicture, triple[] P, real[] knot, - real[] weights=new real[], pen p=currentpen, string name="") + real[] weights=new real[], pen p=currentpen, string name="", + render render=defaultrender) { P=copy(P); knot=copy(knot); @@ -1742,7 +1865,9 @@ void draw(picture pic=currentpicture, triple[] P, real[] knot, pic.add(new void(frame f, transform3 t, picture pic, projection Q) { if(is3D()) { triple[] P=t*P; - draw(f,P,knot,weights,p,name); + begingroup3(f,name == "" ? "curve" : name,render); + draw(f,P,knot,weights,p); + endgroup3(f); if(pic != null) pic.addBox(minbound(P,Q),maxbound(P,Q)); } @@ -1753,7 +1878,8 @@ void draw(picture pic=currentpicture, triple[] P, real[] knot, // Draw a NURBS surface. void draw(picture pic=currentpicture, triple[][] P, real[] uknot, real[] vknot, real[][] weights=new real[][], material m=currentpen, - pen[] colors=new pen[], light light=currentlight, string name="") + pen[] colors=new pen[], light light=currentlight, string name="", + render render=defaultrender) { if(colors.length > 0) m=mean(colors); @@ -1765,14 +1891,14 @@ void draw(picture pic=currentpicture, triple[][] P, real[] uknot, real[] vknot, colors=copy(colors); pic.add(new void(frame f, transform3 t, picture pic, projection Q) { if(is3D()) { + begingroup3(f,name == "" ? "surface" : name,render); triple[][] P=t*P; - real granularity=m.granularity >= 0 ? m.granularity : - defaultgranularity; real PRCshininess; if(prc()) PRCshininess=PRCshininess(m.shininess); draw(f,P,uknot,vknot,weights,m.p,m.opacity,m.shininess,PRCshininess, - granularity,colors,lighton,name); + colors,lighton); + endgroup3(f); if(pic != null) pic.addBox(minbound(P,Q),maxbound(P,Q)); } diff --git a/Build/source/utils/asymptote/base/three_tube.asy b/Build/source/utils/asymptote/base/three_tube.asy index c79ae3f619f..2eb5e4cf716 100644 --- a/Build/source/utils/asymptote/base/three_tube.asy +++ b/Build/source/utils/asymptote/base/three_tube.asy @@ -1,5 +1,6 @@ -void render(path3 s, real granularity=linegranularity, void f(path3, real)) +void render(path3 s, void f(path3, real), render render=defaultrender) { + real granularity=render.tubegranularity; void Split(triple z0, triple c0, triple c1, triple z1, real t0=0, real t1=1, real depth=mantissaBits) { if(depth > 0) { @@ -65,8 +66,8 @@ rmf[] rmf(path3 g, real[] t) return R; } -surface bispline(real[][] z, real[][] p, real[][] q, real[][] r, - real[] x, real[] y, bool[][] cond={}) +private real[][][] bispline0(real[][] z, real[][] p, real[][] q, real[][] r, + real[] x, real[] y, bool[][] cond={}) { // z[i][j] is the value at (x[i],y[j]) // p and q are the first derivatives with respect to x and y, respectively // r is the second derivative ddu/dxdy @@ -87,62 +88,49 @@ surface bispline(real[][] z, real[][] p, real[][] q, real[][] r, } } - surface s=surface(count); - s.index=new int[n][m]; - int k=-1; + real[][][] s=new real[count][][]; + int k=0; for(int i=0; i < n; ++i) { + int ip=i+1; bool[] condi=all ? null : cond[i]; real xi=x[i]; real[] zi=z[i]; - real[] zp=z[i+1]; + real[] zp=z[ip]; real[] ri=r[i]; - real[] rp=r[i+1]; + real[] rp=r[ip]; real[] pi=p[i]; - real[] pp=p[i+1]; + real[] pp=p[ip]; real[] qi=q[i]; - real[] qp=q[i+1]; - real xp=x[i+1]; + real[] qp=q[ip]; + real xp=x[ip]; real hx=(xp-xi)/3; - int[] indexi=s.index[i]; for(int j=0; j < m; ++j) { real yj=y[j]; - real yp=y[j+1]; + int jp=j+1; + real yp=y[jp]; if(all || condi[j]) { - triple[][] P=array(4,array(4,O)); real hy=(yp-yj)/3; real hxy=hx*hy; - // x and y directions - for(int k=0; k < 4; ++k) { - P[0][k] += xi*X; - P[k][0] += yj*Y; - P[1][k] += (xp+2*xi)/3*X; - P[k][1] += (yp+2*yj)/3*Y; - P[2][k] += (2*xp+xi)/3*X; - P[k][2] += (2*yp+yj)/3*Y; - P[3][k] += xp*X; - P[k][3] += yp*Y; - } - // z: value - P[0][0] += zi[j]*Z; - P[3][0] += zp[j]*Z; - P[0][3] += zi[j+1]*Z; - P[3][3] += zp[j+1]*Z; - // z: first derivative - P[1][0] += (P[0][0].z+hx*pi[j])*Z; - P[1][3] += (P[0][3].z+hx*pi[j+1])*Z; - P[2][0] += (P[3][0].z-hx*pp[j])*Z; - P[2][3] += (P[3][3].z-hx*pp[j+1])*Z; - P[0][1] += (P[0][0].z+hy*qi[j])*Z; - P[3][1] += (P[3][0].z+hy*qp[j])*Z; - P[0][2] += (P[0][3].z-hy*qi[j+1])*Z; - P[3][2] += (P[3][3].z-hy*qp[j+1])*Z; - // z: second derivative - P[1][1] += (P[0][1].z+P[1][0].z-P[0][0].z+hxy*ri[j])*Z; - P[1][2] += (P[0][2].z+P[1][3].z-P[0][3].z-hxy*ri[j+1])*Z; - P[2][1] += (P[2][0].z+P[3][1].z-P[3][0].z-hxy*rp[j])*Z; - P[2][2] += (P[2][3].z+P[3][2].z-P[3][3].z+hxy*rp[j+1])*Z; - s.s[++k]=patch(P); - indexi[j]=k; + real zij=zi[j]; + real zip=zi[jp]; + real zpj=zp[j]; + real zpp=zp[jp]; + real pij=hx*pi[j]; + real ppj=hx*pp[j]; + real qip=hy*qi[jp]; + real qpp=hy*qp[jp]; + real zippip=zip+hx*pi[jp]; + real zppmppp=zpp-hx*pp[jp]; + real zijqij=zij+hy*qi[j]; + real zpjqpj=zpj+hy*qp[j]; + + s[k]=new real[][] {{zij,zijqij,zip-qip,zip}, + {zij+pij,zijqij+pij+hxy*ri[j], + zippip-qip-hxy*ri[jp],zippip}, + {zpj-ppj,zpjqpj-ppj-hxy*rp[j], + zppmppp-qpp+hxy*rp[jp],zppmppp}, + {zpj,zpjqpj,zpp-qpp,zpp}}; + ++k; } } } @@ -150,11 +138,11 @@ surface bispline(real[][] z, real[][] p, real[][] q, real[][] r, return s; } -// return the surface described by a real matrix f, interpolated with +// return the surface values described by a real matrix f, interpolated with // xsplinetype and ysplinetype. -surface surface(real[][] f, real[] x, real[] y, - splinetype xsplinetype=null, splinetype ysplinetype=xsplinetype, - bool[][] cond={}) +real[][][] bispline(real[][] f, real[] x, real[] y, + splinetype xsplinetype=null, + splinetype ysplinetype=xsplinetype, bool[][] cond={}) { real epsilon=sqrtEpsilon*norm(y); if(xsplinetype == null) @@ -176,9 +164,7 @@ surface surface(real[][] f, real[] x, real[] y, real[][] p=transpose(tp); for(int i=0; i < n; ++i) r[i]=clamped(d1[i],d2[i])(y,p[i]); - surface s=bispline(f,p,q,r,x,y,cond); - if(xsplinetype == periodic) s.ucyclic(true); - if(ysplinetype == periodic) s.vcyclic(true); + real[][][] s=bispline0(f,p,q,r,x,y,cond); return s; } @@ -248,11 +234,11 @@ surface surface(triple f(pair z), real[] u, real[] v, vperiodic(fz) ? periodic : notaknot}; } else if(vsplinetype.length != 3) abort("vsplinetype must have length 3"); - surface sx=surface(fx,ipt,jpt,usplinetype[0],vsplinetype[0],active); - surface sy=surface(fy,ipt,jpt,usplinetype[1],vsplinetype[1],active); - surface sz=surface(fz,ipt,jpt,usplinetype[2],vsplinetype[2],active); + real[][][] sx=bispline(fx,ipt,jpt,usplinetype[0],vsplinetype[0],active); + real[][][] sy=bispline(fy,ipt,jpt,usplinetype[1],vsplinetype[1],active); + real[][][] sz=bispline(fz,ipt,jpt,usplinetype[2],vsplinetype[2],active); - surface s=surface(sx.s.length); + surface s=surface(sx.length); s.index=new int[nu][nv]; int k=-1; for(int i=0; i < nu; ++i) { @@ -261,12 +247,20 @@ surface surface(triple f(pair z), real[] u, real[] v, indexi[j]=++k; } - for(int k=0; k < sx.s.length; ++k) { + for(int k=0; k < sx.length; ++k) { triple[][] Q=new triple[4][]; - for(int i=0; i < 4 ; ++i) - Q[i]=sequence(new triple(int j) { - return (sx.s[k].P[i][j].z,sy.s[k].P[i][j].z,sz.s[k].P[i][j].z); - },4); + real[][] Px=sx[k]; + real[][] Py=sy[k]; + real[][] Pz=sz[k]; + for(int i=0; i < 4 ; ++i) { + real[] Pxi=Px[i]; + real[] Pyi=Py[i]; + real[] Pzi=Pz[i]; + Q[i]=new triple[] {(Pxi[0],Pyi[0],Pzi[0]), + (Pxi[1],Pyi[1],Pzi[1]), + (Pxi[2],Pyi[2],Pzi[2]), + (Pxi[3],Pyi[3],Pzi[3])}; + } s.s[k]=patch(Q); } @@ -282,8 +276,8 @@ surface surface(triple f(pair z), real[] u, real[] v, path3 interp(path3 a, path3 b, real t) { int n=size(a); - return path3(sequence(new triple(int i) {return interp(precontrol(a,i), - precontrol(b,i),t);},n), + return path3(sequence(new triple(int i) { + return interp(precontrol(a,i),precontrol(b,i),t);},n), sequence(new triple(int i) {return interp(point(a,i),point(b,i),t);},n), sequence(new triple(int i) {return interp(postcontrol(a,i), postcontrol(b,i),t);},n), @@ -294,12 +288,15 @@ path3 interp(path3 a, path3 b, real t) struct tube { surface s; - path3 center; + path3 center; // tube axis - void operator init(path3 p, real width, int sectors=4, - real granularity=linegranularity) { - sectors += sectors % 2; // Must be even. - int h=quotient(sectors,2); + void Null(transform3) {} + void Null(transform3, bool) {} + + void operator init(path3 p, real width, render render=defaultrender, + void cylinder(transform3)=Null, + void sphere(transform3, bool half)=Null, + void tube(path3, path3)=null) { real r=0.5*width; void generate(path3 p) { @@ -308,31 +305,41 @@ struct tube for(int i=0; i < n; ++i) { triple v=point(p,i); triple u=point(p,i+1)-v; - s.append(shift(v)*align(unit(u))*scale(r,r,abs(u))*unitcylinder); + transform3 t=shift(v)*align(unit(u))*scale(r,r,abs(u)); + s.append(t*unitcylinder); + cylinder(t); } center=center&p; } else { real[] T; path3 G; for(int i=0; i < n; ++i) - render(subpath(p,i,i+1),granularity, + render(subpath(p,i,i+1), new void(path3 g, real s) { G=G&g; T.push(i+s); - }); + },render); T.push(n); T.cyclic=cyclic(p); rmf[] rmf=rmf(p,T); triple f(pair t) { rmf R=rmf[round(t.x)]; - return point(G,t.x)+r*(R.r*cos(t.y)-R.s*sin(t.y)); + int n=round(t.y); + static real[] x={1,0,-1,0}; + static real[] y={0,1,0,-1}; + return point(G,t.x)+r*(R.r*x[n]-R.s*y[n]); } - real[] v=uniform(0,2pi,sectors); + static real[] v={0,1,2,3,0}; + static real[] circular(real[] x, real[] y) { + static real a=8/3*(sqrt(2)-1); + return a*periodic(x,y); + } + static splinetype[] Monotonic={monotonic,monotonic,monotonic}; - static splinetype[] Periodic={periodic,periodic,periodic}; + static splinetype[] Circular={circular,circular,circular}; if(T.length > 0) { - surface S=surface(f,sequence(T.length),v,Monotonic,Periodic); + surface S=surface(f,sequence(T.length),v,Monotonic,Circular); s.append(S); // Compute center of tube: @@ -341,19 +348,52 @@ struct tube triple[] pre=new triple[n+1]; triple[] point=new triple[n+1]; triple[] post=new triple[n+1]; + int[] index=S.index[0]; - pre[0]=point[0]=0.5*(S.s[index[0]].P[0][0]+S.s[index[h]].P[0][0]); + triple Point; + for(int m=0; m < 4; ++m) + Point += S.s[index[m]].P[0][0]; + pre[0]=point[0]=0.25*Point; + for(int i=0; i < n; ++i) { index=S.index[i]; - triple [][] P=S.s[index[0]].P; - triple [][] Q=S.s[index[h]].P; - post[i]=0.5*(P[1][0]+Q[1][0]); - pre[i+1]=0.5*(P[2][0]+Q[2][0]); - point[i+1]=0.5*(P[3][0]+Q[3][0]); + triple Pre,Point,Post; + for(int m=0; m < 4; ++m) { + triple [][] P=S.s[index[m]].P; + Post += P[1][0]; + Pre += P[2][0]; + Point += P[3][0]; + } + post[i]=0.25*Post; + pre[i+1]=0.25*Pre; + point[i+1]=0.25*Point; + } + index=S.index[n-1]; - post[n]=0.5*(S.s[index[0]].P[3][0]+S.s[index[h]].P[3][0]); - center=center&path3(pre,point,post,array(n+1,false),T.cyclic); + triple Post; + for(int m=0; m < 4; ++m) + Post += S.s[index[m]].P[3][0]; + post[n]=0.25*Post; + + bool[] b=array(n+1,false); + path3 Center=path3(pre,point,post,b,T.cyclic); + center=center&Center; + + if(tube != null) { // Compute path along tube + triple[] pre=new triple[n+1]; + triple[] point=new triple[n+1]; + triple[] post=new triple[n+1]; + pre[0]=point[0]=S.s[S.index[0][0]].P[0][0]; + for(int i=0; i < n; ++i) { + triple [][] P=S.s[S.index[i][0]].P; + post[i]=P[1][0]; + pre[i+1]=P[2][0]; + point[i+1]=P[3][0]; + } + post[n]=S.s[S.index[n-1][0]].P[3][0]; + tube(Center,path3(pre,point,post,b,T.cyclic)); + } } } } @@ -363,11 +403,16 @@ struct tube int begin=0; int n=length(p); for(int i=cyclic ? 0 : 1; i < n; ++i) - if(abs(dir(p,i,1)-dir(p,i,-1)) > sqrtEpsilon) { - generate(subpath(p,begin,i)); - s.append(shift(point(p,i))*t*align(dir(p,i,-1))*unithemisphere); - begin=i; - } + if(abs(dir(p,i,1)-dir(p,i,-1)) > sqrtEpsilon) { + generate(subpath(p,begin,i)); + triple dir=dir(p,i,-1); + s.append(shift(point(p,i))*t*align(dir)* + (dir != O ? unithemisphere : unitsphere)); + int L=length(center); + sphere(shift(point(center,L))*t*align(dir(center,L,-1)), + half=straight(p,i-1) && straight(p,i)); + begin=i; + } generate(subpath(p,begin,n)); } } diff --git a/Build/source/utils/asymptote/builtin.cc b/Build/source/utils/asymptote/builtin.cc index deb0e223d05..8e2d80cb3f1 100644 --- a/Build/source/utils/asymptote/builtin.cc +++ b/Build/source/utils/asymptote/builtin.cc @@ -36,6 +36,9 @@ #include "refaccess.h" #include "settings.h" +#include "opsymbols.h" +#include "builtin.symbols.h" + #ifdef HAVE_LIBGSL #include <gsl/gsl_math.h> #include <gsl/gsl_sf.h> @@ -73,15 +76,17 @@ void gen_runpath_venv(venv &ve); void gen_runpath3d_venv(venv &ve); void gen_runmath_venv(venv &ve); -void addType(tenv &te, const char *name, ty *t) + +void addType(tenv &te, symbol *name, ty *t) { - te.enter(symbol::trans(name), new tyEntry(t,0,0,position())); + te.enter(name, new tyEntry(t,0,0,position())); } // The base environments for built-in types and functions void base_tenv(tenv &te) { -#define PRIMITIVE(name,Name,asyName) addType(te, #asyName, prim##Name()); +#define PRIMITIVE(name,Name,asyName) \ + addType(te, symbol::trans(#asyName), prim##Name()); #include "primitives.h" #undef PRIMITIVE } @@ -125,6 +130,19 @@ void addFunc(venv &ve, access *a, ty *result, symbol *id, } // Add a function with one or more default arguments. +void addFunc(venv &ve, bltin f, ty *result, symbol *name, + formal f1, formal f2, formal f3, formal f4, formal f5, formal f6, + formal f7, formal f8, formal f9, formal fA, formal fB, formal fC, + formal fD, formal fE, formal fF, formal fG, formal fH, formal fI) +{ + REGISTER_BLTIN(f, name); + access *a = new bltinAccess(f); + addFunc(ve,a,result,name,f1,f2,f3,f4,f5,f6,f7,f8,f9, + fA,fB,fC,fD,fE,fF,fG,fH,fI); +} + +#if 0 +// Add a function with one or more default arguments. void addFunc(venv &ve, bltin f, ty *result, const char *name, formal f1, formal f2, formal f3, formal f4, formal f5, formal f6, formal f7, formal f8, formal f9, formal fA, formal fB, formal fC, @@ -140,8 +158,9 @@ void addFunc(venv &ve, access *a, ty *result, const char *name, formal f1) { addFunc(ve,a,result,symbol::trans(name),f1); } +#endif -void addOpenFunc(venv &ve, bltin f, ty *result, const char *name) +void addOpenFunc(venv &ve, bltin f, ty *result, symbol *name) { function *fun = new function(result, signature::OPEN); @@ -150,12 +169,12 @@ void addOpenFunc(venv &ve, bltin f, ty *result, const char *name) varEntry *ent = new varEntry(fun, a, 0, position()); - ve.enter(symbol::trans(name), ent); + ve.enter(name, ent); } // Add a rest function with zero or more default/explicit arguments. -void addRestFunc(venv &ve, bltin f, ty *result, const char *name, formal frest, +void addRestFunc(venv &ve, bltin f, ty *result, symbol *name, formal frest, formal f1=noformal, formal f2=noformal, formal f3=noformal, formal f4=noformal, formal f5=noformal, formal f6=noformal, formal f7=noformal, formal f8=noformal, formal f9=noformal) @@ -178,28 +197,28 @@ void addRestFunc(venv &ve, bltin f, ty *result, const char *name, formal frest, varEntry *ent = new varEntry(fun, a, 0, position()); - ve.enter(symbol::trans(name), ent); + ve.enter(name, ent); } -void addRealFunc0(venv &ve, bltin fcn, const char *name) +void addRealFunc0(venv &ve, bltin fcn, symbol *name) { addFunc(ve, fcn, primReal(), name); } template<double (*fcn)(double)> -void addRealFunc(venv &ve, const char* name) +void addRealFunc(venv &ve, symbol *name) { - addFunc(ve, realReal<fcn>, primReal(), name, formal(primReal(),"x")); + addFunc(ve, realReal<fcn>, primReal(), name, formal(primReal(),SYM(x))); addFunc(ve, arrayFunc<double,double,fcn>, realArray(), name, - formal(realArray(),"a")); + formal(realArray(),SYM(a))); } -#define addRealFunc(fcn) addRealFunc<fcn>(ve, #fcn); +#define addRealFunc(fcn, sym) addRealFunc<fcn>(ve, sym); -void addRealFunc2(venv &ve, bltin fcn, const char *name) +void addRealFunc2(venv &ve, bltin fcn, symbol *name) { - addFunc(ve,fcn,primReal(),name,formal(primReal(),"a"), - formal(primReal(),"b")); + addFunc(ve,fcn,primReal(),name,formal(primReal(),SYM(a)), + formal(primReal(),SYM(b))); } template <double (*func)(double, int)> @@ -210,8 +229,8 @@ void realRealInt(vm::stack *s) { } template<double (*fcn)(double, int)> -void addRealIntFunc(venv& ve, const char* name, const char* arg1, - const char* arg2) { +void addRealIntFunc(venv& ve, symbol *name, symbol *arg1, + symbol *arg2) { addFunc(ve, realRealInt<fcn>, primReal(), name, formal(primReal(), arg1), formal(primInt(), arg2)); } @@ -315,7 +334,7 @@ void realRealIntGSL(vm::stack *s) // Add a GSL special function from the GNU GSL library template<double (*fcn)(double)> -void addGSLRealFunc(const char* name, const char* arg1="x") +void addGSLRealFunc(symbol *name, symbol *arg1=SYM(x)) { addFunc(GSLModule->e.ve, realRealGSL<fcn>, primReal(), name, formal(primReal(),arg1)); @@ -323,15 +342,15 @@ void addGSLRealFunc(const char* name, const char* arg1="x") // Add a GSL_PREC_DOUBLE GSL special function. template<double (*fcn)(double, gsl_mode_t)> -void addGSLDOUBLEFunc(const char* name, const char* arg1="x") +void addGSLDOUBLEFunc(symbol *name, symbol *arg1=SYM(x)) { addFunc(GSLModule->e.ve, realRealDOUBLE<fcn>, primReal(), name, formal(primReal(),arg1)); } template<double (*fcn)(double, double, gsl_mode_t)> -void addGSLDOUBLE2Func(const char* name, const char* arg1="phi", - const char* arg2="k") +void addGSLDOUBLE2Func(symbol *name, symbol *arg1=SYM(phi), + symbol *arg2=SYM(k)) { addFunc(GSLModule->e.ve, realRealRealDOUBLE<fcn>, primReal(), name, formal(primReal(),arg1), formal(primReal(),arg2)); @@ -348,8 +367,8 @@ void realRealRealRealDOUBLE(vm::stack *s) } template<double (*fcn)(double, double, double, gsl_mode_t)> -void addGSLDOUBLE3Func(const char* name, const char* arg1, const char* arg2, - const char* arg3) +void addGSLDOUBLE3Func(symbol *name, symbol *arg1, symbol *arg2, + symbol *arg3) { addFunc(GSLModule->e.ve, realRealRealRealDOUBLE<fcn>, primReal(), name, formal(primReal(),arg1), formal(primReal(),arg2), @@ -368,8 +387,8 @@ void realRealRealRealRealDOUBLE(vm::stack *s) } template<double (*fcn)(double, double, double, double, gsl_mode_t)> -void addGSLDOUBLE4Func(const char* name, const char* arg1, const char* arg2, - const char* arg3, const char* arg4) +void addGSLDOUBLE4Func(symbol *name, symbol *arg1, symbol *arg2, + symbol *arg3, symbol *arg4) { addFunc(GSLModule->e.ve, realRealRealRealRealDOUBLE<fcn>, primReal(), name, formal(primReal(),arg1), formal(primReal(),arg2), @@ -377,10 +396,10 @@ void addGSLDOUBLE4Func(const char* name, const char* arg1, const char* arg2, } template<double (*fcn)(unsigned)> -void addGSLIntFunc(const char* name) +void addGSLIntFunc(symbol *name) { addFunc(GSLModule->e.ve, realIntGSL<fcn>, primReal(), name, - formal(primInt(),"s")); + formal(primInt(),SYM(s))); } template <double (*func)(int)> @@ -392,31 +411,31 @@ void realSignedGSL(vm::stack *s) } template<double (*fcn)(int)> -void addGSLSignedFunc(const char* name, const char* arg1) +void addGSLSignedFunc(symbol *name, symbol *arg1) { addFunc(GSLModule->e.ve, realSignedGSL<fcn>, primReal(), name, formal(primInt(),arg1)); } template<double (*fcn)(int, double)> -void addGSLIntRealFunc(const char* name, const char *arg1="n", - const char* arg2="x") +void addGSLIntRealFunc(symbol *name, symbol *arg1=SYM(n), + symbol *arg2=SYM(x)) { addFunc(GSLModule->e.ve, realIntRealGSL<fcn>, primReal(), name, formal(primInt(),arg1), formal(primReal(),arg2)); } template<double (*fcn)(double, double)> -void addGSLRealRealFunc(const char* name, const char* arg1="nu", - const char* arg2="x") +void addGSLRealRealFunc(symbol *name, symbol *arg1=SYM(nu), + symbol *arg2=SYM(x)) { addFunc(GSLModule->e.ve, realRealRealGSL<fcn>, primReal(), name, formal(primReal(),arg1), formal(primReal(),arg2)); } template<double (*fcn)(double, double, double)> -void addGSLRealRealRealFunc(const char* name, const char* arg1, - const char* arg2, const char* arg3) +void addGSLRealRealRealFunc(symbol *name, symbol *arg1, + symbol *arg2, symbol *arg3) { addFunc(GSLModule->e.ve, realRealRealRealGSL<fcn>, primReal(), name, formal(primReal(),arg1), formal(primReal(),arg2), @@ -424,8 +443,8 @@ void addGSLRealRealRealFunc(const char* name, const char* arg1, } template<int (*fcn)(double, double, double)> -void addGSLRealRealRealFuncInt(const char* name, const char* arg1, - const char* arg2, const char* arg3) +void addGSLRealRealRealFuncInt(symbol *name, symbol *arg1, + symbol *arg2, symbol *arg3) { addFunc(GSLModule->e.ve, intRealRealRealGSL<fcn>, primInt(), name, formal(primReal(),arg1), formal(primReal(),arg2), @@ -433,8 +452,8 @@ void addGSLRealRealRealFuncInt(const char* name, const char* arg1, } template<double (*fcn)(double, unsigned)> -void addGSLRealIntFunc(const char* name, const char* arg1="nu", - const char* arg2="s") +void addGSLRealIntFunc(symbol *name, symbol *arg1=SYM(nu), + symbol *arg2=SYM(s)) { addFunc(GSLModule->e.ve, realRealIntGSL<fcn>, primReal(), name, formal(primReal(),arg1), formal(primInt(),arg2)); @@ -450,7 +469,7 @@ void realRealSignedGSL(vm::stack *s) } template<double (*fcn)(double, int)> -void addGSLRealSignedFunc(const char* name, const char* arg1, const char* arg2) +void addGSLRealSignedFunc(symbol *name, symbol *arg1, symbol *arg2) { addFunc(GSLModule->e.ve, realRealSignedGSL<fcn>, primReal(), name, formal(primReal(),arg1), formal(primInt(),arg2)); @@ -466,8 +485,8 @@ void realUnsignedUnsignedGSL(vm::stack *s) } template<double (*fcn)(unsigned int, unsigned int)> -void addGSLUnsignedUnsignedFunc(const char* name, const char* arg1, - const char* arg2) +void addGSLUnsignedUnsignedFunc(symbol *name, symbol *arg1, + symbol *arg2) { addFunc(GSLModule->e.ve, realUnsignedUnsignedGSL<fcn>, primReal(), name, formal(primInt(), arg1), formal(primInt(), arg2)); @@ -484,8 +503,8 @@ void realIntRealRealGSL(vm::stack *s) } template<double (*fcn)(int, double, double)> -void addGSLIntRealRealFunc(const char* name, const char* arg1, - const char* arg2, const char* arg3) +void addGSLIntRealRealFunc(symbol *name, symbol *arg1, + symbol *arg2, symbol *arg3) { addFunc(GSLModule->e.ve, realIntRealRealGSL<fcn>, primReal(), name, formal(primInt(), arg1), formal(primReal(), arg2), @@ -503,8 +522,8 @@ void realIntIntRealGSL(vm::stack *s) } template<double (*fcn)(int, int, double)> -void addGSLIntIntRealFunc(const char* name, const char* arg1, const char* arg2, - const char* arg3) +void addGSLIntIntRealFunc(symbol *name, symbol *arg1, symbol *arg2, + symbol *arg3) { addFunc(GSLModule->e.ve, realIntIntRealGSL<fcn>, primReal(), name, formal(primInt(), arg1), formal(primInt(), arg2), @@ -523,9 +542,9 @@ void realIntIntRealRealGSL(vm::stack *s) } template<double (*fcn)(int, int, double, double)> -void addGSLIntIntRealRealFunc(const char* name, const char* arg1, - const char* arg2, const char* arg3, - const char* arg4) +void addGSLIntIntRealRealFunc(symbol *name, symbol *arg1, + symbol *arg2, symbol *arg3, + symbol *arg4) { addFunc(GSLModule->e.ve, realIntIntRealRealGSL<fcn>, primReal(), name, formal(primInt(), arg1), formal(primInt(), arg2), @@ -544,9 +563,9 @@ void realRealRealRealRealGSL(vm::stack *s) } template<double (*fcn)(double, double, double, double)> -void addGSLRealRealRealRealFunc(const char* name, const char* arg1, - const char* arg2, const char* arg3, - const char* arg4) +void addGSLRealRealRealRealFunc(symbol *name, symbol *arg1, + symbol *arg2, symbol *arg3, + symbol *arg4) { addFunc(GSLModule->e.ve, realRealRealRealRealGSL<fcn>, primReal(), name, formal(primReal(), arg1), formal(primReal(), arg2), @@ -568,10 +587,10 @@ void realIntIntIntIntIntIntGSL(vm::stack *s) } template<double (*fcn)(int, int, int, int, int, int)> -void addGSLIntIntIntIntIntIntFunc(const char* name, const char* arg1, - const char* arg2, const char* arg3, - const char* arg4, const char* arg5, - const char* arg6) +void addGSLIntIntIntIntIntIntFunc(symbol *name, symbol *arg1, + symbol *arg2, symbol *arg3, + symbol *arg4, symbol *arg5, + symbol *arg6) { addFunc(GSLModule->e.ve, realIntIntIntIntIntIntGSL<fcn>, primReal(), name, formal(primInt(), arg1), formal(primInt(), arg2), @@ -597,11 +616,11 @@ void realIntIntIntIntIntIntIntIntIntGSL(vm::stack *s) } template<double (*fcn)(int, int, int, int, int, int, int, int, int)> -void addGSLIntIntIntIntIntIntIntIntIntFunc(const char* name, const char* arg1, - const char* arg2, const char* arg3, - const char* arg4, const char* arg5, - const char* arg6, const char* arg7, - const char* arg8, const char* arg9) +void addGSLIntIntIntIntIntIntIntIntIntFunc(symbol *name, symbol *arg1, + symbol *arg2, symbol *arg3, + symbol *arg4, symbol *arg5, + symbol *arg6, symbol *arg7, + symbol *arg8, symbol *arg9) { addFunc(GSLModule->e.ve, realIntIntIntIntIntIntIntIntIntGSL<fcn>, primReal(), name, formal(primInt(), arg1), formal(primInt(), arg2), @@ -669,26 +688,26 @@ void addCast(venv &ve, ty *target, ty *source, bltin f) { } template<class T> -void addVariable(venv &ve, T *ref, ty *t, const char *name, +void addVariable(venv &ve, T *ref, ty *t, symbol *name, record *module=settings::getSettingsModule()) { access *a = new refAccess<T>(ref); varEntry *ent = new varEntry(t, a, PUBLIC, module, 0, position()); - ve.enter(symbol::trans(name), ent); + ve.enter(name, ent); } template<class T> -void addVariable(venv &ve, T value, ty *t, const char *name, +void addVariable(venv &ve, T value, ty *t, symbol *name, record *module=settings::getSettingsModule(), permission perm=PUBLIC) { item* ref=new item; *ref=value; access *a = new itemRefAccess(ref); varEntry *ent = new varEntry(t, a, perm, module, 0, position()); - ve.enter(symbol::trans(name), ent); + ve.enter(name, ent); } template<class T> -void addConstant(venv &ve, T value, ty *t, const char *name, +void addConstant(venv &ve, T value, ty *t, symbol *name, record *module=settings::getSettingsModule()) { addVariable(ve,value,t,name,module,RESTRICTED); } @@ -770,76 +789,76 @@ void addGuideOperators(venv &ve) { // The guide operators .. and -- take an array of guides, and turn them // into a single guide. - addRestFunc(ve, dotsGuide, primGuide(), "..", guideArray()); - addRestFunc(ve, dashesGuide, primGuide(), "--", guideArray()); + addRestFunc(ve, dotsGuide, primGuide(), SYM_DOTS, guideArray()); + addRestFunc(ve, dashesGuide, primGuide(), SYM_DASHES, guideArray()); } /* Avoid typing the same type three times. */ -void addSimpleOperator(venv &ve, bltin f, ty *t, const char *name) +void addSimpleOperator(venv &ve, bltin f, ty *t, symbol *name) { - addFunc(ve,f,t,name,formal(t,"a"),formal(t,"b")); + addFunc(ve,f,t,name,formal(t,SYM(a)),formal(t,SYM(b))); } -void addBooleanOperator(venv &ve, bltin f, ty *t, const char *name) +void addBooleanOperator(venv &ve, bltin f, ty *t, symbol *name) { - addFunc(ve,f,primBoolean(),name,formal(t,"a"),formal(t,"b")); + addFunc(ve,f,primBoolean(),name,formal(t,SYM(a)),formal(t,SYM(b))); } template<class T, template <class S> class op> -void addArray2Array2Op(venv &ve, ty *t3, const char *name) +void addArray2Array2Op(venv &ve, ty *t3, symbol *name) { - addFunc(ve,array2Array2Op<T,op>,t3,name,formal(t3,"a"),formal(t3,"b")); + addFunc(ve,array2Array2Op<T,op>,t3,name,formal(t3,SYM(a)),formal(t3,SYM(b))); } template<class T, template <class S> class op> -void addOpArray2(venv &ve, ty *t1, const char *name, ty *t3) +void addOpArray2(venv &ve, ty *t1, symbol *name, ty *t3) { - addFunc(ve,opArray2<T,T,op>,t3,name,formal(t1,"a"),formal(t3,"b")); + addFunc(ve,opArray2<T,T,op>,t3,name,formal(t1,SYM(a)),formal(t3,SYM(b))); } template<class T, template <class S> class op> -void addArray2Op(venv &ve, ty *t1, const char *name, ty *t3) +void addArray2Op(venv &ve, ty *t1, symbol *name, ty *t3) { - addFunc(ve,array2Op<T,T,op>,t3,name,formal(t3,"a"),formal(t1,"b")); + addFunc(ve,array2Op<T,T,op>,t3,name,formal(t3,SYM(a)),formal(t1,SYM(b))); } template<class T, template <class S> class op> -void addOps(venv &ve, ty *t1, const char *name, ty *t2) +void addOps(venv &ve, ty *t1, symbol *name, ty *t2) { addSimpleOperator(ve,binaryOp<T,op>,t1,name); - addFunc(ve,opArray<T,T,op>,t2,name,formal(t1,"a"),formal(t2,"b")); - addFunc(ve,arrayOp<T,T,op>,t2,name,formal(t2,"a"),formal(t1,"b")); + addFunc(ve,opArray<T,T,op>,t2,name,formal(t1,SYM(a)),formal(t2,SYM(b))); + addFunc(ve,arrayOp<T,T,op>,t2,name,formal(t2,SYM(a)),formal(t1,SYM(b))); addSimpleOperator(ve,arrayArrayOp<T,op>,t2,name); } template<class T, template <class S> class op> -void addBooleanOps(venv &ve, ty *t1, const char *name, ty *t2) +void addBooleanOps(venv &ve, ty *t1, symbol *name, ty *t2) { addBooleanOperator(ve,binaryOp<T,op>,t1,name); addFunc(ve,opArray<T,T,op>, - booleanArray(),name,formal(t1,"a"),formal(t2,"b")); + booleanArray(),name,formal(t1,SYM(a)),formal(t2,SYM(b))); addFunc(ve,arrayOp<T,T,op>, - booleanArray(),name,formal(t2,"a"),formal(t1,"b")); - addFunc(ve,arrayArrayOp<T,op>,booleanArray(),name,formal(t2,"a"), - formal(t2,"b")); + booleanArray(),name,formal(t2,SYM(a)),formal(t1,SYM(b))); + addFunc(ve,arrayArrayOp<T,op>,booleanArray(),name,formal(t2,SYM(a)), + formal(t2,SYM(b))); } void addWrite(venv &ve, bltin f, ty *t1, ty *t2) { - addRestFunc(ve,f,primVoid(),"write",t2, - formal(primFile(),"file",true),formal(primString(),"s",true), - formal(t1,"x"),formal(voidFileFunction(),"suffix",true)); + addRestFunc(ve,f,primVoid(),SYM(write),t2, + formal(primFile(),SYM(file),true),formal(primString(),SYM(s),true), + formal(t1,SYM(x)),formal(voidFileFunction(),SYM(suffix),true)); } template<class T> void addUnorderedOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4) { - addBooleanOps<T,equals>(ve,t1,"==",t2); - addBooleanOps<T,notequals>(ve,t1,"!=",t2); + addBooleanOps<T,equals>(ve,t1,SYM_EQ,t2); + addBooleanOps<T,notequals>(ve,t1,SYM_NEQ,t2); - addFunc(ve, run::array2Equals<T>, primBoolean(), "==", formal(t3, "a"), - formal(t3, "b")); - addFunc(ve, run::array2NotEquals<T>, primBoolean(), "!=", formal(t3, "a"), - formal(t3, "b")); + addFunc(ve, run::array2Equals<T>, primBoolean(), SYM_EQ, formal(t3, SYM(a)), + formal(t3, SYM(b))); + addFunc(ve, run::array2NotEquals<T>, primBoolean(), SYM_NEQ, formal(t3, SYM(a)), + formal(t3, SYM(b))); addCast(ve,t1,primFile(),read<T>); addCast(ve,t2,primFile(),readArray<T>); @@ -847,13 +866,13 @@ void addUnorderedOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4) addCast(ve,t4,primFile(),readArray<T>); addWrite(ve,write<T>,t1,t2); - addRestFunc(ve,writeArray<T>,primVoid(),"write",t3, - formal(primFile(),"file",true),formal(primString(),"s",true), - formal(t2,"a",false,true)); - addFunc(ve,writeArray2<T>,primVoid(),"write", - formal(primFile(),"file",true),t3); - addFunc(ve,writeArray3<T>,primVoid(),"write", - formal(primFile(),"file",true),t4); + addRestFunc(ve,writeArray<T>,primVoid(),SYM(write),t3, + formal(primFile(),SYM(file),true),formal(primString(),SYM(s),true), + formal(t2,SYM(a),false,true)); + addFunc(ve,writeArray2<T>,primVoid(),SYM(write), + formal(primFile(),SYM(file),true),t3); + addFunc(ve,writeArray3<T>,primVoid(),SYM(write), + formal(primFile(),SYM(file),true),t4); } inline double abs(pair z) { @@ -874,53 +893,53 @@ inline T negate(T x) { } template<class T, template <class S> class op> -void addBinOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4, const char *name) +void addBinOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4, symbol *name) { - addFunc(ve,binopArray<T,op>,t1,name,formal(t2,"a")); - addFunc(ve,binopArray2<T,op>,t1,name,formal(t3,"a")); - addFunc(ve,binopArray3<T,op>,t1,name,formal(t4,"a")); + addFunc(ve,binopArray<T,op>,t1,name,formal(t2,SYM(a))); + addFunc(ve,binopArray2<T,op>,t1,name,formal(t3,SYM(a))); + addFunc(ve,binopArray3<T,op>,t1,name,formal(t4,SYM(a))); } template<class T> void addOrderedOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4) { - addBooleanOps<T,less>(ve,t1,"<",t2); - addBooleanOps<T,lessequals>(ve,t1,"<=",t2); - addBooleanOps<T,greaterequals>(ve,t1,">=",t2); - addBooleanOps<T,greater>(ve,t1,">",t2); + addBooleanOps<T,less>(ve,t1,SYM_LT,t2); + addBooleanOps<T,lessequals>(ve,t1,SYM_LE,t2); + addBooleanOps<T,greaterequals>(ve,t1,SYM_GE,t2); + addBooleanOps<T,greater>(ve,t1,SYM_GT,t2); - addOps<T,run::min>(ve,t1,"min",t2); - addOps<T,run::max>(ve,t1,"max",t2); - addBinOps<T,run::min>(ve,t1,t2,t3,t4,"min"); - addBinOps<T,run::max>(ve,t1,t2,t3,t4,"max"); + addOps<T,run::min>(ve,t1,SYM(min),t2); + addOps<T,run::max>(ve,t1,SYM(max),t2); + addBinOps<T,run::min>(ve,t1,t2,t3,t4,SYM(min)); + addBinOps<T,run::max>(ve,t1,t2,t3,t4,SYM(max)); - addFunc(ve,sortArray<T>,t2,"sort",formal(t2,"a")); - addFunc(ve,sortArray2<T>,t3,"sort",formal(t3,"a")); + addFunc(ve,sortArray<T>,t2,SYM(sort),formal(t2,SYM(a))); + addFunc(ve,sortArray2<T>,t3,SYM(sort),formal(t3,SYM(a))); - addFunc(ve,searchArray<T>,primInt(),"search",formal(t2,"a"), - formal(t1,"key")); + addFunc(ve,searchArray<T>,primInt(),SYM(search),formal(t2,SYM(a)), + formal(t1,SYM(key))); } template<class T> void addBasicOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4, bool integer=false, bool Explicit=false) { - addOps<T,plus>(ve,t1,"+",t2); - addOps<T,minus>(ve,t1,"-",t2); + addOps<T,plus>(ve,t1,SYM_PLUS,t2); + addOps<T,minus>(ve,t1,SYM_MINUS,t2); - addArray2Array2Op<T,plus>(ve,t3,"+"); - addArray2Array2Op<T,minus>(ve,t3,"-"); + addArray2Array2Op<T,plus>(ve,t3,SYM_PLUS); + addArray2Array2Op<T,minus>(ve,t3,SYM_MINUS); - addFunc(ve,&id,t1,"+",formal(t1,"a")); - addFunc(ve,&id,t2,"+",formal(t2,"a")); - addFunc(ve,Negate<T>,t1,"-",formal(t1,"a")); - addFunc(ve,arrayFunc<T,T,negate>,t2,"-",formal(t2,"a")); - addFunc(ve,arrayFunc2<T,T,negate>,t3,"-",formal(t3,"a")); - if(!integer) addFunc(ve,interp<T>,t1,"interp",formal(t1,"a",false,Explicit), - formal(t1,"b",false,Explicit), - formal(primReal(),"t")); + addFunc(ve,&id,t1,SYM_PLUS,formal(t1,SYM(a))); + addFunc(ve,&id,t2,SYM_PLUS,formal(t2,SYM(a))); + addFunc(ve,Negate<T>,t1,SYM_MINUS,formal(t1,SYM(a))); + addFunc(ve,arrayFunc<T,T,negate>,t2,SYM_MINUS,formal(t2,SYM(a))); + addFunc(ve,arrayFunc2<T,T,negate>,t3,SYM_MINUS,formal(t3,SYM(a))); + if(!integer) addFunc(ve,interp<T>,t1,SYM(interp),formal(t1,SYM(a),false,Explicit), + formal(t1,SYM(b),false,Explicit), + formal(primReal(),SYM(t))); - addFunc(ve,sumArray<T>,t1,"sum",formal(t2,"a")); + addFunc(ve,sumArray<T>,t1,SYM(sum),formal(t2,SYM(a))); addUnorderedOps<T>(ve,t1,t2,t3,t4); } @@ -930,16 +949,16 @@ void addOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4, bool integer=false, { addBasicOps<T>(ve,t1,t2,t3,t4,integer,Explicit); - addOps<T,times>(ve,t1,"*",t2); - addOpArray2<T,times>(ve,t1,"*",t3); - addArray2Op<T,times>(ve,t1,"*",t3); + addOps<T,times>(ve,t1,SYM_TIMES,t2); + addOpArray2<T,times>(ve,t1,SYM_TIMES,t3); + addArray2Op<T,times>(ve,t1,SYM_TIMES,t3); if(!integer) { - addOps<T,run::divide>(ve,t1,"/",t2); - addArray2Op<T,run::divide>(ve,t1,"/",t3); + addOps<T,run::divide>(ve,t1,SYM_DIVIDE,t2); + addArray2Op<T,run::divide>(ve,t1,SYM_DIVIDE,t3); } - addOps<T,power>(ve,t1,"^",t2); + addOps<T,power>(ve,t1,SYM_CARET,t2); } @@ -949,34 +968,34 @@ void addArrayOps(venv &ve, types::array *t) ty *ct = t->celltype; addFunc(ve, run::arrayAlias, - primBoolean(), "alias", formal(t, "a"), formal(t, "b")); + primBoolean(), SYM(alias), formal(t, SYM(a)), formal(t, SYM(b))); addFunc(ve, run::newDuplicateArray, - t, "array", formal(primInt(), "n"), - formal(ct, "value"), - formal(primInt(), "depth", /*optional=*/ true)); + t, SYM(array), formal(primInt(), SYM(n)), + formal(ct, SYM(value)), + formal(primInt(), SYM(depth), /*optional=*/ true)); switch (t->depth()) { case 1: - addFunc(ve, run::arrayCopy, t, "copy", formal(t, "a")); - addRestFunc(ve, run::arrayConcat, t, "concat", new types::array(t)); + addFunc(ve, run::arrayCopy, t, SYM(copy), formal(t, SYM(a))); + addRestFunc(ve, run::arrayConcat, t, SYM(concat), new types::array(t)); addFunc(ve, run::arraySequence, - t, "sequence", formal(new function(ct, primInt()), "f"), - formal(primInt(), "n")); + t, SYM(sequence), formal(new function(ct, primInt()), SYM(f)), + formal(primInt(), SYM(n))); addFunc(ve, run::arrayFunction, - t, "map", formal(new function(ct, ct), "f"), formal(t, "a")); + t, SYM(map), formal(new function(ct, ct), SYM(f)), formal(t, SYM(a))); addFunc(ve, run::arraySort, - t, "sort", formal(t, "a"), - formal(new function(primBoolean(), ct, ct), "f")); + t, SYM(sort), formal(t, SYM(a)), + formal(new function(primBoolean(), ct, ct), SYM(f))); break; case 2: - addFunc(ve, run::array2Copy, t, "copy", formal(t, "a")); - addFunc(ve, run::array2Transpose, t, "transpose", formal(t, "a")); + addFunc(ve, run::array2Copy, t, SYM(copy), formal(t, SYM(a))); + addFunc(ve, run::array2Transpose, t, SYM(transpose), formal(t, SYM(a))); break; case 3: - addFunc(ve, run::array3Copy, t, "copy", formal(t, "a")); - addFunc(ve, run::array3Transpose, t, "transpose", formal(t, "a"), - formal(IntArray(),"perm")); + addFunc(ve, run::array3Copy, t, SYM(copy), formal(t, SYM(a))); + addFunc(ve, run::array3Transpose, t, SYM(transpose), formal(t, SYM(a)), + formal(IntArray(),SYM(perm))); break; default: break; @@ -985,29 +1004,29 @@ void addArrayOps(venv &ve, types::array *t) void addRecordOps(venv &ve, record *r) { - addFunc(ve, run::boolMemEq, primBoolean(), "alias", formal(r, "a"), - formal(r, "b")); - addFunc(ve, run::boolMemEq, primBoolean(), "==", formal(r, "a"), - formal(r, "b")); - addFunc(ve, run::boolMemNeq, primBoolean(), "!=", formal(r, "a"), - formal(r, "b")); + addFunc(ve, run::boolMemEq, primBoolean(), SYM(alias), formal(r, SYM(a)), + formal(r, SYM(b))); + addFunc(ve, run::boolMemEq, primBoolean(), SYM_EQ, formal(r, SYM(a)), + formal(r, SYM(b))); + addFunc(ve, run::boolMemNeq, primBoolean(), SYM_NEQ, formal(r, SYM(a)), + formal(r, SYM(b))); } void addFunctionOps(venv &ve, function *f) { - addFunc(ve, run::boolFuncEq, primBoolean(), "==", formal(f, "a"), - formal(f, "b")); - addFunc(ve, run::boolFuncNeq, primBoolean(), "!=", formal(f, "a"), - formal(f, "b")); + addFunc(ve, run::boolFuncEq, primBoolean(), SYM_EQ, formal(f, SYM(a)), + formal(f, SYM(b))); + addFunc(ve, run::boolFuncNeq, primBoolean(), SYM_NEQ, formal(f, SYM(a)), + formal(f, SYM(b))); } void addOperators(venv &ve) { - addSimpleOperator(ve,binaryOp<string,plus>,primString(),"+"); + addSimpleOperator(ve,binaryOp<string,plus>,primString(),SYM_PLUS); - addBooleanOps<bool,And>(ve,primBoolean(),"&",booleanArray()); - addBooleanOps<bool,Or>(ve,primBoolean(),"|",booleanArray()); - addBooleanOps<bool,Xor>(ve,primBoolean(),"^",booleanArray()); + addBooleanOps<bool,And>(ve,primBoolean(),SYM_AMPERSAND,booleanArray()); + addBooleanOps<bool,Or>(ve,primBoolean(),SYM_BAR,booleanArray()); + addBooleanOps<bool,Xor>(ve,primBoolean(),SYM_CARET,booleanArray()); addUnorderedOps<bool>(ve,primBoolean(),booleanArray(),booleanArray2(), booleanArray3()); @@ -1016,66 +1035,66 @@ void addOperators(venv &ve) addOps<pair>(ve,primPair(),pairArray(),pairArray2(),pairArray3(),false,true); addBasicOps<triple>(ve,primTriple(),tripleArray(),tripleArray2(), tripleArray3()); - addFunc(ve,opArray<double,triple,times>,tripleArray(),"*", - formal(primReal(),"a"),formal(tripleArray(),"b")); - addFunc(ve,opArray2<double,triple,timesR>,tripleArray2(),"*", - formal(primReal(),"a"),formal(tripleArray2(),"b")); - addFunc(ve,arrayOp<triple,double,timesR>,tripleArray(),"*", - formal(tripleArray(),"a"),formal(primReal(),"b")); - addFunc(ve,array2Op<triple,double,timesR>,tripleArray2(),"*", - formal(tripleArray2(),"a"),formal(primReal(),"b")); - addFunc(ve,arrayOp<triple,double,divide>,tripleArray(),"/", - formal(tripleArray(),"a"),formal(primReal(),"b")); + addFunc(ve,opArray<double,triple,times>,tripleArray(),SYM_TIMES, + formal(primReal(),SYM(a)),formal(tripleArray(),SYM(b))); + addFunc(ve,opArray2<double,triple,timesR>,tripleArray2(),SYM_TIMES, + formal(primReal(),SYM(a)),formal(tripleArray2(),SYM(b))); + addFunc(ve,arrayOp<triple,double,timesR>,tripleArray(),SYM_TIMES, + formal(tripleArray(),SYM(a)),formal(primReal(),SYM(b))); + addFunc(ve,array2Op<triple,double,timesR>,tripleArray2(),SYM_TIMES, + formal(tripleArray2(),SYM(a)),formal(primReal(),SYM(b))); + addFunc(ve,arrayOp<triple,double,divide>,tripleArray(),SYM_DIVIDE, + formal(tripleArray(),SYM(a)),formal(primReal(),SYM(b))); addUnorderedOps<string>(ve,primString(),stringArray(),stringArray2(), stringArray3()); - addSimpleOperator(ve,binaryOp<pair,minbound>,primPair(),"minbound"); - addSimpleOperator(ve,binaryOp<pair,maxbound>,primPair(),"maxbound"); - addSimpleOperator(ve,binaryOp<triple,minbound>,primTriple(),"minbound"); - addSimpleOperator(ve,binaryOp<triple,maxbound>,primTriple(),"maxbound"); + addSimpleOperator(ve,binaryOp<pair,minbound>,primPair(),SYM(minbound)); + addSimpleOperator(ve,binaryOp<pair,maxbound>,primPair(),SYM(maxbound)); + addSimpleOperator(ve,binaryOp<triple,minbound>,primTriple(),SYM(minbound)); + addSimpleOperator(ve,binaryOp<triple,maxbound>,primTriple(),SYM(maxbound)); addBinOps<pair,minbound>(ve,primPair(),pairArray(),pairArray2(),pairArray3(), - "minbound"); + SYM(minbound)); addBinOps<pair,maxbound>(ve,primPair(),pairArray(),pairArray2(),pairArray3(), - "maxbound"); + SYM(maxbound)); addBinOps<triple,minbound>(ve,primTriple(),tripleArray(),tripleArray2(), - tripleArray3(),"minbound"); + tripleArray3(),SYM(minbound)); addBinOps<triple,maxbound>(ve,primTriple(),tripleArray(),tripleArray2(), - tripleArray3(),"maxbound"); - - addFunc(ve,arrayFunc<double,pair,abs>,realArray(),"abs", - formal(pairArray(),"a")); - addFunc(ve,arrayFunc<double,triple,abs>,realArray(),"abs", - formal(tripleArray(),"a")); - - addFunc(ve,arrayFunc<pair,pair,conjugate>,pairArray(),"conj", - formal(pairArray(),"a")); - addFunc(ve,arrayFunc2<pair,pair,conjugate>,pairArray2(),"conj", - formal(pairArray2(),"a")); - - addFunc(ve,binaryOp<Int,divide>,primReal(),"/", - formal(primInt(),"a"),formal(primInt(),"b")); - addFunc(ve,arrayOp<Int,Int,divide>,realArray(),"/", - formal(IntArray(),"a"),formal(primInt(),"b")); - addFunc(ve,opArray<Int,Int,divide>,realArray(),"/", - formal(primInt(),"a"),formal(IntArray(),"b")); - addFunc(ve,arrayArrayOp<Int,divide>,realArray(),"/", - formal(IntArray(),"a"),formal(IntArray(),"b")); + tripleArray3(),SYM(maxbound)); + + addFunc(ve,arrayFunc<double,pair,abs>,realArray(),SYM(abs), + formal(pairArray(),SYM(a))); + addFunc(ve,arrayFunc<double,triple,abs>,realArray(),SYM(abs), + formal(tripleArray(),SYM(a))); + + addFunc(ve,arrayFunc<pair,pair,conjugate>,pairArray(),SYM(conj), + formal(pairArray(),SYM(a))); + addFunc(ve,arrayFunc2<pair,pair,conjugate>,pairArray2(),SYM(conj), + formal(pairArray2(),SYM(a))); + + addFunc(ve,binaryOp<Int,divide>,primReal(),SYM_DIVIDE, + formal(primInt(),SYM(a)),formal(primInt(),SYM(b))); + addFunc(ve,arrayOp<Int,Int,divide>,realArray(),SYM_DIVIDE, + formal(IntArray(),SYM(a)),formal(primInt(),SYM(b))); + addFunc(ve,opArray<Int,Int,divide>,realArray(),SYM_DIVIDE, + formal(primInt(),SYM(a)),formal(IntArray(),SYM(b))); + addFunc(ve,arrayArrayOp<Int,divide>,realArray(),SYM_DIVIDE, + formal(IntArray(),SYM(a)),formal(IntArray(),SYM(b))); addOrderedOps<Int>(ve,primInt(),IntArray(),IntArray2(),IntArray3()); addOrderedOps<double>(ve,primReal(),realArray(),realArray2(),realArray3()); addOrderedOps<string>(ve,primString(),stringArray(),stringArray2(), stringArray3()); - addOps<Int,mod>(ve,primInt(),"%",IntArray()); - addOps<double,mod>(ve,primReal(),"%",realArray()); + addOps<Int,mod>(ve,primInt(),SYM_MOD,IntArray()); + addOps<double,mod>(ve,primReal(),SYM_MOD,realArray()); - addRestFunc(ve,diagonal<Int>,IntArray2(),"diagonal",IntArray()); - addRestFunc(ve,diagonal<double>,realArray2(),"diagonal",realArray()); - addRestFunc(ve,diagonal<pair>,pairArray2(),"diagonal",pairArray()); + addRestFunc(ve,diagonal<Int>,IntArray2(),SYM(diagonal),IntArray()); + addRestFunc(ve,diagonal<double>,realArray2(),SYM(diagonal),realArray()); + addRestFunc(ve,diagonal<pair>,pairArray2(),SYM(diagonal),pairArray()); } -dummyRecord *createDummyRecord(venv &ve, const char *name) +dummyRecord *createDummyRecord(venv &ve, symbol *name) { dummyRecord *r=new dummyRecord(name); #ifdef DEBUG_FRAME @@ -1112,357 +1131,357 @@ void base_venv(venv &ve) addOperators(ve); addGuideOperators(ve); - addRealFunc(sin); - addRealFunc(cos); - addRealFunc(tan); - addRealFunc(asin); - addRealFunc(acos); - addRealFunc(atan); - addRealFunc(exp); - addRealFunc(log); - addRealFunc(log10); - addRealFunc(sinh); - addRealFunc(cosh); - addRealFunc(tanh); - addRealFunc(asinh); - addRealFunc(acosh); - addRealFunc(atanh); - addRealFunc(sqrt); - addRealFunc(cbrt); - addRealFunc(fabs); - addRealFunc<fabs>(ve,"abs"); - addRealFunc(expm1); - addRealFunc(log1p); - addRealIntFunc<ldexp>(ve, "ldexp", "x", "e"); - - addRealFunc(pow10); - addRealFunc(identity); + addRealFunc(sin,SYM(sin)); + addRealFunc(cos,SYM(cos)); + addRealFunc(tan,SYM(tan)); + addRealFunc(asin,SYM(asin)); + addRealFunc(acos,SYM(acos)); + addRealFunc(atan,SYM(atan)); + addRealFunc(exp,SYM(exp)); + addRealFunc(log,SYM(log)); + addRealFunc(log10,SYM(log10)); + addRealFunc(sinh,SYM(sinh)); + addRealFunc(cosh,SYM(cosh)); + addRealFunc(tanh,SYM(tanh)); + addRealFunc(asinh,SYM(asinh)); + addRealFunc(acosh,SYM(acosh)); + addRealFunc(atanh,SYM(atanh)); + addRealFunc(sqrt,SYM(sqrt)); + addRealFunc(cbrt,SYM(cbrt)); + addRealFunc(fabs,SYM(fabs)); + addRealFunc<fabs>(ve,SYM(abs)); + addRealFunc(expm1,SYM(expm1)); + addRealFunc(log1p,SYM(log1p)); + addRealIntFunc<ldexp>(ve, SYM(ldexp), SYM(x), SYM(e)); + + addRealFunc(pow10,SYM(pow10)); + addRealFunc(identity,SYM(identity)); #ifdef HAVE_LIBGSL - GSLModule=new dummyRecord(symbol::trans("gsl")); + GSLModule=new dummyRecord(SYM(gsl)); gsl_set_error_handler(GSLerrorhandler); // Common functions - addGSLRealRealFunc<gsl_hypot>("hypot","x","y"); -// addGSLRealRealRealFunc<gsl_hypot3>("hypot","x","y","z"); - addGSLRealRealRealFuncInt<gsl_fcmp>("fcmp","x","y","epsilon"); + addGSLRealRealFunc<gsl_hypot>(SYM(hypot),SYM(x),SYM(y)); +// addGSLRealRealRealFunc<gsl_hypot3>(SYM(hypot),SYM(x),SYM(y),SYM(z)); + addGSLRealRealRealFuncInt<gsl_fcmp>(SYM(fcmp),SYM(x),SYM(y),SYM(epsilon)); // Airy functions - addGSLDOUBLEFunc<gsl_sf_airy_Ai>("Ai"); - addGSLDOUBLEFunc<gsl_sf_airy_Bi>("Bi"); - addGSLDOUBLEFunc<gsl_sf_airy_Ai_scaled>("Ai_scaled"); - addGSLDOUBLEFunc<gsl_sf_airy_Bi_scaled>("Bi_scaled"); - addGSLDOUBLEFunc<gsl_sf_airy_Ai_deriv>("Ai_deriv"); - addGSLDOUBLEFunc<gsl_sf_airy_Bi_deriv>("Bi_deriv"); - addGSLDOUBLEFunc<gsl_sf_airy_Ai_deriv_scaled>("Ai_deriv_scaled"); - addGSLDOUBLEFunc<gsl_sf_airy_Bi_deriv_scaled>("Bi_deriv_scaled"); - addGSLIntFunc<gsl_sf_airy_zero_Ai>("zero_Ai"); - addGSLIntFunc<gsl_sf_airy_zero_Bi>("zero_Bi"); - addGSLIntFunc<gsl_sf_airy_zero_Ai_deriv>("zero_Ai_deriv"); - addGSLIntFunc<gsl_sf_airy_zero_Bi_deriv>("zero_Bi_deriv"); + addGSLDOUBLEFunc<gsl_sf_airy_Ai>(SYM(Ai)); + addGSLDOUBLEFunc<gsl_sf_airy_Bi>(SYM(Bi)); + addGSLDOUBLEFunc<gsl_sf_airy_Ai_scaled>(SYM(Ai_scaled)); + addGSLDOUBLEFunc<gsl_sf_airy_Bi_scaled>(SYM(Bi_scaled)); + addGSLDOUBLEFunc<gsl_sf_airy_Ai_deriv>(SYM(Ai_deriv)); + addGSLDOUBLEFunc<gsl_sf_airy_Bi_deriv>(SYM(Bi_deriv)); + addGSLDOUBLEFunc<gsl_sf_airy_Ai_deriv_scaled>(SYM(Ai_deriv_scaled)); + addGSLDOUBLEFunc<gsl_sf_airy_Bi_deriv_scaled>(SYM(Bi_deriv_scaled)); + addGSLIntFunc<gsl_sf_airy_zero_Ai>(SYM(zero_Ai)); + addGSLIntFunc<gsl_sf_airy_zero_Bi>(SYM(zero_Bi)); + addGSLIntFunc<gsl_sf_airy_zero_Ai_deriv>(SYM(zero_Ai_deriv)); + addGSLIntFunc<gsl_sf_airy_zero_Bi_deriv>(SYM(zero_Bi_deriv)); // Bessel functions - addGSLRealFunc<gsl_sf_bessel_J0>("J0"); - addGSLRealFunc<gsl_sf_bessel_J1>("J1"); - addGSLIntRealFunc<gsl_sf_bessel_Jn>("Jn"); - addGSLRealFunc<gsl_sf_bessel_Y0>("Y0"); - addGSLRealFunc<gsl_sf_bessel_Y1>("Y1"); - addGSLIntRealFunc<gsl_sf_bessel_Yn>("Yn"); - addGSLRealFunc<gsl_sf_bessel_I0>("I0"); - addGSLRealFunc<gsl_sf_bessel_I1>("I1"); - addGSLIntRealFunc<gsl_sf_bessel_In>("I"); - addGSLRealFunc<gsl_sf_bessel_I0_scaled>("I0_scaled"); - addGSLRealFunc<gsl_sf_bessel_I1_scaled>("I1_scaled"); - addGSLIntRealFunc<gsl_sf_bessel_In_scaled>("I_scaled"); - addGSLRealFunc<gsl_sf_bessel_K0>("K0"); - addGSLRealFunc<gsl_sf_bessel_K1>("K1"); - addGSLIntRealFunc<gsl_sf_bessel_Kn>("K"); - addGSLRealFunc<gsl_sf_bessel_K0_scaled>("K0_scaled"); - addGSLRealFunc<gsl_sf_bessel_K1_scaled>("K1_scaled"); - addGSLIntRealFunc<gsl_sf_bessel_Kn_scaled>("K_scaled"); - addGSLRealFunc<gsl_sf_bessel_j0>("j0"); - addGSLRealFunc<gsl_sf_bessel_j1>("j1"); - addGSLRealFunc<gsl_sf_bessel_j2>("j2"); - addGSLIntRealFunc<gsl_sf_bessel_jl>("j","l"); - addGSLRealFunc<gsl_sf_bessel_y0>("y0"); - addGSLRealFunc<gsl_sf_bessel_y1>("y1"); - addGSLRealFunc<gsl_sf_bessel_y2>("y2"); - addGSLIntRealFunc<gsl_sf_bessel_yl>("y","l"); - addGSLRealFunc<gsl_sf_bessel_i0_scaled>("i0_scaled"); - addGSLRealFunc<gsl_sf_bessel_i1_scaled>("i1_scaled"); - addGSLRealFunc<gsl_sf_bessel_i2_scaled>("i2_scaled"); - addGSLIntRealFunc<gsl_sf_bessel_il_scaled>("i_scaled","l"); - addGSLRealFunc<gsl_sf_bessel_k0_scaled>("k0_scaled"); - addGSLRealFunc<gsl_sf_bessel_k1_scaled>("k1_scaled"); - addGSLRealFunc<gsl_sf_bessel_k2_scaled>("k2_scaled"); - addGSLIntRealFunc<gsl_sf_bessel_kl_scaled>("k_scaled","l"); - addGSLRealRealFunc<gsl_sf_bessel_Jnu>("J"); - addGSLRealRealFunc<gsl_sf_bessel_Ynu>("Y"); - addGSLRealRealFunc<gsl_sf_bessel_Inu>("I"); - addGSLRealRealFunc<gsl_sf_bessel_Inu_scaled>("I_scaled"); - addGSLRealRealFunc<gsl_sf_bessel_Knu>("K"); - addGSLRealRealFunc<gsl_sf_bessel_lnKnu>("lnK"); - addGSLRealRealFunc<gsl_sf_bessel_Knu_scaled>("K_scaled"); - addGSLIntFunc<gsl_sf_bessel_zero_J0>("zero_J0"); - addGSLIntFunc<gsl_sf_bessel_zero_J1>("zero_J1"); - addGSLRealIntFunc<gsl_sf_bessel_zero_Jnu>("zero_J"); + addGSLRealFunc<gsl_sf_bessel_J0>(SYM(J0)); + addGSLRealFunc<gsl_sf_bessel_J1>(SYM(J1)); + addGSLIntRealFunc<gsl_sf_bessel_Jn>(SYM(Jn)); + addGSLRealFunc<gsl_sf_bessel_Y0>(SYM(Y0)); + addGSLRealFunc<gsl_sf_bessel_Y1>(SYM(Y1)); + addGSLIntRealFunc<gsl_sf_bessel_Yn>(SYM(Yn)); + addGSLRealFunc<gsl_sf_bessel_I0>(SYM(I0)); + addGSLRealFunc<gsl_sf_bessel_I1>(SYM(I1)); + addGSLIntRealFunc<gsl_sf_bessel_In>(SYM(I)); + addGSLRealFunc<gsl_sf_bessel_I0_scaled>(SYM(I0_scaled)); + addGSLRealFunc<gsl_sf_bessel_I1_scaled>(SYM(I1_scaled)); + addGSLIntRealFunc<gsl_sf_bessel_In_scaled>(SYM(I_scaled)); + addGSLRealFunc<gsl_sf_bessel_K0>(SYM(K0)); + addGSLRealFunc<gsl_sf_bessel_K1>(SYM(K1)); + addGSLIntRealFunc<gsl_sf_bessel_Kn>(SYM(K)); + addGSLRealFunc<gsl_sf_bessel_K0_scaled>(SYM(K0_scaled)); + addGSLRealFunc<gsl_sf_bessel_K1_scaled>(SYM(K1_scaled)); + addGSLIntRealFunc<gsl_sf_bessel_Kn_scaled>(SYM(K_scaled)); + addGSLRealFunc<gsl_sf_bessel_j0>(SYM(j0)); + addGSLRealFunc<gsl_sf_bessel_j1>(SYM(j1)); + addGSLRealFunc<gsl_sf_bessel_j2>(SYM(j2)); + addGSLIntRealFunc<gsl_sf_bessel_jl>(SYM(j),SYM(l)); + addGSLRealFunc<gsl_sf_bessel_y0>(SYM(y0)); + addGSLRealFunc<gsl_sf_bessel_y1>(SYM(y1)); + addGSLRealFunc<gsl_sf_bessel_y2>(SYM(y2)); + addGSLIntRealFunc<gsl_sf_bessel_yl>(SYM(y),SYM(l)); + addGSLRealFunc<gsl_sf_bessel_i0_scaled>(SYM(i0_scaled)); + addGSLRealFunc<gsl_sf_bessel_i1_scaled>(SYM(i1_scaled)); + addGSLRealFunc<gsl_sf_bessel_i2_scaled>(SYM(i2_scaled)); + addGSLIntRealFunc<gsl_sf_bessel_il_scaled>(SYM(i_scaled),SYM(l)); + addGSLRealFunc<gsl_sf_bessel_k0_scaled>(SYM(k0_scaled)); + addGSLRealFunc<gsl_sf_bessel_k1_scaled>(SYM(k1_scaled)); + addGSLRealFunc<gsl_sf_bessel_k2_scaled>(SYM(k2_scaled)); + addGSLIntRealFunc<gsl_sf_bessel_kl_scaled>(SYM(k_scaled),SYM(l)); + addGSLRealRealFunc<gsl_sf_bessel_Jnu>(SYM(J)); + addGSLRealRealFunc<gsl_sf_bessel_Ynu>(SYM(Y)); + addGSLRealRealFunc<gsl_sf_bessel_Inu>(SYM(I)); + addGSLRealRealFunc<gsl_sf_bessel_Inu_scaled>(SYM(I_scaled)); + addGSLRealRealFunc<gsl_sf_bessel_Knu>(SYM(K)); + addGSLRealRealFunc<gsl_sf_bessel_lnKnu>(SYM(lnK)); + addGSLRealRealFunc<gsl_sf_bessel_Knu_scaled>(SYM(K_scaled)); + addGSLIntFunc<gsl_sf_bessel_zero_J0>(SYM(zero_J0)); + addGSLIntFunc<gsl_sf_bessel_zero_J1>(SYM(zero_J1)); + addGSLRealIntFunc<gsl_sf_bessel_zero_Jnu>(SYM(zero_J)); // Clausen functions - addGSLRealFunc<gsl_sf_clausen>("clausen"); + addGSLRealFunc<gsl_sf_clausen>(SYM(clausen)); // Coulomb functions - addGSLRealRealFunc<gsl_sf_hydrogenicR_1>("hydrogenicR_1","Z","r"); - addGSLIntIntRealRealFunc<gsl_sf_hydrogenicR>("hydrogenicR","n","l","Z", - "r"); + addGSLRealRealFunc<gsl_sf_hydrogenicR_1>(SYM(hydrogenicR_1),SYM(Z),SYM(r)); + addGSLIntIntRealRealFunc<gsl_sf_hydrogenicR>(SYM(hydrogenicR),SYM(n),SYM(l),SYM(Z), + SYM(r)); // Missing: F_L(eta,x), G_L(eta,x), C_L(eta) // Coupling coefficients - addGSLIntIntIntIntIntIntFunc<gsl_sf_coupling_3j>("coupling_3j","two_ja", - "two_jb","two_jc","two_ma", - "two_mb","two_mc"); - addGSLIntIntIntIntIntIntFunc<gsl_sf_coupling_6j>("coupling_6j","two_ja", - "two_jb","two_jc","two_jd", - "two_je","two_jf"); - addGSLIntIntIntIntIntIntIntIntIntFunc<gsl_sf_coupling_9j>("coupling_9j", - "two_ja","two_jb", - "two_jc","two_jd", - "two_je","two_jf", - "two_jg","two_jh", - "two_ji"); + addGSLIntIntIntIntIntIntFunc<gsl_sf_coupling_3j>(SYM(coupling_3j),SYM(two_ja), + SYM(two_jb),SYM(two_jc),SYM(two_ma), + SYM(two_mb),SYM(two_mc)); + addGSLIntIntIntIntIntIntFunc<gsl_sf_coupling_6j>(SYM(coupling_6j),SYM(two_ja), + SYM(two_jb),SYM(two_jc),SYM(two_jd), + SYM(two_je),SYM(two_jf)); + addGSLIntIntIntIntIntIntIntIntIntFunc<gsl_sf_coupling_9j>(SYM(coupling_9j), + SYM(two_ja),SYM(two_jb), + SYM(two_jc),SYM(two_jd), + SYM(two_je),SYM(two_jf), + SYM(two_jg),SYM(two_jh), + SYM(two_ji)); // Dawson function - addGSLRealFunc<gsl_sf_dawson>("dawson"); + addGSLRealFunc<gsl_sf_dawson>(SYM(dawson)); // Debye functions - addGSLRealFunc<gsl_sf_debye_1>("debye_1"); - addGSLRealFunc<gsl_sf_debye_2>("debye_2"); - addGSLRealFunc<gsl_sf_debye_3>("debye_3"); - addGSLRealFunc<gsl_sf_debye_4>("debye_4"); - addGSLRealFunc<gsl_sf_debye_5>("debye_5"); - addGSLRealFunc<gsl_sf_debye_6>("debye_6"); + addGSLRealFunc<gsl_sf_debye_1>(SYM(debye_1)); + addGSLRealFunc<gsl_sf_debye_2>(SYM(debye_2)); + addGSLRealFunc<gsl_sf_debye_3>(SYM(debye_3)); + addGSLRealFunc<gsl_sf_debye_4>(SYM(debye_4)); + addGSLRealFunc<gsl_sf_debye_5>(SYM(debye_5)); + addGSLRealFunc<gsl_sf_debye_6>(SYM(debye_6)); // Dilogarithm - addGSLRealFunc<gsl_sf_dilog>("dilog"); + addGSLRealFunc<gsl_sf_dilog>(SYM(dilog)); // Missing: complex dilogarithm // Elementary operations // we don't support errors at the moment // Elliptic integrals - addGSLDOUBLEFunc<gsl_sf_ellint_Kcomp>("K","k"); - addGSLDOUBLEFunc<gsl_sf_ellint_Ecomp>("E","k"); - addGSLDOUBLE2Func<gsl_sf_ellint_Pcomp>("P","k","n"); - addGSLDOUBLE2Func<gsl_sf_ellint_F>("F"); - addGSLDOUBLE2Func<gsl_sf_ellint_E>("E"); - addGSLDOUBLE3Func<gsl_sf_ellint_P>("P","phi","k","n"); - addGSLDOUBLE3Func<gsl_sf_ellint_D>("D","phi","k","n"); - addGSLDOUBLE2Func<gsl_sf_ellint_RC>("RC","x","y"); - addGSLDOUBLE3Func<gsl_sf_ellint_RD>("RD","x","y","z"); - addGSLDOUBLE3Func<gsl_sf_ellint_RF>("RF","x","y","z"); - addGSLDOUBLE4Func<gsl_sf_ellint_RJ>("RJ","x","y","z","p"); + addGSLDOUBLEFunc<gsl_sf_ellint_Kcomp>(SYM(K),SYM(k)); + addGSLDOUBLEFunc<gsl_sf_ellint_Ecomp>(SYM(E),SYM(k)); + addGSLDOUBLE2Func<gsl_sf_ellint_Pcomp>(SYM(P),SYM(k),SYM(n)); + addGSLDOUBLE2Func<gsl_sf_ellint_F>(SYM(F)); + addGSLDOUBLE2Func<gsl_sf_ellint_E>(SYM(E)); + addGSLDOUBLE3Func<gsl_sf_ellint_P>(SYM(P),SYM(phi),SYM(k),SYM(n)); + addGSLDOUBLE3Func<gsl_sf_ellint_D>(SYM(D),SYM(phi),SYM(k),SYM(n)); + addGSLDOUBLE2Func<gsl_sf_ellint_RC>(SYM(RC),SYM(x),SYM(y)); + addGSLDOUBLE3Func<gsl_sf_ellint_RD>(SYM(RD),SYM(x),SYM(y),SYM(z)); + addGSLDOUBLE3Func<gsl_sf_ellint_RF>(SYM(RF),SYM(x),SYM(y),SYM(z)); + addGSLDOUBLE4Func<gsl_sf_ellint_RJ>(SYM(RJ),SYM(x),SYM(y),SYM(z),SYM(p)); // Elliptic functions (Jacobi) // to be implemented // Error functions - addGSLRealFunc<gsl_sf_erf>("erf"); - addGSLRealFunc<gsl_sf_erfc>("erfc"); - addGSLRealFunc<gsl_sf_log_erfc>("log_erfc"); - addGSLRealFunc<gsl_sf_erf_Z>("erf_Z"); - addGSLRealFunc<gsl_sf_erf_Q>("erf_Q"); - addGSLRealFunc<gsl_sf_hazard>("hazard"); + addGSLRealFunc<gsl_sf_erf>(SYM(erf)); + addGSLRealFunc<gsl_sf_erfc>(SYM(erfc)); + addGSLRealFunc<gsl_sf_log_erfc>(SYM(log_erfc)); + addGSLRealFunc<gsl_sf_erf_Z>(SYM(erf_Z)); + addGSLRealFunc<gsl_sf_erf_Q>(SYM(erf_Q)); + addGSLRealFunc<gsl_sf_hazard>(SYM(hazard)); // Exponential functions - addGSLRealRealFunc<gsl_sf_exp_mult>("exp_mult","x","y"); -// addGSLRealFunc<gsl_sf_expm1>("expm1"); - addGSLRealFunc<gsl_sf_exprel>("exprel"); - addGSLRealFunc<gsl_sf_exprel_2>("exprel_2"); - addGSLIntRealFunc<gsl_sf_exprel_n>("exprel","n","x"); + addGSLRealRealFunc<gsl_sf_exp_mult>(SYM(exp_mult),SYM(x),SYM(y)); +// addGSLRealFunc<gsl_sf_expm1>(SYM(expm1)); + addGSLRealFunc<gsl_sf_exprel>(SYM(exprel)); + addGSLRealFunc<gsl_sf_exprel_2>(SYM(exprel_2)); + addGSLIntRealFunc<gsl_sf_exprel_n>(SYM(exprel),SYM(n),SYM(x)); // Exponential integrals - addGSLRealFunc<gsl_sf_expint_E1>("E1"); - addGSLRealFunc<gsl_sf_expint_E2>("E2"); -// addGSLIntRealFunc<gsl_sf_expint_En>("En","n","x"); - addGSLRealFunc<gsl_sf_expint_Ei>("Ei"); - addGSLRealFunc<gsl_sf_Shi>("Shi"); - addGSLRealFunc<gsl_sf_Chi>("Chi"); - addGSLRealFunc<gsl_sf_expint_3>("Ei3"); - addGSLRealFunc<gsl_sf_Si>("Si"); - addGSLRealFunc<gsl_sf_Ci>("Ci"); - addGSLRealFunc<gsl_sf_atanint>("atanint"); + addGSLRealFunc<gsl_sf_expint_E1>(SYM(E1)); + addGSLRealFunc<gsl_sf_expint_E2>(SYM(E2)); +// addGSLIntRealFunc<gsl_sf_expint_En>(SYM(En),SYM(n),SYM(x)); + addGSLRealFunc<gsl_sf_expint_Ei>(SYM(Ei)); + addGSLRealFunc<gsl_sf_Shi>(SYM(Shi)); + addGSLRealFunc<gsl_sf_Chi>(SYM(Chi)); + addGSLRealFunc<gsl_sf_expint_3>(SYM(Ei3)); + addGSLRealFunc<gsl_sf_Si>(SYM(Si)); + addGSLRealFunc<gsl_sf_Ci>(SYM(Ci)); + addGSLRealFunc<gsl_sf_atanint>(SYM(atanint)); // Fermi--Dirac function - addGSLRealFunc<gsl_sf_fermi_dirac_m1>("FermiDiracM1"); - addGSLRealFunc<gsl_sf_fermi_dirac_0>("FermiDirac0"); - addGSLRealFunc<gsl_sf_fermi_dirac_1>("FermiDirac1"); - addGSLRealFunc<gsl_sf_fermi_dirac_2>("FermiDirac2"); - addGSLIntRealFunc<gsl_sf_fermi_dirac_int>("FermiDirac","j","x"); - addGSLRealFunc<gsl_sf_fermi_dirac_mhalf>("FermiDiracMHalf"); - addGSLRealFunc<gsl_sf_fermi_dirac_half>("FermiDiracHalf"); - addGSLRealFunc<gsl_sf_fermi_dirac_3half>("FermiDirac3Half"); - addGSLRealRealFunc<gsl_sf_fermi_dirac_inc_0>("FermiDiracInc0","x","b"); + addGSLRealFunc<gsl_sf_fermi_dirac_m1>(SYM(FermiDiracM1)); + addGSLRealFunc<gsl_sf_fermi_dirac_0>(SYM(FermiDirac0)); + addGSLRealFunc<gsl_sf_fermi_dirac_1>(SYM(FermiDirac1)); + addGSLRealFunc<gsl_sf_fermi_dirac_2>(SYM(FermiDirac2)); + addGSLIntRealFunc<gsl_sf_fermi_dirac_int>(SYM(FermiDirac),SYM(j),SYM(x)); + addGSLRealFunc<gsl_sf_fermi_dirac_mhalf>(SYM(FermiDiracMHalf)); + addGSLRealFunc<gsl_sf_fermi_dirac_half>(SYM(FermiDiracHalf)); + addGSLRealFunc<gsl_sf_fermi_dirac_3half>(SYM(FermiDirac3Half)); + addGSLRealRealFunc<gsl_sf_fermi_dirac_inc_0>(SYM(FermiDiracInc0),SYM(x),SYM(b)); // Gamma and beta functions - addGSLRealFunc<gsl_sf_gamma>("gamma"); - addGSLRealFunc<gsl_sf_lngamma>("lngamma"); - addGSLRealFunc<gsl_sf_gammastar>("gammastar"); - addGSLRealFunc<gsl_sf_gammainv>("gammainv"); - addGSLIntFunc<gsl_sf_fact>("fact"); - addGSLIntFunc<gsl_sf_doublefact>("doublefact"); - addGSLIntFunc<gsl_sf_lnfact>("lnfact"); - addGSLIntFunc<gsl_sf_lndoublefact>("lndoublefact"); - addGSLUnsignedUnsignedFunc<gsl_sf_choose>("choose","n","m"); - addGSLUnsignedUnsignedFunc<gsl_sf_lnchoose>("lnchoose","n","m"); - addGSLIntRealFunc<gsl_sf_taylorcoeff>("taylorcoeff","n","x"); - addGSLRealRealFunc<gsl_sf_poch>("poch","a","x"); - addGSLRealRealFunc<gsl_sf_lnpoch>("lnpoch","a","x"); - addGSLRealRealFunc<gsl_sf_pochrel>("pochrel","a","x"); - addGSLRealRealFunc<gsl_sf_gamma_inc>("gamma","a","x"); - addGSLRealRealFunc<gsl_sf_gamma_inc_Q>("gamma_Q","a","x"); - addGSLRealRealFunc<gsl_sf_gamma_inc_P>("gamma_P","a","x"); - addGSLRealRealFunc<gsl_sf_beta>("beta","a","b"); - addGSLRealRealFunc<gsl_sf_lnbeta>("lnbeta","a","b"); - addGSLRealRealRealFunc<gsl_sf_beta_inc>("beta","a","b","x"); + addGSLRealFunc<gsl_sf_gamma>(SYM(gamma)); + addGSLRealFunc<gsl_sf_lngamma>(SYM(lngamma)); + addGSLRealFunc<gsl_sf_gammastar>(SYM(gammastar)); + addGSLRealFunc<gsl_sf_gammainv>(SYM(gammainv)); + addGSLIntFunc<gsl_sf_fact>(SYM(fact)); + addGSLIntFunc<gsl_sf_doublefact>(SYM(doublefact)); + addGSLIntFunc<gsl_sf_lnfact>(SYM(lnfact)); + addGSLIntFunc<gsl_sf_lndoublefact>(SYM(lndoublefact)); + addGSLUnsignedUnsignedFunc<gsl_sf_choose>(SYM(choose),SYM(n),SYM(m)); + addGSLUnsignedUnsignedFunc<gsl_sf_lnchoose>(SYM(lnchoose),SYM(n),SYM(m)); + addGSLIntRealFunc<gsl_sf_taylorcoeff>(SYM(taylorcoeff),SYM(n),SYM(x)); + addGSLRealRealFunc<gsl_sf_poch>(SYM(poch),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_lnpoch>(SYM(lnpoch),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_pochrel>(SYM(pochrel),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_gamma_inc>(SYM(gamma),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_gamma_inc_Q>(SYM(gamma_Q),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_gamma_inc_P>(SYM(gamma_P),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_beta>(SYM(beta),SYM(a),SYM(b)); + addGSLRealRealFunc<gsl_sf_lnbeta>(SYM(lnbeta),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_sf_beta_inc>(SYM(beta),SYM(a),SYM(b),SYM(x)); // Gegenbauer functions - addGSLRealRealFunc<gsl_sf_gegenpoly_1>("gegenpoly_1","lambda","x"); - addGSLRealRealFunc<gsl_sf_gegenpoly_2>("gegenpoly_2","lambda","x"); - addGSLRealRealFunc<gsl_sf_gegenpoly_3>("gegenpoly_3","lambda","x"); - addGSLIntRealRealFunc<gsl_sf_gegenpoly_n>("gegenpoly","n","lambda","x"); + addGSLRealRealFunc<gsl_sf_gegenpoly_1>(SYM(gegenpoly_1),SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_gegenpoly_2>(SYM(gegenpoly_2),SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_gegenpoly_3>(SYM(gegenpoly_3),SYM(lambda),SYM(x)); + addGSLIntRealRealFunc<gsl_sf_gegenpoly_n>(SYM(gegenpoly),SYM(n),SYM(lambda),SYM(x)); // Hypergeometric functions - addGSLRealRealFunc<gsl_sf_hyperg_0F1>("hy0F1","c","x"); - addGSLIntIntRealFunc<gsl_sf_hyperg_1F1_int>("hy1F1","m","n","x"); - addGSLRealRealRealFunc<gsl_sf_hyperg_1F1>("hy1F1","a","b","x"); - addGSLIntIntRealFunc<gsl_sf_hyperg_U_int>("U","m","n","x"); - addGSLRealRealRealFunc<gsl_sf_hyperg_U>("U","a","b","x"); - addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1>("hy2F1","a","b","c","x"); - addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_conj>("hy2F1_conj","aR","aI","c", - "x"); - addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_renorm>("hy2F1_renorm","a","b", - "c","x"); - addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_conj_renorm>("hy2F1_conj_renorm", - "aR","aI","c","x"); - addGSLRealRealRealFunc<gsl_sf_hyperg_2F0>("hy2F0","a","b","x"); + addGSLRealRealFunc<gsl_sf_hyperg_0F1>(SYM(hy0F1),SYM(c),SYM(x)); + addGSLIntIntRealFunc<gsl_sf_hyperg_1F1_int>(SYM(hy1F1),SYM(m),SYM(n),SYM(x)); + addGSLRealRealRealFunc<gsl_sf_hyperg_1F1>(SYM(hy1F1),SYM(a),SYM(b),SYM(x)); + addGSLIntIntRealFunc<gsl_sf_hyperg_U_int>(SYM(U),SYM(m),SYM(n),SYM(x)); + addGSLRealRealRealFunc<gsl_sf_hyperg_U>(SYM(U),SYM(a),SYM(b),SYM(x)); + addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1>(SYM(hy2F1),SYM(a),SYM(b),SYM(c),SYM(x)); + addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_conj>(SYM(hy2F1_conj),SYM(aR),SYM(aI),SYM(c), + SYM(x)); + addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_renorm>(SYM(hy2F1_renorm),SYM(a),SYM(b), + SYM(c),SYM(x)); + addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_conj_renorm>(SYM(hy2F1_conj_renorm), + SYM(aR),SYM(aI),SYM(c),SYM(x)); + addGSLRealRealRealFunc<gsl_sf_hyperg_2F0>(SYM(hy2F0),SYM(a),SYM(b),SYM(x)); // Laguerre functions - addGSLRealRealFunc<gsl_sf_laguerre_1>("L1","a","x"); - addGSLRealRealFunc<gsl_sf_laguerre_2>("L2","a","x"); - addGSLRealRealFunc<gsl_sf_laguerre_3>("L3","a","x"); - addGSLIntRealRealFunc<gsl_sf_laguerre_n>("L","n","a","x"); + addGSLRealRealFunc<gsl_sf_laguerre_1>(SYM(L1),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_laguerre_2>(SYM(L2),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_laguerre_3>(SYM(L3),SYM(a),SYM(x)); + addGSLIntRealRealFunc<gsl_sf_laguerre_n>(SYM(L),SYM(n),SYM(a),SYM(x)); // Lambert W functions - addGSLRealFunc<gsl_sf_lambert_W0>("W0"); - addGSLRealFunc<gsl_sf_lambert_Wm1>("Wm1"); + addGSLRealFunc<gsl_sf_lambert_W0>(SYM(W0)); + addGSLRealFunc<gsl_sf_lambert_Wm1>(SYM(Wm1)); // Legendre functions and spherical harmonics - addGSLRealFunc<gsl_sf_legendre_P1>("P1"); - addGSLRealFunc<gsl_sf_legendre_P2>("P2"); - addGSLRealFunc<gsl_sf_legendre_P3>("P3"); - addGSLIntRealFunc<gsl_sf_legendre_Pl>("Pl","l"); - addGSLRealFunc<gsl_sf_legendre_Q0>("Q0"); - addGSLRealFunc<gsl_sf_legendre_Q1>("Q1"); - addGSLIntRealFunc<gsl_sf_legendre_Ql>("Ql","l"); - addGSLIntIntRealFunc<gsl_sf_legendre_Plm>("Plm","l","m","x"); - addGSLIntIntRealFunc<gsl_sf_legendre_sphPlm>("sphPlm","l","m","x"); - addGSLRealRealFunc<gsl_sf_conicalP_half>("conicalP_half","lambda","x"); - addGSLRealRealFunc<gsl_sf_conicalP_mhalf>("conicalP_mhalf","lambda","x"); - addGSLRealRealFunc<gsl_sf_conicalP_0>("conicalP_0","lambda","x"); - addGSLRealRealFunc<gsl_sf_conicalP_1>("conicalP_1","lambda","x"); - addGSLIntRealRealFunc<gsl_sf_conicalP_sph_reg>("conicalP_sph_reg","l", - "lambda","x"); - addGSLIntRealRealFunc<gsl_sf_conicalP_cyl_reg>("conicalP_cyl_reg","m", - "lambda","x"); - addGSLRealRealFunc<gsl_sf_legendre_H3d_0>("H3d0","lambda","eta"); - addGSLRealRealFunc<gsl_sf_legendre_H3d_1>("H3d1","lambda","eta"); - addGSLIntRealRealFunc<gsl_sf_legendre_H3d>("H3d","l","lambda","eta"); + addGSLRealFunc<gsl_sf_legendre_P1>(SYM(P1)); + addGSLRealFunc<gsl_sf_legendre_P2>(SYM(P2)); + addGSLRealFunc<gsl_sf_legendre_P3>(SYM(P3)); + addGSLIntRealFunc<gsl_sf_legendre_Pl>(SYM(Pl),SYM(l)); + addGSLRealFunc<gsl_sf_legendre_Q0>(SYM(Q0)); + addGSLRealFunc<gsl_sf_legendre_Q1>(SYM(Q1)); + addGSLIntRealFunc<gsl_sf_legendre_Ql>(SYM(Ql),SYM(l)); + addGSLIntIntRealFunc<gsl_sf_legendre_Plm>(SYM(Plm),SYM(l),SYM(m),SYM(x)); + addGSLIntIntRealFunc<gsl_sf_legendre_sphPlm>(SYM(sphPlm),SYM(l),SYM(m),SYM(x)); + addGSLRealRealFunc<gsl_sf_conicalP_half>(SYM(conicalP_half),SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_conicalP_mhalf>(SYM(conicalP_mhalf),SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_conicalP_0>(SYM(conicalP_0),SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_conicalP_1>(SYM(conicalP_1),SYM(lambda),SYM(x)); + addGSLIntRealRealFunc<gsl_sf_conicalP_sph_reg>(SYM(conicalP_sph_reg),SYM(l), + SYM(lambda),SYM(x)); + addGSLIntRealRealFunc<gsl_sf_conicalP_cyl_reg>(SYM(conicalP_cyl_reg),SYM(m), + SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_legendre_H3d_0>(SYM(H3d0),SYM(lambda),SYM(eta)); + addGSLRealRealFunc<gsl_sf_legendre_H3d_1>(SYM(H3d1),SYM(lambda),SYM(eta)); + addGSLIntRealRealFunc<gsl_sf_legendre_H3d>(SYM(H3d),SYM(l),SYM(lambda),SYM(eta)); // Logarithm and related functions - addGSLRealFunc<gsl_sf_log_abs>("logabs"); -// addGSLRealFunc<gsl_sf_log_1plusx>("log1p"); - addGSLRealFunc<gsl_sf_log_1plusx_mx>("log1pm"); + addGSLRealFunc<gsl_sf_log_abs>(SYM(logabs)); +// addGSLRealFunc<gsl_sf_log_1plusx>(SYM(log1p)); + addGSLRealFunc<gsl_sf_log_1plusx_mx>(SYM(log1pm)); // Matthieu functions // to be implemented // Power function - addGSLRealSignedFunc<gsl_sf_pow_int>("pow","x","n"); + addGSLRealSignedFunc<gsl_sf_pow_int>(SYM(pow),SYM(x),SYM(n)); // Psi (digamma) function - addGSLSignedFunc<gsl_sf_psi_int>("psi","n"); - addGSLRealFunc<gsl_sf_psi>("psi"); - addGSLRealFunc<gsl_sf_psi_1piy>("psi_1piy","y"); - addGSLSignedFunc<gsl_sf_psi_1_int>("psi1","n"); - addGSLRealFunc<gsl_sf_psi_1>("psi1","x"); - addGSLIntRealFunc<gsl_sf_psi_n>("psi","n","x"); + addGSLSignedFunc<gsl_sf_psi_int>(SYM(psi),SYM(n)); + addGSLRealFunc<gsl_sf_psi>(SYM(psi)); + addGSLRealFunc<gsl_sf_psi_1piy>(SYM(psi_1piy),SYM(y)); + addGSLSignedFunc<gsl_sf_psi_1_int>(SYM(psi1),SYM(n)); + addGSLRealFunc<gsl_sf_psi_1>(SYM(psi1),SYM(x)); + addGSLIntRealFunc<gsl_sf_psi_n>(SYM(psi),SYM(n),SYM(x)); // Synchrotron functions - addGSLRealFunc<gsl_sf_synchrotron_1>("synchrotron_1"); - addGSLRealFunc<gsl_sf_synchrotron_2>("synchrotron_2"); + addGSLRealFunc<gsl_sf_synchrotron_1>(SYM(synchrotron_1)); + addGSLRealFunc<gsl_sf_synchrotron_2>(SYM(synchrotron_2)); // Transport functions - addGSLRealFunc<gsl_sf_transport_2>("transport_2"); - addGSLRealFunc<gsl_sf_transport_3>("transport_3"); - addGSLRealFunc<gsl_sf_transport_4>("transport_4"); - addGSLRealFunc<gsl_sf_transport_5>("transport_5"); + addGSLRealFunc<gsl_sf_transport_2>(SYM(transport_2)); + addGSLRealFunc<gsl_sf_transport_3>(SYM(transport_3)); + addGSLRealFunc<gsl_sf_transport_4>(SYM(transport_4)); + addGSLRealFunc<gsl_sf_transport_5>(SYM(transport_5)); // Trigonometric functions - addGSLRealFunc<gsl_sf_sinc>("sinc"); - addGSLRealFunc<gsl_sf_lnsinh>("lnsinh"); - addGSLRealFunc<gsl_sf_lncosh>("lncosh"); + addGSLRealFunc<gsl_sf_sinc>(SYM(sinc)); + addGSLRealFunc<gsl_sf_lnsinh>(SYM(lnsinh)); + addGSLRealFunc<gsl_sf_lncosh>(SYM(lncosh)); // Zeta functions - addGSLSignedFunc<gsl_sf_zeta_int>("zeta","n"); - addGSLRealFunc<gsl_sf_zeta>("zeta","s"); - addGSLSignedFunc<gsl_sf_zetam1_int>("zetam1","n"); - addGSLRealFunc<gsl_sf_zetam1>("zetam1","s"); - addGSLRealRealFunc<gsl_sf_hzeta>("hzeta","s","q"); - addGSLSignedFunc<gsl_sf_eta_int>("eta","n"); - addGSLRealFunc<gsl_sf_eta>("eta","s"); + addGSLSignedFunc<gsl_sf_zeta_int>(SYM(zeta),SYM(n)); + addGSLRealFunc<gsl_sf_zeta>(SYM(zeta),SYM(s)); + addGSLSignedFunc<gsl_sf_zetam1_int>(SYM(zetam1),SYM(n)); + addGSLRealFunc<gsl_sf_zetam1>(SYM(zetam1),SYM(s)); + addGSLRealRealFunc<gsl_sf_hzeta>(SYM(hzeta),SYM(s),SYM(q)); + addGSLSignedFunc<gsl_sf_eta_int>(SYM(eta),SYM(n)); + addGSLRealFunc<gsl_sf_eta>(SYM(eta),SYM(s)); #endif #ifdef STRUCTEXAMPLE - dummyRecord *fun=createDummyRecord(ve, "test"); - addFunc(fun->e.ve,realReal<sin>,primReal(),"f",formal(primReal(),"x")); - addVariable<Int>(fun->e.ve,1,primInt(),"x"); + dummyRecord *fun=createDummyRecord(ve, SYM(test)); + addFunc(fun->e.ve,realReal<sin>,primReal(),SYM(f),formal(primReal(),SYM(x))); + addVariable<Int>(fun->e.ve,1,primInt(),SYM(x)); #endif - addFunc(ve,writestring,primVoid(),"write", - formal(primFile(),"file",true), - formal(primString(),"s"), - formal(voidFileFunction(),"suffix",true)); + addFunc(ve,writestring,primVoid(),SYM(write), + formal(primFile(),SYM(file),true), + formal(primString(),SYM(s)), + formal(voidFileFunction(),SYM(suffix),true)); addWrite(ve,write<transform>,primTransform(),transformArray()); addWrite(ve,write<guide *>,primGuide(),guideArray()); addWrite(ve,write<pen>,primPen(),penArray()); - addFunc(ve,arrayArrayOp<pen,equals>,booleanArray(),"==", - formal(penArray(),"a"),formal(penArray(),"b")); - addFunc(ve,arrayArrayOp<pen,notequals>,booleanArray(),"!=", - formal(penArray(),"a"),formal(penArray(),"b")); - - addFunc(ve,arrayFunction,realArray(),"map", - formal(realPairFunction(),"f"), - formal(pairArray(),"a")); - addFunc(ve,arrayFunction,IntArray(),"map", - formal(IntRealFunction(),"f"), - formal(realArray(),"a")); - - addConstant<Int>(ve, Int_MAX, primInt(), "intMax"); - addConstant<Int>(ve, Int_MIN, primInt(), "intMin"); - addConstant<double>(ve, HUGE_VAL, primReal(), "inf"); - addConstant<double>(ve, run::infinity, primReal(), "infinity"); - addConstant<double>(ve, DBL_MAX, primReal(), "realMax"); - addConstant<double>(ve, DBL_MIN, primReal(), "realMin"); - addConstant<double>(ve, DBL_EPSILON, primReal(), "realEpsilon"); - addConstant<Int>(ve, DBL_DIG, primInt(), "realDigits"); - addConstant<Int>(ve, RAND_MAX, primInt(), "randMax"); - addConstant<double>(ve, PI, primReal(), "pi"); + addFunc(ve,arrayArrayOp<pen,equals>,booleanArray(),SYM_EQ, + formal(penArray(),SYM(a)),formal(penArray(),SYM(b))); + addFunc(ve,arrayArrayOp<pen,notequals>,booleanArray(),SYM_NEQ, + formal(penArray(),SYM(a)),formal(penArray(),SYM(b))); + + addFunc(ve,arrayFunction,realArray(),SYM(map), + formal(realPairFunction(),SYM(f)), + formal(pairArray(),SYM(a))); + addFunc(ve,arrayFunction,IntArray(),SYM(map), + formal(IntRealFunction(),SYM(f)), + formal(realArray(),SYM(a))); + + addConstant<Int>(ve, Int_MAX, primInt(), SYM(intMax)); + addConstant<Int>(ve, Int_MIN, primInt(), SYM(intMin)); + addConstant<double>(ve, HUGE_VAL, primReal(), SYM(inf)); + addConstant<double>(ve, run::infinity, primReal(), SYM(infinity)); + addConstant<double>(ve, DBL_MAX, primReal(), SYM(realMax)); + addConstant<double>(ve, DBL_MIN, primReal(), SYM(realMin)); + addConstant<double>(ve, DBL_EPSILON, primReal(), SYM(realEpsilon)); + addConstant<Int>(ve, DBL_DIG, primInt(), SYM(realDigits)); + addConstant<Int>(ve, RAND_MAX, primInt(), SYM(randMax)); + addConstant<double>(ve, PI, primReal(), SYM(pi)); addConstant<string>(ve, string(settings::VERSION)+string(SVN_REVISION), - primString(),"VERSION"); + primString(),SYM(VERSION)); - addVariable<pen>(ve, &processData().currentpen, primPen(), "currentpen"); + addVariable<pen>(ve, &processData().currentpen, primPen(), SYM(currentpen)); #ifdef OPENFUNCEXAMPLE - addOpenFunc(ve, openFunc, primInt(), "openFunc"); + addOpenFunc(ve, openFunc, primInt(), SYM(openFunc)); #endif gen_runtime_venv(ve); diff --git a/Build/source/utils/asymptote/builtin.h b/Build/source/utils/asymptote/builtin.h index 6f0c382d100..cf877023d58 100644 --- a/Build/source/utils/asymptote/builtin.h +++ b/Build/source/utils/asymptote/builtin.h @@ -22,7 +22,7 @@ void base_venv(venv &); extern const types::formal noformal; // Add a function with one or more default arguments. -void addFunc(venv &ve, vm::bltin f, types::ty *result, const char *name, +void addFunc(venv &ve, vm::bltin f, types::ty *result, symbol *name, types::formal f1=noformal, types::formal f2=noformal, types::formal f3=noformal, types::formal f4=noformal, types::formal f5=noformal, types::formal f6=noformal, diff --git a/Build/source/utils/asymptote/builtin.symbols.h b/Build/source/utils/asymptote/builtin.symbols.h new file mode 100644 index 00000000000..02e44568514 --- /dev/null +++ b/Build/source/utils/asymptote/builtin.symbols.h @@ -0,0 +1,292 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(Ai); +ADDSYMBOL(Ai_deriv); +ADDSYMBOL(Ai_deriv_scaled); +ADDSYMBOL(Ai_scaled); +ADDSYMBOL(Bi); +ADDSYMBOL(Bi_deriv); +ADDSYMBOL(Bi_deriv_scaled); +ADDSYMBOL(Bi_scaled); +ADDSYMBOL(Chi); +ADDSYMBOL(Ci); +ADDSYMBOL(D); +ADDSYMBOL(E); +ADDSYMBOL(E1); +ADDSYMBOL(E2); +ADDSYMBOL(Ei); +ADDSYMBOL(Ei3); +ADDSYMBOL(En); +ADDSYMBOL(F); +ADDSYMBOL(FermiDirac); +ADDSYMBOL(FermiDirac0); +ADDSYMBOL(FermiDirac1); +ADDSYMBOL(FermiDirac2); +ADDSYMBOL(FermiDirac3Half); +ADDSYMBOL(FermiDiracHalf); +ADDSYMBOL(FermiDiracInc0); +ADDSYMBOL(FermiDiracM1); +ADDSYMBOL(FermiDiracMHalf); +ADDSYMBOL(H3d); +ADDSYMBOL(H3d0); +ADDSYMBOL(H3d1); +ADDSYMBOL(I); +ADDSYMBOL(I0); +ADDSYMBOL(I0_scaled); +ADDSYMBOL(I1); +ADDSYMBOL(I1_scaled); +ADDSYMBOL(I_scaled); +ADDSYMBOL(J); +ADDSYMBOL(J0); +ADDSYMBOL(J1); +ADDSYMBOL(Jn); +ADDSYMBOL(K); +ADDSYMBOL(K0); +ADDSYMBOL(K0_scaled); +ADDSYMBOL(K1); +ADDSYMBOL(K1_scaled); +ADDSYMBOL(K_scaled); +ADDSYMBOL(L); +ADDSYMBOL(L1); +ADDSYMBOL(L2); +ADDSYMBOL(L3); +ADDSYMBOL(P); +ADDSYMBOL(P1); +ADDSYMBOL(P2); +ADDSYMBOL(P3); +ADDSYMBOL(Pl); +ADDSYMBOL(Plm); +ADDSYMBOL(Q0); +ADDSYMBOL(Q1); +ADDSYMBOL(Ql); +ADDSYMBOL(RC); +ADDSYMBOL(RD); +ADDSYMBOL(RF); +ADDSYMBOL(RJ); +ADDSYMBOL(Shi); +ADDSYMBOL(Si); +ADDSYMBOL(U); +ADDSYMBOL(VERSION); +ADDSYMBOL(W0); +ADDSYMBOL(Wm1); +ADDSYMBOL(Y); +ADDSYMBOL(Y0); +ADDSYMBOL(Y1); +ADDSYMBOL(Yn); +ADDSYMBOL(Z); +ADDSYMBOL(a); +ADDSYMBOL(aI); +ADDSYMBOL(aR); +ADDSYMBOL(abs); +ADDSYMBOL(acos); +ADDSYMBOL(acosh); +ADDSYMBOL(alias); +ADDSYMBOL(array); +ADDSYMBOL(asin); +ADDSYMBOL(asinh); +ADDSYMBOL(atan); +ADDSYMBOL(atanh); +ADDSYMBOL(atanint); +ADDSYMBOL(b); +ADDSYMBOL(beta); +ADDSYMBOL(c); +ADDSYMBOL(cbrt); +ADDSYMBOL(choose); +ADDSYMBOL(clausen); +ADDSYMBOL(concat); +ADDSYMBOL(conicalP_0); +ADDSYMBOL(conicalP_1); +ADDSYMBOL(conicalP_cyl_reg); +ADDSYMBOL(conicalP_half); +ADDSYMBOL(conicalP_mhalf); +ADDSYMBOL(conicalP_sph_reg); +ADDSYMBOL(conj); +ADDSYMBOL(copy); +ADDSYMBOL(cos); +ADDSYMBOL(cosh); +ADDSYMBOL(coupling_3j); +ADDSYMBOL(coupling_6j); +ADDSYMBOL(coupling_9j); +ADDSYMBOL(currentpen); +ADDSYMBOL(dawson); +ADDSYMBOL(debye_1); +ADDSYMBOL(debye_2); +ADDSYMBOL(debye_3); +ADDSYMBOL(debye_4); +ADDSYMBOL(debye_5); +ADDSYMBOL(debye_6); +ADDSYMBOL(depth); +ADDSYMBOL(diagonal); +ADDSYMBOL(dilog); +ADDSYMBOL(doublefact); +ADDSYMBOL(e); +ADDSYMBOL(epsilon); +ADDSYMBOL(erf); +ADDSYMBOL(erf_Q); +ADDSYMBOL(erf_Z); +ADDSYMBOL(erfc); +ADDSYMBOL(eta); +ADDSYMBOL(exp); +ADDSYMBOL(exp_mult); +ADDSYMBOL(expm1); +ADDSYMBOL(exprel); +ADDSYMBOL(exprel_2); +ADDSYMBOL(f); +ADDSYMBOL(fabs); +ADDSYMBOL(fact); +ADDSYMBOL(fcmp); +ADDSYMBOL(file); +ADDSYMBOL(gamma); +ADDSYMBOL(gamma_P); +ADDSYMBOL(gamma_Q); +ADDSYMBOL(gammainv); +ADDSYMBOL(gammastar); +ADDSYMBOL(gegenpoly); +ADDSYMBOL(gegenpoly_1); +ADDSYMBOL(gegenpoly_2); +ADDSYMBOL(gegenpoly_3); +ADDSYMBOL(gsl); +ADDSYMBOL(hazard); +ADDSYMBOL(hy0F1); +ADDSYMBOL(hy1F1); +ADDSYMBOL(hy2F0); +ADDSYMBOL(hy2F1); +ADDSYMBOL(hy2F1_conj); +ADDSYMBOL(hy2F1_conj_renorm); +ADDSYMBOL(hy2F1_renorm); +ADDSYMBOL(hydrogenicR); +ADDSYMBOL(hydrogenicR_1); +ADDSYMBOL(hypot); +ADDSYMBOL(hzeta); +ADDSYMBOL(i0_scaled); +ADDSYMBOL(i1_scaled); +ADDSYMBOL(i2_scaled); +ADDSYMBOL(i_scaled); +ADDSYMBOL(identity); +ADDSYMBOL(inf); +ADDSYMBOL(infinity); +ADDSYMBOL(intMax); +ADDSYMBOL(intMin); +ADDSYMBOL(interp); +ADDSYMBOL(j); +ADDSYMBOL(j0); +ADDSYMBOL(j1); +ADDSYMBOL(j2); +ADDSYMBOL(k); +ADDSYMBOL(k0_scaled); +ADDSYMBOL(k1_scaled); +ADDSYMBOL(k2_scaled); +ADDSYMBOL(k_scaled); +ADDSYMBOL(key); +ADDSYMBOL(l); +ADDSYMBOL(lambda); +ADDSYMBOL(ldexp); +ADDSYMBOL(lnK); +ADDSYMBOL(lnbeta); +ADDSYMBOL(lnchoose); +ADDSYMBOL(lncosh); +ADDSYMBOL(lndoublefact); +ADDSYMBOL(lnfact); +ADDSYMBOL(lngamma); +ADDSYMBOL(lnpoch); +ADDSYMBOL(lnsinh); +ADDSYMBOL(log); +ADDSYMBOL(log10); +ADDSYMBOL(log1p); +ADDSYMBOL(log1pm); +ADDSYMBOL(log_erfc); +ADDSYMBOL(logabs); +ADDSYMBOL(m); +ADDSYMBOL(map); +ADDSYMBOL(max); +ADDSYMBOL(maxbound); +ADDSYMBOL(min); +ADDSYMBOL(minbound); +ADDSYMBOL(n); +ADDSYMBOL(nu); +ADDSYMBOL(openFunc); +ADDSYMBOL(p); +ADDSYMBOL(perm); +ADDSYMBOL(phi); +ADDSYMBOL(pi); +ADDSYMBOL(poch); +ADDSYMBOL(pochrel); +ADDSYMBOL(pow); +ADDSYMBOL(pow10); +ADDSYMBOL(psi); +ADDSYMBOL(psi1); +ADDSYMBOL(psi_1piy); +ADDSYMBOL(q); +ADDSYMBOL(r); +ADDSYMBOL(randMax); +ADDSYMBOL(realDigits); +ADDSYMBOL(realEpsilon); +ADDSYMBOL(realMax); +ADDSYMBOL(realMin); +ADDSYMBOL(s); +ADDSYMBOL(search); +ADDSYMBOL(sequence); +ADDSYMBOL(sin); +ADDSYMBOL(sinc); +ADDSYMBOL(sinh); +ADDSYMBOL(sort); +ADDSYMBOL(sphPlm); +ADDSYMBOL(sqrt); +ADDSYMBOL(suffix); +ADDSYMBOL(sum); +ADDSYMBOL(synchrotron_1); +ADDSYMBOL(synchrotron_2); +ADDSYMBOL(t); +ADDSYMBOL(tan); +ADDSYMBOL(tanh); +ADDSYMBOL(taylorcoeff); +ADDSYMBOL(test); +ADDSYMBOL(transport_2); +ADDSYMBOL(transport_3); +ADDSYMBOL(transport_4); +ADDSYMBOL(transport_5); +ADDSYMBOL(transpose); +ADDSYMBOL(two_ja); +ADDSYMBOL(two_jb); +ADDSYMBOL(two_jc); +ADDSYMBOL(two_jd); +ADDSYMBOL(two_je); +ADDSYMBOL(two_jf); +ADDSYMBOL(two_jg); +ADDSYMBOL(two_jh); +ADDSYMBOL(two_ji); +ADDSYMBOL(two_ma); +ADDSYMBOL(two_mb); +ADDSYMBOL(two_mc); +ADDSYMBOL(value); +ADDSYMBOL(write); +ADDSYMBOL(x); +ADDSYMBOL(y); +ADDSYMBOL(y0); +ADDSYMBOL(y1); +ADDSYMBOL(y2); +ADDSYMBOL(z); +ADDSYMBOL(zero_Ai); +ADDSYMBOL(zero_Ai_deriv); +ADDSYMBOL(zero_Bi); +ADDSYMBOL(zero_Bi_deriv); +ADDSYMBOL(zero_J); +ADDSYMBOL(zero_J0); +ADDSYMBOL(zero_J1); +ADDSYMBOL(zeta); +ADDSYMBOL(zetam1); diff --git a/Build/source/utils/asymptote/camp.l b/Build/source/utils/asymptote/camp.l index f6b53c40f85..477a6d32a2d 100644 --- a/Build/source/utils/asymptote/camp.l +++ b/Build/source/utils/asymptote/camp.l @@ -24,6 +24,8 @@ using mem::string; #include "camp.tab.h" +#include "opsymbols.h" + #define YY_NO_UNPUT fileinfo* fi; @@ -81,8 +83,27 @@ void adjust() yylval.pos = here(); } +void savesymbol(symbol *name) +{ + adjust(); + yylval.ps.pos=here(); + yylval.ps.sym=name; +} + +/* For optimization reasons, the operator names are translated into symbols + * just once, and can be accessed throughout the code as SYM_PLUS, SYM_DASHES, + * etc. Following the Don't Repeat Yourself principle, the mapping from + * strings to names is defined only here in camp.l (because we can't produce + * lex rules from a C style macro). + * The script opsymbols.pl reads this file scanning for rules using DEFSYMBOL + * and creates opsymbols.h which defines the names for use in C++ code. + */ +#define DEFSYMBOL(name) \ + savesymbol(name) + void makesymbol(bool op=true, string text = yytext) { + // TODO: Refactor to a call to savesymbol. adjust(); yylval.ps.pos=here(); yylval.ps.sym=op ? symbol::opTrans(text) : symbol::literalTrans(text); @@ -275,32 +296,33 @@ EXTRAOPS <<|>>|$|$$|@|@@|~ "}" {adjust(); return '}'; } "." {adjust(); return '.'; } "..." {adjust(); return ELLIPSIS; } -"+" {makesymbol(); return '+'; } -"-" {makesymbol(); return '-'; } -"*" {makesymbol(); return '*'; } -"/" {makesymbol(); return '/'; } -"%" {makesymbol(); return '%'; } -"^" {makesymbol(); return '^'; } -"**" {makesymbol(true,"^"); return '^'; } + +"+" {DEFSYMBOL(SYM_PLUS); return '+'; } +"-" {DEFSYMBOL(SYM_MINUS); return '-'; } +"*" {DEFSYMBOL(SYM_TIMES); return '*'; } +"/" {DEFSYMBOL(SYM_DIVIDE); return '/'; } +"%" {DEFSYMBOL(SYM_MOD); return '%'; } +"^" {DEFSYMBOL(SYM_CARET); return '^'; } +"**" {savesymbol(SYM_CARET); return '^'; } "?" {adjust(); return '?'; } "=" {adjust(); return ASSIGN; } -"==" {makesymbol(); return EQ; } -"!=" {makesymbol(); return NEQ; } -"<" {makesymbol(); return LT; } -"<=" {makesymbol(); return LE; } -">" {makesymbol(); return GT; } -">=" {makesymbol(); return GE; } -"&&" {makesymbol(); return CAND; } -"||" {makesymbol(); return COR; } -"!" {makesymbol(); return LOGNOT; } -"^^" {makesymbol(); return CARETS; } -"::" {makesymbol(); return COLONS; } -"++" {makesymbol(); return INCR; } -".." {makesymbol(); return DOTS; } -"--" {makesymbol(); return DASHES; } -"---" {makesymbol(); return LONGDASH; } -"&" {makesymbol(); return AMPERSAND; } -"|" {makesymbol(); return BAR; } +"==" {DEFSYMBOL(SYM_EQ); return EQ; } +"!=" {DEFSYMBOL(SYM_NEQ); return NEQ; } +"<" {DEFSYMBOL(SYM_LT); return LT; } +"<=" {DEFSYMBOL(SYM_LE); return LE; } +">" {DEFSYMBOL(SYM_GT); return GT; } +">=" {DEFSYMBOL(SYM_GE); return GE; } +"&&" {DEFSYMBOL(SYM_CAND); return CAND; } +"||" {DEFSYMBOL(SYM_COR); return COR; } +"!" {DEFSYMBOL(SYM_LOGNOT); return LOGNOT; } +"^^" {DEFSYMBOL(SYM_CARETS); return CARETS; } +"::" {DEFSYMBOL(SYM_COLONS); return COLONS; } +"++" {DEFSYMBOL(SYM_INCR); return INCR; } +".." {DEFSYMBOL(SYM_DOTS); return DOTS; } +"--" {DEFSYMBOL(SYM_DASHES); return DASHES; } +"---" {DEFSYMBOL(SYM_LONGDASH); return LONGDASH; } +"&" {DEFSYMBOL(SYM_AMPERSAND); return AMPERSAND; } +"|" {DEFSYMBOL(SYM_BAR); return BAR; } {EXTRAOPS} {makesymbol(); return OPERATOR; } "+=" {makeselfsymbol(); return ADD; } @@ -311,10 +333,10 @@ EXTRAOPS <<|>>|$|$$|@|@@|~ "^=" {makeselfsymbol(); return EXPONENT; } and {adjust(); return AND; } -controls {makesymbol(); return CONTROLS; } -tension {makesymbol(); return TENSION; } -atleast {makesymbol(); return ATLEAST; } -curl {makesymbol(); return CURL; } +controls {DEFSYMBOL(SYM_CONTROLS); return CONTROLS; } +tension {DEFSYMBOL(SYM_TENSION); return TENSION; } +atleast {DEFSYMBOL(SYM_ATLEAST); return ATLEAST; } +curl {DEFSYMBOL(SYM_CURL); return CURL; } if {adjust(); return IF; } else {adjust(); return ELSE; } diff --git a/Build/source/utils/asymptote/configure b/Build/source/utils/asymptote/configure index 06aa9ad6cd5..6cf43608a3d 100755 --- a/Build/source/utils/asymptote/configure +++ b/Build/source/utils/asymptote/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63 for Asymptote 1.94. +# Generated by GNU Autoconf 2.63 for Asymptote 1.96. # # Report bugs to <http://sourceforge.net/projects/asymptote>. # @@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='Asymptote' PACKAGE_TARNAME='asymptote' -PACKAGE_VERSION='1.94' -PACKAGE_STRING='Asymptote 1.94' +PACKAGE_VERSION='1.96' +PACKAGE_STRING='Asymptote 1.96' PACKAGE_BUGREPORT='http://sourceforge.net/projects/asymptote' # Factoring default headers for most tests. @@ -1294,7 +1294,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Asymptote 1.94 to adapt to many kinds of systems. +\`configure' configures Asymptote 1.96 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1355,7 +1355,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Asymptote 1.94:";; + short | recursive ) echo "Configuration of Asymptote 1.96:";; esac cat <<\_ACEOF @@ -1465,7 +1465,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Asymptote configure 1.94 +Asymptote configure 1.96 generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1479,7 +1479,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Asymptote $as_me 1.94, which was +It was created by Asymptote $as_me 1.96, which was generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ @@ -12019,7 +12019,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Asymptote $as_me 1.94, which was +This file was extended by Asymptote $as_me 1.96, which was generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12078,7 +12078,7 @@ Report bugs to <bug-autoconf@gnu.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -Asymptote config.status 1.94 +Asymptote config.status 1.96 configured by $0, generated by GNU Autoconf 2.63, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/Build/source/utils/asymptote/configure.ac b/Build/source/utils/asymptote/configure.ac index 505fa340808..a2bf1cf0ca6 100644 --- a/Build/source/utils/asymptote/configure.ac +++ b/Build/source/utils/asymptote/configure.ac @@ -3,7 +3,7 @@ # this file. AC_PREREQ(2) -AC_INIT([Asymptote],[1.94],[http://sourceforge.net/projects/asymptote]) +AC_INIT([Asymptote],[1.96],[http://sourceforge.net/projects/asymptote]) VERSION=$PACKAGE_VERSION AC_SUBST(VERSION) diff --git a/Build/source/utils/asymptote/dec.cc b/Build/source/utils/asymptote/dec.cc index 07e1711107c..bc2be656e70 100644 --- a/Build/source/utils/asymptote/dec.cc +++ b/Build/source/utils/asymptote/dec.cc @@ -437,9 +437,32 @@ void initializeVar(position pos, coenv &e, varEntry *v, varinit *init) e.c.encode(inst::pop); } +types::ty *inferType(position pos, coenv &e, varinit *init) +{ + if (!init) { + em.error(pos); + em << "inferred variable declaration without initializer"; + return primError(); + } + + exp *base = dynamic_cast<exp *>(init); + if (base) { + types::ty *t = base->cgetType(e); + if (t->kind != ty_overloaded) + return t; + } + + em.error(pos); + em << "could not infer type of initializer"; + return primError(); +} + void createVar(position pos, coenv &e, record *r, symbol *id, types::ty *t, varinit *init) { + // I'm not sure how to handle inferred types in these cases. + assert(t->kind != types::ty_inferred); + varEntry *v=makeVarEntry(pos, e, r, t); addVar(e, r, v, id); initializeVar(pos, e, v, init); @@ -448,6 +471,12 @@ void createVar(position pos, coenv &e, record *r, void createVarOutOfOrder(position pos, coenv &e, record *r, symbol *id, types::ty *t, varinit *init) { + /* For declarations such as "var x = 5;", infer the type from the + * initializer. + */ + if (t->kind == types::ty_inferred) + t = inferType(pos, e, init); + varEntry *v=makeVarEntry(pos, e, r, t); initializeVar(pos, e, v, init); addVar(e, r, v, id); @@ -544,6 +573,10 @@ public: loadModuleExp(position pos, record *imp) : exp(pos), imp(imp), ft(new function(imp,primString())) {} + void prettyprint(ostream &out, Int indent) { + prettyname(out, "loadModuleExp", indent); + } + types::ty *trans(coenv &) { em.compiler(getPos()); em << "trans called for loadModuleExp"; diff --git a/Build/source/utils/asymptote/doc/CAD.pdf b/Build/source/utils/asymptote/doc/CAD.pdf Binary files differindex ee2b6692e8f..4406335c391 100644 --- a/Build/source/utils/asymptote/doc/CAD.pdf +++ b/Build/source/utils/asymptote/doc/CAD.pdf diff --git a/Build/source/utils/asymptote/doc/FAQ/asy-faq.info b/Build/source/utils/asymptote/doc/FAQ/asy-faq.info index 32b8053f241..efd60036acc 100644 --- a/Build/source/utils/asymptote/doc/FAQ/asy-faq.info +++ b/Build/source/utils/asymptote/doc/FAQ/asy-faq.info @@ -9,7 +9,7 @@ END-INFO-DIR-ENTRY File: $prefix.info, Node: Top, Next: Question 1.1, Up: (dir) ASYMPTOTE FREQUENTLY ASKED QUESTIONS - 04 May 2010 + 06 Jun 2010 This is the list of Frequently Asked Questions about Asymptote (asy). diff --git a/Build/source/utils/asymptote/doc/asymptote.pdf b/Build/source/utils/asymptote/doc/asymptote.pdf Binary files differindex 699a02f61b2..0bd7a54892d 100644 --- a/Build/source/utils/asymptote/doc/asymptote.pdf +++ b/Build/source/utils/asymptote/doc/asymptote.pdf diff --git a/Build/source/utils/asymptote/doc/asymptote.texi b/Build/source/utils/asymptote/doc/asymptote.texi index 4a08d9c58ea..a25fae07653 100644 --- a/Build/source/utils/asymptote/doc/asymptote.texi +++ b/Build/source/utils/asymptote/doc/asymptote.texi @@ -3873,7 +3873,6 @@ as initializers, as in @code{real x=2*sin(pi/2);}. A variable is not added to the namespace until after the initializer is evaluated, so for example, in - @verbatim int x=2; int x=5*x; @@ -3911,7 +3910,6 @@ it a value. The default initializer for any type @code{T} can be redeclared by defining the function @code{T operator init()}. For instance, @code{int} variables are usually initialized to zero, but in - @verbatim int operator init() { return 3; @@ -3925,6 +3923,23 @@ illustrative purposes; redeclaring the initializers of built-in types is not recommended. Typically, @code{operator init} is used to define sensible defaults for user-defined types. +@cindex @code{var} +The special type @code{var} may be used to infer the type of a variable from +its initializer. If the initializer is an expression of a unique type, then +the variable will be defined with that type. For instance, +@verbatim +var x=5; +var y=4.3; +var reddash=red+dashed; +@end verbatim +@noindent +is equivalent to +@verbatim +int x=5; +real y=4.3; +pen reddash=red+dashed; +@end verbatim + @node Structures @section Structures @cindex @code{struct} @@ -3947,7 +3962,6 @@ structure. Any code at the top-level scope within the structure is executed on initialization. Variables hold references to structures. That is, in the example: - @verbatim struct T { int x; @@ -3967,7 +3981,6 @@ that @code{foo.x} will also be equal to @code{5}. The expression @code{new T} creates a new instance of the structure @code{T} and returns a reference to that instance. In creating the new instance, any code in the body of the record definition is executed. For example: - @verbatim int Tcount=0; struct T { @@ -4003,7 +4016,6 @@ initialized to a new instance (@code{new T}) by default. During the definition of the structure, however, variables of type @code{T} are initialized to @code{null} by default. This special behaviour is to avoid infinite recursion of creating new instances in code such as - @verbatim struct tree { int value; @@ -4013,7 +4025,6 @@ struct tree { @end verbatim Here is a simple example that illustrates the use of structures: - @verbatim struct S { real a=1; @@ -4038,7 +4049,6 @@ write((s+s).f(0)); // Outputs 2 @cindex constructors It is often convenient to have functions that construct new instances of a structure. Say we have a @code{Person} structure: - @verbatim struct Person { string firstname; @@ -4056,7 +4066,6 @@ creating a new person in real life, though). We can reduce the work by defining a constructor function @code{Person(string,string)}: - @verbatim struct Person { string firstname; @@ -4076,7 +4085,6 @@ Person joe=Person.Person("Joe", "Jones"); While it is now easier than before to create a new instance, we still have to refer to the constructor by the qualified name @code{Person.Person}. If we add the line - @verbatim from Person unravel Person; @end verbatim @@ -4109,7 +4117,6 @@ static Foo Foo(@var{args}) @{ This constructor is also implicitly copied to the enclosing scope after the end of the structure definition, so that it can used subsequently without qualifying it by the structure name. Our @code{Person} example can thus be implemented as: - @verbatim struct Person { string firstname; @@ -5116,11 +5123,10 @@ If @code{n} is negative, search backwards from the end of the array for the @cindex @code{search} @item int search(T[] a, T key) For built-in ordered types @code{T}, searches a sorted ordered array -@code{a} of @code{n} elements to find an interval containing -@code{key}, returning @code{-1} if @code{key} is less than the first -element, @code{n-1} if @code{key} is greater than or equal to the last -element, and otherwise the index corresponding to the left-hand -(smaller) endpoint. +@code{a} of @code{n} elements for k, returning the index @code{i} +if @code{a[i] <= key < a[i+1]}, @code{-1} if @code{key} is +less than all elements of @code{a}, or @code{n-1} if @code{key} is +greater than or equal to the last element of @code{a}. @cindex @code{copy} @item T[] copy(T[] a) @@ -5435,7 +5441,6 @@ Asymptote allows a section of an array to be addressed as a slice using a Python-like syntax. If @code{A} is an array, the expression @code{A[m:n]} returns a new array consisting of the elements of @code{A} with indices from @code{m} up to but not including @code{n}. For example, - @verbatim int[] x={0,1,2,3,4,5,6,7,8,9}; int[] y=x[2:6]; // y={2,3,4,5}; @@ -5446,7 +5451,6 @@ If the left index is omitted, it is taken be @code{0}. If the right index is omitted it is taken to be the length of the array. If both are omitted, the slice then goes from the start of the array to the end, producing a non-cyclic deep copy of the array. For example: - @verbatim int[] x={0,1,2,3,4,5,6,7,8,9}; int[] y=x[:4]; // y={0,1,2,3} @@ -5483,7 +5487,6 @@ Slices can also be assigned to, changing the value of the original array. If the array being assigned to the slice has a different length than the slice itself, elements will be inserted or removed from the array to accommodate it. For instance: - @verbatim string[] toppings={"mayo", "salt", "ham", "lettuce"}; toppings[0:2]=new string[] {"mustard", "pepper"}; @@ -5536,7 +5539,6 @@ trying to match function calls with possible function signatures. Implicit casting can be inhibited by declaring individual arguments @code{explicit} in the function signature, say to avoid an ambiguous function call in the following example, which outputs 0: - @verbatim int f(pair a) {return 0;} int f(explicit real x) {return 1;} @@ -5621,7 +5623,6 @@ adds the @code{axes} field of @code{graph} into the local name space, so that subsequently, one can just write @code{axes()}. If the given name is overloaded, all types and variables of that name are added. To add more than one name, just use a comma-separated list: - @verbatim from graph access axes, xaxis, yaxis; @end verbatim @@ -5636,7 +5637,6 @@ from graph access *; @cindex @code{unravel} Similarly, one can add the non-private fields and types of a structure to the local environment with the @code{unravel} keyword: - @verbatim struct matrix { real a,b,c,d; @@ -5685,7 +5685,6 @@ have the same name as local functions defined later. @cindex @code{as} To rename modules or fields when adding them to the local environment, use @code{as}: - @verbatim access graph as graph2d; from graph access xaxis as xline, yaxis as yline; @@ -5863,7 +5862,6 @@ is an ugly implementation of exponentiation. Loop constructs allocate a new frame in every iteration. This is so that higher-order functions can refer to variables of a specific iteration of a loop: - @verbatim void f(); for(int i=0; i < 10; ++i) { @@ -5879,7 +5877,6 @@ Here, every iteration of the loop has its own variable @code{x}, so @code{f()} will write @code{5}. If a variable in a loop is declared static, it will be allocated where the enclosing function or structure was defined (just as if it were declared static outside of the loop). For instance, in: - @verbatim void f() { static int x; @@ -5943,7 +5940,6 @@ latex latexusage @noindent or - @verbatim pdflatex latexusage asy latexusage @@ -6146,6 +6142,18 @@ returns, if @code{strict=false}, whether @code{i > j} implies @code{a[i] >= a[j]}, or if @code{strict=true}, whether @code{i > j} implies implies @code{a[i] > a[j]}. +@cindex @code{unique} +@item int unique(real[] a, real x) +if the sorted array @code{a} does not contain @code{x}, insert it +sequentially, returning the index of @code{x} in the resulting array. + +@cindex @code{lexorder} +@item bool lexorder(pair a, pair b) +returns the lexicographical partial order of @code{a} and @code{b}. + +@cindex @code{lexorder} +@item bool lexorder(triple a, triple b) +returns the lexicographical partial order of @code{a} and @code{b}. @end table @node interpolate @@ -7519,6 +7527,8 @@ path path(path3 p, pair P(triple)=xypart); @end verbatim @cindex @code{surface} +@cindex @code{render} +@cindex @code{defaultrender} A Bezier surface, the natural two-dimensional generalization of Bezier curves, is defined in @code{three_surface.asy} as a structure containing an array of Bezier patches. Surfaces may drawn with one of @@ -7526,13 +7536,17 @@ the routines @verbatim void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material surfacepen=currentpen, pen meshpen=nullpen, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen meshpen, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen[] meshpen=nullpens, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); + @end verbatim The parameters @code{nu} and @code{nv} specify the number of subdivisions for drawing optional mesh lines for each Bezier patch. The optional @@ -7544,7 +7558,6 @@ struct material { pen[] p; // diffusepen,ambientpen,emissivepen,specularpen real opacity; real shininess; - real granularity; ... } @end verbatim @@ -7552,7 +7565,9 @@ struct material { These material properties are used to implement @code{OpenGL}-style lighting, based on the Phong-Blinn specular model. Sample Bezier surfaces are contained in the example files @code{BezierSurface.asy}, @code{teapot.asy}, -and @code{parametricsurface.asy}. +and @code{parametricsurface.asy}. The structure @code{render} contains +specialized rendering options documented at the beginning of module +@code{three.asy}. @cindex patch-dependent colors @cindex vertex-dependent colors @@ -7609,7 +7624,7 @@ Arbitrary thick three-dimensional curves and line caps (which the @code{OpenGL} standard does not require implementations to provide) are constructed with @verbatim -tube tube(path3 p, real width, real granularity=tubegranularity); +tube tube(path3 p, real width, render render=defaultrender); @end verbatim @noindent this returns a tube structure representing a tube of diameter @code{width} @@ -8054,8 +8069,8 @@ When not multiplied on the left by a transform3, three-dimensional @verbatim void label(picture pic=currentpicture, Label L, triple position, align align=NoAlign, pen p=currentpen, - light light=nolight, string name=L.s, - interaction interaction= + light light=nolight, string name="", + render render=defaultrender, interaction interaction= settings.autobillboard ? Billboard : Embedded) @end verbatim @noindent @@ -8064,7 +8079,7 @@ void label(picture pic=currentpicture, Label L, triple position, The optional @code{name} parameter is used as a prefix for naming the label patches in the @acronym{PRC} model tree. The default interaction is @code{Billboard}, which means that labels -are rotated interactively so that they always lie on the projection plane. +are rotated interactively so that they always face the camera. The interaction @code{Embedded} means that the label interacts as a normal @code{3D} surface, as illustrated in the example @code{billboard.asy}. @cindex @code{transform} @@ -9137,11 +9152,11 @@ this requires @code{Python 2.6.2} and the @code{Python Imaging Library}: @url{http://www.python.org/ftp/python/2.6.2/python-2.6.2.msi} @end quotation @quotation -@url{http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.6.exe}. +@url{http://effbot.org/downloads/PIL-1.1.7.win32-py2.6.exe}. @end quotation @noindent On @code{UNIX} systems, place -@url{http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz} in the +@url{http://effbot.org/downloads/Imaging-1.1.7.tar.gz} in the @code{Asymptote} source directory, and type (as the root user): @verbatim tar -zxf Imaging-1.1.7.tar.gz @@ -9525,8 +9540,9 @@ Melenchuk, Martin Wiebusch, and Stefan Knorr. @c LocalWords: usplinetype vsplinetype leftbutton middlebutton rightbutton @c LocalWords: rotateY rotateZ wheelup zoomin wheeldown zoomout TeXLive @c LocalWords: viewportshift signedint signedness psview multiplatform nowarn -@c LocalWords: singlereal singleint writeoverloaded tubegranularity dvisvg +@c LocalWords: singlereal singleint writeoverloaded dvisvg reddash lexorder @c LocalWords: bigdiagonal autobillboard dvisvgm maxtiles hyperrefOptions @c LocalWords: setpagesize pdfborder controlsystem OmitTickInterval SixViews @c LocalWords: OmitTickIntervals tickmodifiers autorotated SixViewsUS @c LocalWords: ThreeViewsUS ThreeViewsFR SixViewsFR ThreeViews partialsum +@c LocalWords: defaultrender diff --git a/Build/source/utils/asymptote/doc/cube.asy b/Build/source/utils/asymptote/doc/cube.asy index 436e1e2729f..acfecfdd7d4 100644 --- a/Build/source/utils/asymptote/doc/cube.asy +++ b/Build/source/utils/asymptote/doc/cube.asy @@ -1,5 +1,4 @@ import three; -dotgranularity=0; // Render dots as spheres. currentprojection=orthographic(5,4,2,center=true); diff --git a/Build/source/utils/asymptote/doc/join3.asy b/Build/source/utils/asymptote/doc/join3.asy index 62d5faaaee6..9513d522b4d 100644 --- a/Build/source/utils/asymptote/doc/join3.asy +++ b/Build/source/utils/asymptote/doc/join3.asy @@ -15,10 +15,7 @@ path3 p=z[0]..z[1]---z[2]::{Y}z[3] &z[3]..z[4]--z[5]::{Y}z[6] &z[6]::z[7]---z[8]..{Y}z[9]; -draw(p,grey+linewidth(4mm)+opacity(0.5)); +draw(p,grey+linewidth(4mm),currentlight); xaxis3(Label(XY()*"$x$",align=-3Y),red,above=true); yaxis3(Label(XY()*"$y$",align=-3X),red,above=true); - -dot(z); - diff --git a/Build/source/utils/asymptote/doc/latexusage.tex b/Build/source/utils/asymptote/doc/latexusage.tex index f073f80258f..bc0638098c2 100644 --- a/Build/source/utils/asymptote/doc/latexusage.tex +++ b/Build/source/utils/asymptote/doc/latexusage.tex @@ -7,7 +7,7 @@ %\usepackage[inline]{asymptote} % Enable this line to support PDF hyperlinks: -%\usepackage[setpagesize=false]{hyperref} +%\usepackage{hyperref}\hypersetup{setpagesize=false} % Enable this line for PDF attachments with asy environment option attach=true: %\usepackage[dvips]{attachfile2} @@ -81,6 +81,7 @@ the \verb+{attach=true}+ option: \begin{center} \begin{asy}[height=4cm,attach=false] import three; +defaultrender.margin=3pt; currentprojection=orthographic(5,4,2); draw(unitcube,blue); label("$V-E+F=2$",(0,1,0.5),3Y,blue+fontsize(17pt)); diff --git a/Build/source/utils/asymptote/doc/png/asymptote.info b/Build/source/utils/asymptote/doc/png/asymptote.info index aa24a4f977a..b8497480d4c 100644 --- a/Build/source/utils/asymptote/doc/png/asymptote.info +++ b/Build/source/utils/asymptote/doc/png/asymptote.info @@ -1,7 +1,7 @@ This is asymptote.info, produced by makeinfo version 4.13 from ../asymptote.texi. -This file documents `Asymptote', version 1.94. +This file documents `Asymptote', version 1.96. `http://asymptote.sourceforge.net' @@ -23,7 +23,7 @@ File: asymptote.info, Node: Top, Next: Description, Up: (dir) Asymptote ********* -This file documents `Asymptote', version 1.94. +This file documents `Asymptote', version 1.96. `http://asymptote.sourceforge.net' @@ -793,7 +793,6 @@ the module `three.asy' to construct the edges of a cube `unitbox' without retracing steps (*note three::): import three; -dotgranularity=0; // Render dots as spheres. currentprojection=orthographic(5,4,2,center=true); @@ -3023,7 +3022,6 @@ initializers, as in `real x=2*sin(pi/2);'. A variable is not added to the namespace until after the initializer is evaluated, so for example, in - int x=2; int x=5*x; the `x' in the initializer on the second line refers to the variable @@ -3064,7 +3062,6 @@ giving it a value. The default initializer for any type `T' can be redeclared by defining the function `T operator init()'. For instance, `int' variables are usually initialized to zero, but in - int operator init() { return 3; } @@ -3075,6 +3072,17 @@ illustrative purposes; redeclaring the initializers of built-in types is not recommended. Typically, `operator init' is used to define sensible defaults for user-defined types. + The special type `var' may be used to infer the type of a variable +from its initializer. If the initializer is an expression of a unique +type, then the variable will be defined with that type. For instance, +var x=5; +var y=4.3; +var reddash=red+dashed; + is equivalent to +int x=5; +real y=4.3; +pen reddash=red+dashed; + File: asymptote.info, Node: Structures, Next: Operators, Prev: Variable initializers, Up: Programming @@ -3092,7 +3100,6 @@ structure. Any code at the top-level scope within the structure is executed on initialization. Variables hold references to structures. That is, in the example: - struct T { int x; } @@ -3111,7 +3118,6 @@ will also be equal to `5'. and returns a reference to that instance. In creating the new instance, any code in the body of the record definition is executed. For example: - int Tcount=0; struct T { int x; @@ -3143,7 +3149,6 @@ initialized to a new instance (`new T') by default. During the definition of the structure, however, variables of type `T' are initialized to `null' by default. This special behaviour is to avoid infinite recursion of creating new instances in code such as - struct tree { int value; tree left; @@ -3151,7 +3156,6 @@ struct tree { } Here is a simple example that illustrates the use of structures: - struct S { real a=1; real f(real a) {return a+this.a;} @@ -3172,7 +3176,6 @@ write((s+s).f(0)); // Outputs 2 It is often convenient to have functions that construct new instances of a structure. Say we have a `Person' structure: - struct Person { string firstname; string lastname; @@ -3187,7 +3190,6 @@ effort than creating a new person in real life, though). We can reduce the work by defining a constructor function `Person(string,string)': - struct Person { string firstname; string lastname; @@ -3205,7 +3207,6 @@ Person joe=Person.Person("Joe", "Jones"); While it is now easier than before to create a new instance, we still have to refer to the constructor by the qualified name `Person.Person'. If we add the line - from Person unravel Person; immediately after the structure definition, then the constructor can be used without qualification: `Person joe=Person("Joe", "Jones");'. @@ -3233,7 +3234,6 @@ structure. That is, it essentially defines the following constructor after the end of the structure definition, so that it can used subsequently without qualifying it by the structure name. Our `Person' example can thus be implemented as: - struct Person { string firstname; string lastname; @@ -3998,10 +3998,9 @@ of type `T[]'. `int search(T[] a, T key)' For built-in ordered types `T', searches a sorted ordered array - `a' of `n' elements to find an interval containing `key', - returning `-1' if `key' is less than the first element, `n-1' if - `key' is greater than or equal to the last element, and otherwise - the index corresponding to the left-hand (smaller) endpoint. + `a' of `n' elements for k, returning the index `i' if `a[i] <= key + < a[i+1]', `-1' if `key' is less than all elements of `a', or + `n-1' if `key' is greater than or equal to the last element of `a'. `T[] copy(T[] a)' returns a copy of the array `a'; @@ -4243,7 +4242,6 @@ Asymptote allows a section of an array to be addressed as a slice using a Python-like syntax. If `A' is an array, the expression `A[m:n]' returns a new array consisting of the elements of `A' with indices from `m' up to but not including `n'. For example, - int[] x={0,1,2,3,4,5,6,7,8,9}; int[] y=x[2:6]; // y={2,3,4,5}; int[] z=x[5:10]; // z={5,6,7,8,9}; @@ -4252,7 +4250,6 @@ int[] z=x[5:10]; // z={5,6,7,8,9}; index is omitted it is taken to be the length of the array. If both are omitted, the slice then goes from the start of the array to the end, producing a non-cyclic deep copy of the array. For example: - int[] x={0,1,2,3,4,5,6,7,8,9}; int[] y=x[:4]; // y={0,1,2,3} int[] z=x[5:]; // z={5,6,7,8,9} @@ -4287,7 +4284,6 @@ will yield an error. array. If the array being assigned to the slice has a different length than the slice itself, elements will be inserted or removed from the array to accommodate it. For instance: - string[] toppings={"mayo", "salt", "ham", "lettuce"}; toppings[0:2]=new string[] {"mustard", "pepper"}; // Now toppings={"mustard", "pepper", "ham", "lettuce"} @@ -4337,7 +4333,6 @@ function calls with possible function signatures. Implicit casting can be inhibited by declaring individual arguments `explicit' in the function signature, say to avoid an ambiguous function call in the following example, which outputs 0: - int f(pair a) {return 0;} int f(explicit real x) {return 1;} @@ -4405,7 +4400,6 @@ from graph access axes; subsequently, one can just write `axes()'. If the given name is overloaded, all types and variables of that name are added. To add more than one name, just use a comma-separated list: - from graph access axes, xaxis, yaxis; Wild card notation can be used to add all non-private fields and types of a module to the local name space: @@ -4414,7 +4408,6 @@ from graph access *; Similarly, one can add the non-private fields and types of a structure to the local environment with the `unravel' keyword: - struct matrix { real a,b,c,d; } @@ -4453,7 +4446,6 @@ same name as local functions defined later. To rename modules or fields when adding them to the local environment, use `as': - access graph as graph2d; from graph access xaxis as xline, yaxis as yline; @@ -4590,7 +4582,6 @@ implementation of exponentiation. Loop constructs allocate a new frame in every iteration. This is so that higher-order functions can refer to variables of a specific iteration of a loop: - void f(); for(int i=0; i < 10; ++i) { int x=i; @@ -4604,7 +4595,6 @@ f(); will write `5'. If a variable in a loop is declared static, it will be allocated where the enclosing function or structure was defined (just as if it were declared static outside of the loop). For instance, in: - void f() { static int x; for(int i=0; i < 10; ++i) { @@ -4659,7 +4649,6 @@ asy latexusage latex latexusage or - pdflatex latexusage asy latexusage pdflatex latexusage @@ -4706,7 +4695,7 @@ and `LaTeX' is available at `http://dario.dse.nl/projects/asylatex/'. %\usepackage[inline]{asymptote} % Enable this line to support PDF hyperlinks: -%\usepackage[setpagesize=false]{hyperref} +%\usepackage{hyperref}\hypersetup{setpagesize=false} % Enable this line for PDF attachments with asy environment option attach=true: %\usepackage[dvips]{attachfile2} @@ -4780,6 +4769,7 @@ the \verb+{attach=true}+ option: \begin{center} \begin{asy}[height=4cm,attach=false] import three; +defaultrender.margin=3pt; currentprojection=orthographic(5,4,2); draw(unitcube,blue); label("$V-E+F=2$",(0,1,0.5),3Y,blue+fontsize(17pt)); @@ -4952,6 +4942,15 @@ useful functions such as a[j]', or if `strict=true', whether `i > j' implies implies `a[i] > a[j]'. +`int unique(real[] a, real x)' + if the sorted array `a' does not contain `x', insert it + sequentially, returning the index of `x' in the resulting array. + +`bool lexorder(pair a, pair b)' + returns the lexicographical partial order of `a' and `b'. + +`bool lexorder(triple a, triple b)' + returns the lexicographical partial order of `a' and `b'. File: asymptote.info, Node: interpolate, Next: geometry, Prev: math, Up: Base modules @@ -6591,13 +6590,17 @@ containing an array of Bezier patches. Surfaces may drawn with one of the routines void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material surfacepen=currentpen, pen meshpen=nullpen, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen meshpen, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen[] meshpen=nullpens, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); + The parameters `nu' and `nv' specify the number of subdivisions for drawing optional mesh lines for each Bezier patch. The optional `name' parameter is used as a prefix for naming the surface patches in the PRC @@ -6606,13 +6609,14 @@ struct material { pen[] p; // diffusepen,ambientpen,emissivepen,specularpen real opacity; real shininess; - real granularity; ... } These material properties are used to implement `OpenGL'-style lighting, based on the Phong-Blinn specular model. Sample Bezier surfaces are contained in the example files `BezierSurface.asy', -`teapot.asy', and `parametricsurface.asy'. +`teapot.asy', and `parametricsurface.asy'. The structure `render' +contains specialized rendering options documented at the beginning of +module `three.asy'. The examples `elevation.asy' and `sphericalharmonic.asy' illustrate how to draw a surface with patch-dependent colors. The examples @@ -6646,7 +6650,7 @@ bounded by cyclic paths of length `4' or less. Arbitrary thick three-dimensional curves and line caps (which the `OpenGL' standard does not require implementations to provide) are constructed with -tube tube(path3 p, real width, real granularity=tubegranularity); +tube tube(path3 p, real width, render render=defaultrender); this returns a tube structure representing a tube of diameter `width' centered approximately on `g'. The tube structure consists of a surface `s' and the actual tube center, path3 `center'. Drawing thick lines as @@ -7002,14 +7006,14 @@ TeX Labels are drawn as Bezier surfaces directly on the projection plane: void label(picture pic=currentpicture, Label L, triple position, align align=NoAlign, pen p=currentpen, - light light=nolight, string name=L.s, - interaction interaction= + light light=nolight, string name="", + render render=defaultrender, interaction interaction= settings.autobillboard ? Billboard : Embedded) The optional `name' parameter is used as a prefix for naming the label patches in the PRC model tree. The default interaction is `Billboard', which means that labels are rotated interactively so that they always -lie on the projection plane. The interaction `Embedded' means that the -label interacts as a normal `3D' surface, as illustrated in the example +face the camera. The interaction `Embedded' means that the label +interacts as a normal `3D' surface, as illustrated in the example `billboard.asy'. Alternatively, a label can be transformed from the `XY' plane by an explicit transform3 or mapped to a specified two-dimensional plane with the predefined transform3 types `XY', `YZ', @@ -7069,13 +7073,11 @@ path3 p=z[0]..z[1]---z[2]::{Y}z[3] &z[3]..z[4]--z[5]::{Y}z[6] &z[6]::z[7]---z[8]..{Y}z[9]; -draw(p,grey+linewidth(4mm)+opacity(0.5)); +draw(p,grey+linewidth(4mm),currentlight); xaxis3(Label(XY()*"$x$",align=-3Y),red,above=true); yaxis3(Label(XY()*"$y$",align=-3X),red,above=true); -dot(z); - Three-dimensional versions of bars or arrows can be drawn with one of @@ -8154,10 +8156,10 @@ requires `Python 2.6.2' and the `Python Imaging Library': `http://www.python.org/ftp/python/2.6.2/python-2.6.2.msi' - `http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.6.exe'. + `http://effbot.org/downloads/PIL-1.1.7.win32-py2.6.exe'. On `UNIX' systems, place -`http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz' in the -`Asymptote' source directory, and type (as the root user): +`http://effbot.org/downloads/Imaging-1.1.7.tar.gz' in the `Asymptote' +source directory, and type (as the root user): tar -zxf Imaging-1.1.7.tar.gz cd Imaging-1.1.7 python setup.py install @@ -8345,7 +8347,7 @@ Index (line 68) * != <1>: Arithmetic & logical. (line 38) -* !=: Structures. (line 54) +* !=: Structures. (line 52) * % <1>: Interactive mode. (line 17) * %: Arithmetic & logical. (line 23) @@ -8392,7 +8394,7 @@ Index * 2D graphs: graph. (line 6) * 3D graphs: graph3. (line 6) * 3D grids: grid3. (line 6) -* 3D PostScript: three. (line 567) +* 3D PostScript: three. (line 570) * 3D rendering: Compiling from UNIX source. (line 16) * :: Arithmetic & logical. @@ -8404,7 +8406,7 @@ Index (line 44) * == <1>: Arithmetic & logical. (line 37) -* ==: Structures. (line 54) +* ==: Structures. (line 52) * >: Arithmetic & logical. (line 50) * >=: Arithmetic & logical. @@ -8421,7 +8423,7 @@ Index * abs <1>: Mathematical functions. (line 35) * abs: Data types. (line 60) -* accel <1>: three. (line 497) +* accel <1>: three. (line 502) * accel: Paths and guides. (line 115) * access: Import. (line 6) * acknowledgments: Credits. (line 6) @@ -8431,9 +8433,9 @@ Index (line 6) * acosh: Mathematical functions. (line 6) -* add <1>: three. (line 266) +* add <1>: three. (line 271) * add: Frames and pictures. (line 196) -* addViews: three. (line 383) +* addViews: three. (line 388) * adjust: Pens. (line 115) * Ai: Mathematical functions. (line 48) @@ -8441,11 +8443,11 @@ Index (line 48) * Airy: Mathematical functions. (line 48) -* alias <1>: Arrays. (line 184) -* alias: Structures. (line 54) +* alias <1>: Arrays. (line 183) +* alias: Structures. (line 52) * align: Options. (line 166) * Align: label. (line 12) -* all: Arrays. (line 332) +* all: Arrays. (line 331) * Allow: Pens. (line 327) * AND: Arithmetic & logical. (line 80) @@ -8457,21 +8459,21 @@ Index * animation: animation. (line 6) * annotate: annotate. (line 6) * antialias <1>: Options. (line 141) -* antialias: three. (line 205) +* antialias: three. (line 210) * antialiasing: Compiling from UNIX source. (line 16) * append <1>: Arrays. (line 39) * append: Files. (line 35) -* arc: three. (line 278) +* arc: three. (line 283) * Arc: Paths and guides. (line 32) * arc: Paths and guides. (line 22) * ArcArrow: draw. (line 26) -* ArcArrow3: three. (line 540) +* ArcArrow3: three. (line 543) * ArcArrows: draw. (line 26) -* ArcArrows3: three. (line 540) -* arclength <1>: three. (line 497) +* ArcArrows3: three. (line 543) +* arclength <1>: three. (line 502) * arclength: Paths and guides. (line 142) -* arctime <1>: three. (line 497) +* arctime <1>: three. (line 502) * arctime: Paths and guides. (line 146) * arguments: Default arguments. (line 6) * arithmetic operators: Arithmetic & logical. @@ -8483,11 +8485,11 @@ Index * Arrow: draw. (line 26) * arrow: Drawing commands. (line 31) * arrow keys: Tutorial. (line 35) -* Arrow3: three. (line 540) +* Arrow3: three. (line 543) * Arrows: draw. (line 26) * arrows: draw. (line 26) -* Arrows3: three. (line 540) -* as: Import. (line 70) +* Arrows3: three. (line 543) +* as: Import. (line 68) * aSin: Mathematical functions. (line 20) * asin: Mathematical functions. @@ -8497,7 +8499,7 @@ Index * Aspect: Frames and pictures. (line 54) * assert: Data types. (line 327) * assignment: Programming. (line 8) -* asy: Import. (line 105) +* asy: Import. (line 102) * asy-mode: Editing modes. (line 6) * asy.vim: Editing modes. (line 33) * asymptote.sty: LaTeX usage. (line 6) @@ -8513,8 +8515,8 @@ Index (line 6) * atleast: Bezier curves. (line 56) * attach <1>: graph. (line 415) -* attach: LaTeX usage. (line 32) -* autoadjust: three. (line 349) +* attach: LaTeX usage. (line 31) +* autoadjust: three. (line 354) * autoimport: Options. (line 109) * automatic scaling: graph. (line 682) * axialshade: fill. (line 43) @@ -8523,11 +8525,11 @@ Index * azimuth: Data types. (line 124) * babel: babel. (line 6) * background color: Frames and pictures. (line 168) -* BackView: three. (line 376) +* BackView: three. (line 381) * Bar: draw. (line 19) -* Bar3: three. (line 540) +* Bar3: three. (line 543) * Bars: draw. (line 19) -* Bars3: three. (line 540) +* Bars3: three. (line 543) * barsize: draw. (line 19) * base modules: Base modules. (line 6) * basealign: Pens. (line 168) @@ -8535,36 +8537,36 @@ Index * batch mode: Tutorial. (line 6) * beep: Data types. (line 340) * BeginArcArrow: draw. (line 26) -* BeginArcArrow3: three. (line 540) +* BeginArcArrow3: three. (line 543) * BeginArrow: draw. (line 26) -* BeginArrow3: three. (line 540) +* BeginArrow3: three. (line 543) * BeginBar: draw. (line 19) -* BeginBar3: three. (line 540) +* BeginBar3: three. (line 543) * BeginDotMargin: draw. (line 42) -* BeginDotMargin3: three. (line 556) +* BeginDotMargin3: three. (line 559) * BeginMargin: draw. (line 42) -* BeginMargin3: three. (line 556) +* BeginMargin3: three. (line 559) * BeginPenMargin: draw. (line 42) -* BeginPenMargin2: three. (line 556) -* BeginPenMargin3: three. (line 556) +* BeginPenMargin2: three. (line 559) +* BeginPenMargin3: three. (line 559) * BeginPoint: label. (line 57) * Bessel: Mathematical functions. (line 48) * bevel: flowchart. (line 75) * beveljoin: Pens. (line 138) * Bezier curves: Bezier curves. (line 6) -* bezulate: three. (line 99) +* bezulate: three. (line 104) * Bi: Mathematical functions. (line 48) * Bi_deriv: Mathematical functions. (line 48) -* Billboard: three. (line 467) +* Billboard: three. (line 472) * binary format: Files. (line 70) * binary operators: Arithmetic & logical. (line 6) * binarytree: binarytree. (line 6) * binput: Files. (line 70) -* black stripes: three. (line 205) +* black stripes: three. (line 210) * Blank: draw. (line 26) * block.bottom: flowchart. (line 19) * block.bottomleft: flowchart. (line 19) @@ -8583,11 +8585,11 @@ Index (line 6) * Bottom: graph. (line 134) * BottomTop: graph. (line 140) -* BottomView: three. (line 376) +* BottomView: three. (line 381) * bounding box: Frames and pictures. (line 168) * Bounds: graph3. (line 20) * boutput: Files. (line 70) -* box <1>: three. (line 300) +* box <1>: three. (line 305) * box: Frames and pictures. (line 22) * bp: Tutorial. (line 24) * break: Programming. (line 29) @@ -8609,7 +8611,7 @@ Index * cd: Files. (line 24) * ceil: Mathematical functions. (line 26) -* center: three. (line 333) +* center: three. (line 338) * Center: label. (line 62) * checker: Pens. (line 251) * Chinese: unicode. (line 12) @@ -8618,7 +8620,7 @@ Index * Ci: Mathematical functions. (line 48) * circle <1>: flowchart. (line 64) -* circle: three. (line 274) +* circle: three. (line 279) * Circle: Paths and guides. (line 17) * circle: Paths and guides. (line 10) * circlebarframe: markers. (line 18) @@ -8639,7 +8641,7 @@ Index * colorless: Pens. (line 54) * colors: Pens. (line 51) * comma: Files. (line 58) -* comma-separated-value mode: Arrays. (line 365) +* comma-separated-value mode: Arrays. (line 364) * command-line options <1>: Options. (line 6) * command-line options: Configuring. (line 83) * comment character: Files. (line 15) @@ -8647,7 +8649,7 @@ Index * Compiling from UNIX source: Compiling from UNIX source. (line 6) * complement: Arrays. (line 150) -* concat: Arrays. (line 180) +* concat: Arrays. (line 179) * conditional <1>: Arithmetic & logical. (line 73) * conditional: Programming. (line 8) @@ -8656,7 +8658,7 @@ Index * configuration file: Configuring. (line 23) * configuring: Configuring. (line 6) * conj: Data types. (line 57) -* constructors: Structures. (line 95) +* constructors: Structures. (line 91) * context: Options. (line 141) * continue <1>: Debugger. (line 31) * continue: Programming. (line 29) @@ -8671,29 +8673,29 @@ Index * convert: Configuring. (line 67) * convertOptions: Options. (line 128) * Coons shading: fill. (line 74) -* copy: Arrays. (line 171) +* copy: Arrays. (line 170) * Cos: Mathematical functions. (line 20) * cos: Mathematical functions. (line 6) * cosh: Mathematical functions. (line 6) -* cputime: Structures. (line 177) +* cputime: Structures. (line 169) * crop: graph. (line 636) * cropping graphs: graph. (line 636) * cross <1>: graph. (line 484) * cross: Data types. (line 167) * crossframe: markers. (line 23) * crosshatch: Pens. (line 267) -* csv: Arrays. (line 365) +* csv: Arrays. (line 364) * CTZ: Arithmetic & logical. (line 80) -* cubicroots: Arrays. (line 321) +* cubicroots: Arrays. (line 320) * curl <1>: three. (line 6) * curl: Bezier curves. (line 63) * curlSpecifier: Paths and guides. (line 391) * currentpen: Pens. (line 6) -* currentprojection: three. (line 373) +* currentprojection: three. (line 378) * curve: slopefield. (line 20) * custom axis types: graph. (line 144) * custom mark routine: graph. (line 576) @@ -8701,7 +8703,7 @@ Index * cut: Paths and guides. (line 237) * cycle <1>: three. (line 6) * cycle: Tutorial. (line 73) -* cyclic <1>: three. (line 497) +* cyclic <1>: three. (line 502) * cyclic <2>: Arrays. (line 39) * cyclic: Paths and guides. (line 74) * Cyrillic: unicode. (line 7) @@ -8717,8 +8719,9 @@ Index * default arguments: Default arguments. (line 6) * defaultformat: graph. (line 175) * DefaultHead: draw. (line 26) -* DefaultHead3: three. (line 540) +* DefaultHead3: three. (line 543) * defaultpen: Pens. (line 46) +* defaultrender: three. (line 47) * deferred drawing: simplex. (line 6) * Degrees: Mathematical functions. (line 17) @@ -8728,10 +8731,10 @@ Index * delete <1>: Arrays. (line 39) * delete: Files. (line 145) * description: Description. (line 6) -* diagonal: Arrays. (line 306) +* diagonal: Arrays. (line 305) * diamond: flowchart. (line 57) -* dimension: Arrays. (line 370) -* dir <1>: three. (line 497) +* dimension: Arrays. (line 369) +* dir <1>: three. (line 502) * dir <2>: Paths and guides. (line 98) * dir <3>: Data types. (line 85) * dir: Search paths. (line 10) @@ -8741,15 +8744,15 @@ Index * dirtime: Paths and guides. (line 152) * display: Configuring. (line 67) * do: Programming. (line 29) -* dot <1>: Arrays. (line 262) +* dot <1>: Arrays. (line 261) * dot <2>: Data types. (line 98) * dot: draw. (line 83) * DotMargin: draw. (line 42) -* DotMargin3: three. (line 556) +* DotMargin3: three. (line 559) * DotMargins: draw. (line 42) -* DotMargins3: three. (line 556) +* DotMargins3: three. (line 559) * dotted: Pens. (line 95) -* double deferred drawing: three. (line 251) +* double deferred drawing: three. (line 256) * double precision: Files. (line 70) * Draw: Frames and pictures. (line 147) * draw: draw. (line 110) @@ -8774,28 +8777,28 @@ Index * else: Programming. (line 8) * emacs: Editing modes. (line 6) * embed: embed. (line 6) -* Embedded: three. (line 467) +* Embedded: three. (line 472) * empty: Frames and pictures. (line 7) * EndArcArrow: draw. (line 26) -* EndArcArrow3: three. (line 540) +* EndArcArrow3: three. (line 543) * EndArrow: draw. (line 26) -* EndArrow3: three. (line 540) +* EndArrow3: three. (line 543) * EndBar: draw. (line 19) -* EndBar3: three. (line 540) +* EndBar3: three. (line 543) * EndDotMargin: draw. (line 42) -* EndDotMargin3: three. (line 556) +* EndDotMargin3: three. (line 559) * endl: Files. (line 58) * EndMargin: draw. (line 42) -* EndMargin3: three. (line 556) +* EndMargin3: three. (line 559) * EndPenMargin: draw. (line 42) -* EndPenMargin2: three. (line 556) -* EndPenMargin3: three. (line 556) +* EndPenMargin2: three. (line 559) +* EndPenMargin3: three. (line 559) * EndPoint: label. (line 57) * envelope: Frames and pictures. (line 22) * environment variables: Configuring. (line 87) -* eof <1>: Arrays. (line 347) +* eof <1>: Arrays. (line 346) * eof: Files. (line 88) -* eol <1>: Arrays. (line 347) +* eol <1>: Arrays. (line 346) * eol: Files. (line 88) * EPS <1>: Options. (line 141) * EPS: label. (line 80) @@ -8809,7 +8812,7 @@ Index * error: Files. (line 15) * error bars: graph. (line 532) * errorbars: graph. (line 484) -* eval: Import. (line 101) +* eval: Import. (line 98) * evenodd <1>: Pens. (line 152) * evenodd: Tutorial. (line 146) * exit <1>: Debugger. (line 57) @@ -8819,7 +8822,7 @@ Index (line 6) * expi: Data types. (line 81) * explicit: Casts. (line 6) -* explicit casts: Casts. (line 22) +* explicit casts: Casts. (line 21) * expm1: Mathematical functions. (line 6) * exponential integral: Mathematical functions. @@ -8828,19 +8831,19 @@ Index * extension <1>: MetaPost. (line 10) * extension: Paths and guides. (line 232) * external: embed. (line 28) -* extrude: three. (line 491) +* extrude: three. (line 496) * F: Mathematical functions. (line 48) * fabs: Mathematical functions. (line 6) -* face: three. (line 575) +* face: three. (line 578) * factorial: Mathematical functions. (line 39) * Fedora: UNIX binary distributions. (line 15) * feynman: feynman. (line 6) * fft <1>: math. (line 26) -* fft: Arrays. (line 249) +* fft: Arrays. (line 248) * FFTW: Compiling from UNIX source. (line 58) * file <1>: Debugger. (line 45) @@ -8858,7 +8861,7 @@ Index * find: Data types. (line 224) * firstcut: Paths and guides. (line 247) * fit: Frames and pictures. (line 103) -* fit3: three. (line 264) +* fit3: three. (line 269) * fix-cm: Pens. (line 178) * fixedscaling: Frames and pictures. (line 74) * floor: Mathematical functions. @@ -8879,7 +8882,7 @@ Index * freeglut: Compiling from UNIX source. (line 16) * from: Import. (line 17) -* FrontView: three. (line 376) +* FrontView: three. (line 381) * function declarations: Functions. (line 67) * function shading: fill. (line 96) * Function shading: fill. (line 96) @@ -8898,7 +8901,7 @@ Index * getstring: Files. (line 113) * gettriple: Files. (line 113) * glOptions <1>: Options. (line 128) -* glOptions: three. (line 205) +* glOptions: three. (line 210) * GNU Scientific Library: Mathematical functions. (line 48) * gouraudshade: fill. (line 58) @@ -8926,7 +8929,7 @@ Index * guide: Paths and guides. (line 300) * guide3: three. (line 6) * hatch: Pens. (line 267) -* height: LaTeX usage. (line 32) +* height: LaTeX usage. (line 31) * help <1>: Debugger. (line 30) * help <2>: Help. (line 6) * help: Interactive mode. (line 44) @@ -8936,14 +8939,14 @@ Index * hex: Data types. (line 280) * hexidecimal <1>: Pens. (line 59) * hexidecimal: Data types. (line 280) -* hidden surface removal: three. (line 575) +* hidden surface removal: three. (line 578) * histogram: Mathematical functions. (line 39) * history <1>: Interactive mode. (line 59) * history: Files. (line 138) * historylines: Interactive mode. (line 64) * HookHead: draw. (line 26) -* HookHead3: three. (line 540) +* HookHead3: three. (line 543) * Horizontal: flowchart. (line 81) * hyperrefOptions: Options. (line 128) * hypot: Mathematical functions. @@ -8952,12 +8955,12 @@ Index (line 48) * i_scaled: Mathematical functions. (line 48) -* iconic: three. (line 205) -* identity <1>: Arrays. (line 303) +* iconic: three. (line 210) +* identity <1>: Arrays. (line 302) * identity <2>: Mathematical functions. (line 6) * identity: Transforms. (line 24) -* identity4: three. (line 427) +* identity4: three. (line 432) * if: Programming. (line 8) * IgnoreAspect: Frames and pictures. (line 58) * image: palette. (line 34) @@ -8968,11 +8971,11 @@ Index * implicit casts: Casts. (line 6) * implicit linear solver: MetaPost. (line 10) * implicit scaling: Implicit scaling. (line 6) -* import: Import. (line 48) +* import: Import. (line 46) * inches: Tutorial. (line 61) * including images: label. (line 80) * increasing: math. (line 59) -* inheritance: Structures. (line 189) +* inheritance: Structures. (line 181) * initialized: Arrays. (line 39) * initializers: Variable initializers. (line 6) @@ -8993,22 +8996,22 @@ Index * interp: Arithmetic & logical. (line 76) * interpolate: interpolate. (line 6) -* intersect <1>: three. (line 497) +* intersect <1>: three. (line 502) * intersect <2>: math. (line 13) * intersect: Paths and guides. (line 181) -* intersectionpoint <1>: three. (line 497) +* intersectionpoint <1>: three. (line 502) * intersectionpoint <2>: math. (line 17) * intersectionpoint: Paths and guides. (line 224) -* intersectionpoints <1>: three. (line 497) +* intersectionpoints <1>: three. (line 502) * intersectionpoints: Paths and guides. (line 228) -* intersections <1>: three. (line 497) +* intersections <1>: three. (line 502) * intersections: Paths and guides. (line 192) * InTicks: graph3. (line 34) * intMax: Data types. (line 28) * intMin: Data types. (line 28) -* inverse <1>: Arrays. (line 309) +* inverse <1>: Arrays. (line 308) * inverse: Transforms. (line 16) -* invert: three. (line 417) +* invert: three. (line 422) * invisible: Pens. (line 39) * J: Mathematical functions. (line 6) @@ -9019,11 +9022,11 @@ Index (line 48) * Kate: Editing modes. (line 49) * KDE editor: Editing modes. (line 49) -* keyboard bindings:: three. (line 164) +* keyboard bindings:: three. (line 169) * keys: Arrays. (line 39) * keywords: Named arguments. (line 6) * Korean: unicode. (line 12) -* label: three. (line 461) +* label: three. (line 466) * Label <1>: graph. (line 342) * Label: label. (line 15) * label: clip. (line 16) @@ -9048,24 +9051,25 @@ Index * LeftRight: graph. (line 290) * LeftSide: label. (line 62) * LeftTicks: graph. (line 161) -* LeftView: three. (line 376) +* LeftView: three. (line 381) * legend <1>: graph. (line 431) * legend <2>: draw. (line 64) * legend: Drawing commands. (line 31) * Legendre: Mathematical functions. (line 48) -* length <1>: three. (line 497) +* length <1>: three. (line 502) * length <2>: Arrays. (line 39) * length <3>: Paths and guides. (line 65) * length: Data types. (line 60) * letter: Configuring. (line 61) +* lexorder: math. (line 68) * libm routines: Mathematical functions. (line 6) * libsigsegv <1>: Help. (line 33) * libsigsegv: Functions. (line 88) * limits: graph. (line 636) -* line: Arrays. (line 347) -* line mode: Arrays. (line 347) +* line: Arrays. (line 346) +* line mode: Arrays. (line 346) * Linear: graph. (line 682) * linecap: Pens. (line 129) * linejoin: Pens. (line 138) @@ -9094,10 +9098,10 @@ Index * makepen: Pens. (line 300) * map: Arrays. (line 141) * Margin: draw. (line 42) -* Margin3: three. (line 556) -* margins: three. (line 257) +* Margin3: three. (line 559) +* margins: three. (line 262) * Margins: draw. (line 42) -* Margins3: three. (line 556) +* Margins3: three. (line 559) * mark: graph. (line 484) * markangle: markers. (line 38) * marker: graph. (line 484) @@ -9107,14 +9111,14 @@ Index * math: math. (line 6) * mathematical functions: Mathematical functions. (line 6) -* max <1>: three. (line 497) -* max <2>: Arrays. (line 228) +* max <1>: three. (line 502) +* max <2>: Arrays. (line 227) * max <3>: Frames and pictures. (line 7) * max: Paths and guides. (line 264) * maxbound: Data types. (line 104) -* maxtile: three. (line 205) +* maxtile: three. (line 210) * maxtimes: Paths and guides. (line 219) -* maxviewport: three. (line 205) +* maxviewport: three. (line 210) * MetaPost: MetaPost. (line 6) * MetaPost ... : Bezier curves. (line 67) * MetaPost cutafter: Paths and guides. (line 252) @@ -9123,13 +9127,13 @@ Index * MetaPost whatever: MetaPost. (line 10) * Microsoft Windows: Microsoft Windows. (line 6) * MidArcArrow: draw. (line 26) -* MidArcArrow3: three. (line 540) +* MidArcArrow3: three. (line 543) * MidArrow: draw. (line 26) -* MidArrow3: three. (line 540) +* MidArrow3: three. (line 543) * midpoint: Paths and guides. (line 166) * MidPoint: label. (line 57) -* min <1>: three. (line 497) -* min <2>: Arrays. (line 221) +* min <1>: three. (line 502) +* min <2>: Arrays. (line 220) * min <3>: Frames and pictures. (line 7) * min: Paths and guides. (line 260) * minbound: Data types. (line 101) @@ -9140,10 +9144,10 @@ Index * mm: Tutorial. (line 61) * mode: Files. (line 84) * mouse: GUI. (line 6) -* mouse bindings: three. (line 132) +* mouse bindings: three. (line 137) * Move: Pens. (line 339) * MoveQuiet: Pens. (line 345) -* multisample: three. (line 122) +* multisample: three. (line 127) * multisampling: Compiling from UNIX source. (line 16) * N: Tutorial. (line 104) @@ -9161,10 +9165,10 @@ Index * NoFill <1>: Frames and pictures. (line 141) * NoFill: draw. (line 26) * NoMargin: draw. (line 42) -* NoMargin3: three. (line 556) +* NoMargin3: three. (line 559) * none: Files. (line 58) * None: draw. (line 19) -* normal: three. (line 483) +* normal: three. (line 488) * nosafe: Options. (line 161) * NOT: Arithmetic & logical. (line 80) @@ -9173,13 +9177,13 @@ Index * null: Structures. (line 6) * nullpen <1>: Frames and pictures. (line 127) * nullpen: label. (line 14) -* NURBS: three. (line 353) -* O: three. (line 269) +* NURBS: three. (line 358) +* O: three. (line 274) * obj: obj. (line 9) -* oblique: three. (line 314) -* obliqueX: three. (line 322) -* obliqueY: three. (line 329) -* obliqueZ: three. (line 314) +* oblique: three. (line 319) +* obliqueX: three. (line 327) +* obliqueY: three. (line 334) +* obliqueZ: three. (line 319) * ode: ode. (line 9) * offset <1>: Options. (line 166) * offset: Pens. (line 115) @@ -9188,15 +9192,15 @@ Index * OmitTickIntervals: graph. (line 239) * opacity: Pens. (line 222) * open: Files. (line 11) -* OpenGL: three. (line 122) +* OpenGL: three. (line 127) * operator: User-defined operators. (line 6) * operator --: graph. (line 31) * operator ..: graph. (line 34) * operator answer: Interactive mode. (line 37) -* operator cast: Casts. (line 31) -* operator ecast: Casts. (line 58) -* operator init <1>: Structures. (line 141) +* operator cast: Casts. (line 30) +* operator ecast: Casts. (line 57) +* operator init <1>: Structures. (line 134) * operator init: Variable initializers. (line 6) * operators: Operators. (line 6) @@ -9204,8 +9208,8 @@ Index * OR: Arithmetic & logical. (line 80) * orientation: Frames and pictures. (line 95) -* orthographic: three. (line 333) -* outformat: three. (line 122) +* orthographic: three. (line 338) +* outformat: three. (line 127) * outprefix: Frames and pictures. (line 83) * output <1>: Options. (line 141) * output: Files. (line 35) @@ -9218,7 +9222,7 @@ Index * packing: Rest arguments. (line 30) * pair <1>: Data types. (line 41) * pair: Tutorial. (line 49) -* pairs: Arrays. (line 245) +* pairs: Arrays. (line 244) * paperheight: Configuring. (line 61) * papertype: Configuring. (line 61) * paperwidth: Configuring. (line 61) @@ -9226,7 +9230,7 @@ Index * parametric surface: graph3. (line 100) * parametrized curve: graph. (line 636) * partialsum: math. (line 53) -* patch-dependent colors: three. (line 76) +* patch-dependent colors: three. (line 81) * path <1>: flowchart. (line 81) * path <2>: three. (line 43) * path: Paths and guides. (line 7) @@ -9241,30 +9245,30 @@ Index * pdfviewerOptions: Options. (line 128) * pen: Pens. (line 6) * PenMargin: draw. (line 42) -* PenMargin2: three. (line 556) -* PenMargin3: three. (line 556) +* PenMargin2: three. (line 559) +* PenMargin3: three. (line 559) * PenMargins: draw. (line 42) -* PenMargins2: three. (line 556) -* PenMargins3: three. (line 556) +* PenMargins2: three. (line 559) +* PenMargins3: three. (line 559) * perpendicular: geometry. (line 6) -* perspective: three. (line 353) +* perspective: three. (line 358) * picture: Frames and pictures. (line 35) * picture alignment: Frames and pictures. (line 209) * piecewisestraight: Paths and guides. (line 81) * Pl: Mathematical functions. (line 48) * plain: plain. (line 6) -* planar: three. (line 84) -* plane: three. (line 296) -* planeproject: three. (line 480) -* point <1>: three. (line 497) +* planar: three. (line 89) +* plane: three. (line 301) +* planeproject: three. (line 485) +* point <1>: three. (line 502) * point: Paths and guides. (line 84) * polar: Data types. (line 119) * polargraph: graph. (line 90) * polygon: graph. (line 484) * pop: Arrays. (line 39) * Portrait: Frames and pictures. (line 95) -* postcontrol <1>: three. (line 497) +* postcontrol <1>: three. (line 502) * postcontrol: Paths and guides. (line 135) * postfix operators: Self & prefix operators. (line 19) @@ -9273,9 +9277,9 @@ Index * PostScript subpath: Tutorial. (line 132) * pow10: Mathematical functions. (line 6) -* prc: three. (line 226) +* prc: three. (line 231) * precision: Files. (line 88) -* precontrol <1>: three. (line 497) +* precontrol <1>: three. (line 502) * precontrol: Paths and guides. (line 128) * prefix operators: Self & prefix operators. (line 6) @@ -9290,12 +9294,12 @@ Index * public: Structures. (line 6) * push: Arrays. (line 39) * Python usage: Interactive mode. (line 80) -* quadraticroots: Arrays. (line 312) +* quadraticroots: Arrays. (line 311) * quarticroots: math. (line 22) * quit <1>: Debugger. (line 54) * quit <2>: Interactive mode. (line 59) * quit: Tutorial. (line 35) -* quote: Import. (line 119) +* quote: Import. (line 116) * quotient: Arithmetic & logical. (line 6) * RadialShade: Frames and pictures. (line 159) @@ -9303,16 +9307,16 @@ Index * RadialShadeDraw: Frames and pictures. (line 163) * radians: Mathematical functions. (line 17) -* radius <1>: three. (line 497) +* radius <1>: three. (line 502) * radius: Paths and guides. (line 124) * Rainbow: palette. (line 12) * rand: Mathematical functions. (line 39) * randMax: Mathematical functions. (line 39) -* read: Arrays. (line 388) +* read: Arrays. (line 387) * reading: Files. (line 11) -* reading string arrays: Arrays. (line 357) +* reading string arrays: Arrays. (line 356) * readline: Files. (line 130) * real: Data types. (line 33) * realDigits: Data types. (line 33) @@ -9330,14 +9334,14 @@ Index (line 6) * rename: Files. (line 147) * render <1>: Options. (line 141) -* render: three. (line 122) +* render: three. (line 47) * replace: Data types. (line 252) * resetdefaultpen: Pens. (line 353) * rest arguments: Rest arguments. (line 6) * restore: Frames and pictures. (line 265) * restricted: Structures. (line 6) * return: Debugger. (line 48) -* reverse <1>: three. (line 497) +* reverse <1>: three. (line 502) * reverse <2>: Arrays. (line 146) * reverse <3>: Paths and guides. (line 169) * reverse: Data types. (line 248) @@ -9349,8 +9353,8 @@ Index * Right: graph. (line 287) * RightSide: label. (line 62) * RightTicks: graph. (line 161) -* RightView: three. (line 376) -* rotate: three. (line 448) +* RightView: three. (line 381) +* rotate: three. (line 453) * Rotate: label. (line 37) * Rotate(pair z): label. (line 40) * round: Mathematical functions. @@ -9361,19 +9365,19 @@ Index * roundrectangle: flowchart. (line 69) * RPM: UNIX binary distributions. (line 6) -* runtime imports: Import. (line 101) +* runtime imports: Import. (line 98) * Russian: unicode. (line 7) * S: Tutorial. (line 104) * safe: Options. (line 161) * save: Frames and pictures. (line 262) * saveline: Files. (line 130) -* scale: three. (line 447) +* scale: three. (line 452) * Scale: graph. (line 698) * scale <1>: graph. (line 682) * scale <2>: Transforms. (line 39) * scale: Pens. (line 115) * Scale: label. (line 46) -* scale3: three. (line 444) +* scale3: three. (line 449) * scaled graph: graph. (line 663) * scientific graph: graph. (line 396) * scroll: Files. (line 104) @@ -9396,12 +9400,12 @@ Index * sgn: Mathematical functions. (line 26) * shading: fill. (line 32) -* shift <1>: three. (line 432) +* shift <1>: three. (line 437) * shift: Transforms. (line 27) * Shift: label. (line 34) * shiftless: Transforms. (line 53) * shipout: Frames and pictures. (line 83) -* showtarget: three. (line 333) +* showtarget: three. (line 338) * Si: Mathematical functions. (line 48) * signedint: Files. (line 70) @@ -9418,14 +9422,14 @@ Index * singlereal: Files. (line 70) * sinh: Mathematical functions. (line 6) -* SixViews: three. (line 391) -* SixViewsFR: three. (line 391) -* SixViewsUS: three. (line 391) +* SixViews: three. (line 396) +* SixViewsFR: three. (line 396) +* SixViewsUS: three. (line 396) * size <1>: Options. (line 141) -* size <2>: three. (line 497) +* size <2>: three. (line 502) * size <3>: Frames and pictures. (line 43) * size: Paths and guides. (line 70) -* size3: three. (line 254) +* size3: three. (line 259) * slant: Transforms. (line 45) * Slant: label. (line 43) * sleep: Data types. (line 334) @@ -9436,8 +9440,8 @@ Index * slopefield: slopefield. (line 6) * solid: Pens. (line 95) * solids: solids. (line 9) -* solve: Arrays. (line 281) -* sort: Arrays. (line 187) +* solve: Arrays. (line 280) +* sort: Arrays. (line 186) * Spline <1>: graph3. (line 100) * Spline: graph. (line 34) * split: Data types. (line 261) @@ -9455,7 +9459,7 @@ Index * step: Debugger. (line 39) * stickframe: markers. (line 16) * stop: Debugger. (line 10) -* straight: three. (line 497) +* straight: three. (line 502) * Straight: graph. (line 31) * straight: Paths and guides. (line 77) * strftime: Data types. (line 292) @@ -9465,12 +9469,12 @@ Index * strptime: Data types. (line 300) * struct: Structures. (line 6) * structures: Structures. (line 6) -* subpath <1>: three. (line 497) +* subpath <1>: three. (line 502) * subpath: Paths and guides. (line 172) * subpictures: Frames and pictures. (line 103) * substr: Data types. (line 244) * Subversion: Subversion. (line 6) -* sum: Arrays. (line 216) +* sum: Arrays. (line 215) * superpath: Tutorial. (line 132) * Suppress: Pens. (line 331) * SuppressQuiet: Pens. (line 335) @@ -9489,7 +9493,7 @@ Index (line 6) * tanh: Mathematical functions. (line 6) -* target: three. (line 333) +* target: three. (line 338) * tell: Files. (line 88) * tension <1>: three. (line 6) * tension: Bezier curves. (line 56) @@ -9502,7 +9506,7 @@ Index * TeX string: Data types. (line 179) * texcommand: Configuring. (line 67) * TeXHead: draw. (line 26) -* TeXHead3: three. (line 540) +* TeXHead3: three. (line 543) * texpath <1>: label. (line 116) * texpath: Configuring. (line 67) * texpreamble: Frames and pictures. (line 286) @@ -9510,13 +9514,13 @@ Index * textbook graph: graph. (line 371) * tgz: UNIX binary distributions. (line 6) -* thick: three. (line 105) -* thin: three. (line 105) +* thick: three. (line 110) +* thin: three. (line 110) * this: Structures. (line 6) * three: three. (line 6) -* ThreeViews: three. (line 391) -* ThreeViewsFR: three. (line 391) -* ThreeViewsUS: three. (line 391) +* ThreeViews: three. (line 396) +* ThreeViewsFR: three. (line 396) +* ThreeViewsUS: three. (line 396) * tick: graph. (line 342) * Ticks: graph. (line 161) * ticks: graph. (line 161) @@ -9527,26 +9531,26 @@ Index * time: Data types. (line 292) * times: Paths and guides. (line 206) * Top: graph. (line 137) -* TopView: three. (line 376) +* TopView: three. (line 381) * trace: Debugger. (line 51) * trailingzero: graph. (line 175) -* transform <1>: three. (line 472) +* transform <1>: three. (line 477) * transform: Transforms. (line 6) -* transform3: three. (line 427) +* transform3: three. (line 432) * transparency: Pens. (line 222) -* transpose: Arrays. (line 208) +* transpose: Arrays. (line 207) * tree: tree. (line 9) * trembling: trembling. (line 6) * triangle: geometry. (line 6) * triangulate: contour. (line 157) -* tridiagonal: Arrays. (line 269) +* tridiagonal: Arrays. (line 268) * trigonometric integrals: Mathematical functions. (line 48) * triple: Data types. (line 108) * TrueMargin: draw. (line 42) -* TrueMargin3: three. (line 556) +* TrueMargin3: three. (line 559) * tube <1>: tube. (line 6) -* tube: three. (line 105) +* tube: three. (line 110) * tutorial: Tutorial. (line 6) * typedef <1>: Functions. (line 36) * typedef: Data types. (line 344) @@ -9557,10 +9561,11 @@ Index * unicode: unicode. (line 6) * uniform: Arrays. (line 155) * Uninstall: Uninstall. (line 6) +* unique: math. (line 64) * unit: Data types. (line 78) -* unitbox <1>: three. (line 302) +* unitbox <1>: three. (line 307) * unitbox: Tutorial. (line 153) -* unitcircle <1>: three. (line 269) +* unitcircle <1>: three. (line 274) * unitcircle: Tutorial. (line 126) * unitrand: Mathematical functions. (line 39) @@ -9569,8 +9574,8 @@ Index * UNIX binary distributions: UNIX binary distributions. (line 6) * unpacking: Rest arguments. (line 39) -* unravel: Import. (line 31) -* up: three. (line 333) +* unravel: Import. (line 30) +* up: three. (line 338) * update: Files. (line 35) * UpsideDown: Frames and pictures. (line 95) * usepackage: Frames and pictures. (line 291) @@ -9579,34 +9584,36 @@ Index (line 6) * usleep: Data types. (line 337) * value: math. (line 38) +* var: Variable initializers. + (line 63) * variable initializers: Variable initializers. (line 6) * vectorfield: graph. (line 975) * vectorfield3: graph3. (line 159) -* vectorization: Arrays. (line 326) +* vectorization: Arrays. (line 325) * verbatim: Frames and pictures. (line 271) -* vertex-dependent colors: three. (line 76) +* vertex-dependent colors: three. (line 81) * Vertical: flowchart. (line 81) -* viewportheight: LaTeX usage. (line 32) -* viewportmargin: three. (line 257) -* viewportsize: three. (line 257) -* viewportwidth: LaTeX usage. (line 32) -* views: three. (line 226) +* viewportheight: LaTeX usage. (line 31) +* viewportmargin: three. (line 262) +* viewportsize: three. (line 262) +* viewportwidth: LaTeX usage. (line 31) +* views: three. (line 231) * vim: Editing modes. (line 33) -* virtual functions: Structures. (line 189) +* virtual functions: Structures. (line 181) * void: Data types. (line 10) * W: Tutorial. (line 104) * whatever: Paths and guides. (line 232) * Wheel: palette. (line 22) * wheel mouse: GUI. (line 6) * while: Programming. (line 29) -* white-space string delimiter mode: Arrays. (line 357) -* width: LaTeX usage. (line 32) +* white-space string delimiter mode: Arrays. (line 356) +* width: LaTeX usage. (line 31) * windingnumber: Paths and guides. (line 268) -* word: Arrays. (line 357) -* write <1>: Arrays. (line 397) +* word: Arrays. (line 356) +* write <1>: Arrays. (line 396) * write: Files. (line 50) -* X: three. (line 269) +* X: three. (line 274) * xasy: GUI. (line 6) * xaxis3: graph3. (line 7) * xelatex <1>: Options. (line 141) @@ -9620,15 +9627,15 @@ Index * xoutput: Files. (line 70) * xpart: Data types. (line 89) * xscale: Transforms. (line 33) -* xscale3: three. (line 435) +* xscale3: three. (line 440) * xtick: graph. (line 342) -* XY: three. (line 457) +* XY: three. (line 462) * XYEquals: graph3. (line 20) * XYZero: graph3. (line 20) * XZEquals: graph3. (line 20) * XZero: graph. (line 275) * XZZero: graph3. (line 20) -* Y <1>: three. (line 269) +* Y <1>: three. (line 274) * Y: Mathematical functions. (line 6) * yaxis3: graph3. (line 7) @@ -9637,14 +9644,14 @@ Index * ylimits: graph. (line 636) * ypart: Data types. (line 92) * yscale: Transforms. (line 36) -* yscale3: three. (line 438) +* yscale3: three. (line 443) * ytick: graph. (line 342) -* YX: three. (line 472) -* YZ: three. (line 472) +* YX: three. (line 477) +* YZ: three. (line 477) * YZEquals: graph3. (line 20) * YZero: graph. (line 125) * YZZero: graph3. (line 20) -* Z: three. (line 269) +* Z: three. (line 274) * zaxis3: graph3. (line 7) * zero_Ai: Mathematical functions. (line 48) @@ -9660,9 +9667,9 @@ Index * zeta: Mathematical functions. (line 48) * zpart: Data types. (line 161) -* zscale3: three. (line 441) -* ZX: three. (line 472) -* ZY: three. (line 472) +* zscale3: three. (line 446) +* ZX: three. (line 477) +* ZY: three. (line 477) * |: Arithmetic & logical. (line 62) * ||: Arithmetic & logical. @@ -9687,130 +9694,130 @@ Node: Subversion25457 Node: Uninstall25920 Node: Tutorial26270 Ref: unitcircle30496 -Node: Drawing commands32477 -Node: draw34188 -Ref: arrows35336 -Node: fill40579 -Ref: gradient shading41623 -Node: clip45851 -Node: label46443 -Ref: Label47142 -Node: Bezier curves52867 -Node: Programming56444 -Ref: array iteration57258 -Node: Data types58340 -Ref: format67348 -Node: Paths and guides70951 -Ref: circle71205 -Ref: arctime76693 -Ref: extension80548 -Node: Pens87231 -Ref: fillrule94597 -Ref: basealign95494 -Ref: transparency98319 -Ref: makepen101762 -Ref: overwrite102600 -Node: Transforms103810 -Node: Frames and pictures105601 -Ref: envelope106742 -Ref: size107825 -Ref: unitsize108812 -Ref: shipout109872 -Ref: filltype112205 -Ref: add115342 -Ref: add about116288 -Ref: tex119226 -Node: Files120100 -Ref: cd121065 -Ref: scroll125497 -Node: Variable initializers128570 -Node: Structures130865 -Node: Operators138317 -Node: Arithmetic & logical138631 -Node: Self & prefix operators140605 -Node: User-defined operators141393 -Node: Implicit scaling142304 -Node: Functions142867 -Ref: stack overflow145620 -Node: Default arguments146184 -Node: Named arguments146923 -Node: Rest arguments149085 -Node: Mathematical functions151895 -Node: Arrays156502 -Ref: sort163513 -Ref: tridiagonal165923 -Ref: solve167151 -Node: Slices171344 -Node: Casts175237 -Node: Import177203 -Node: Static182433 -Node: LaTeX usage185329 -Node: Base modules190767 -Node: plain193267 -Node: simplex193919 -Node: math194192 -Node: interpolate196525 -Node: geometry196804 -Node: trembling197398 -Node: stats197749 -Node: patterns198009 -Node: markers198245 -Node: tree200028 -Node: binarytree200216 -Node: drawtree200805 -Node: syzygy201009 -Node: feynman201283 -Node: roundedpath201558 -Node: animation201841 -Ref: animate202258 -Node: embed203397 -Node: slide205186 -Node: MetaPost205526 -Node: unicode206242 -Node: latin1207130 -Node: babel207498 -Node: labelpath207727 -Node: labelpath3208547 -Node: annotate208858 -Node: CAD209329 -Node: graph209639 -Ref: ticks216768 -Ref: pathmarkers230047 -Ref: marker230512 -Ref: markuniform230863 -Ref: errorbars232654 -Ref: automatic scaling236710 -Node: palette247356 -Ref: images247474 -Ref: image251645 -Ref: logimage252123 -Ref: penimage252929 -Node: three253373 -Ref: PostScript3D277702 -Node: obj279394 -Node: graph3279646 -Ref: GaussianSurface284771 -Node: grid3285856 -Node: solids286596 -Node: tube287544 -Node: flowchart289779 -Node: contour294348 -Node: contour3299473 -Node: slopefield299780 -Node: ode301217 -Node: Options301477 -Ref: configuration file307273 -Ref: settings307273 -Ref: convert308474 -Node: Interactive mode311441 -Ref: history313594 -Node: GUI314899 -Node: GUI installation315402 -Node: GUI usage316544 -Node: PostScript to Asymptote317447 -Node: Help318203 -Node: Debugger319939 -Node: Credits321724 -Node: Index322637 +Node: Drawing commands32432 +Node: draw34143 +Ref: arrows35291 +Node: fill40534 +Ref: gradient shading41578 +Node: clip45806 +Node: label46398 +Ref: Label47097 +Node: Bezier curves52822 +Node: Programming56399 +Ref: array iteration57213 +Node: Data types58295 +Ref: format67303 +Node: Paths and guides70906 +Ref: circle71160 +Ref: arctime76648 +Ref: extension80503 +Node: Pens87186 +Ref: fillrule94552 +Ref: basealign95449 +Ref: transparency98274 +Ref: makepen101717 +Ref: overwrite102555 +Node: Transforms103765 +Node: Frames and pictures105556 +Ref: envelope106697 +Ref: size107780 +Ref: unitsize108767 +Ref: shipout109827 +Ref: filltype112160 +Ref: add115297 +Ref: add about116243 +Ref: tex119181 +Node: Files120055 +Ref: cd121020 +Ref: scroll125452 +Node: Variable initializers128525 +Node: Structures131138 +Node: Operators138582 +Node: Arithmetic & logical138896 +Node: Self & prefix operators140870 +Node: User-defined operators141658 +Node: Implicit scaling142569 +Node: Functions143132 +Ref: stack overflow145885 +Node: Default arguments146449 +Node: Named arguments147188 +Node: Rest arguments149350 +Node: Mathematical functions152160 +Node: Arrays156767 +Ref: sort163720 +Ref: tridiagonal166130 +Ref: solve167358 +Node: Slices171551 +Node: Casts175441 +Node: Import177406 +Node: Static182633 +Node: LaTeX usage185527 +Node: Base modules191001 +Node: plain193501 +Node: simplex194153 +Node: math194426 +Node: interpolate197117 +Node: geometry197396 +Node: trembling197990 +Node: stats198341 +Node: patterns198601 +Node: markers198837 +Node: tree200620 +Node: binarytree200808 +Node: drawtree201397 +Node: syzygy201601 +Node: feynman201875 +Node: roundedpath202150 +Node: animation202433 +Ref: animate202850 +Node: embed203989 +Node: slide205778 +Node: MetaPost206118 +Node: unicode206834 +Node: latin1207722 +Node: babel208090 +Node: labelpath208319 +Node: labelpath3209139 +Node: annotate209450 +Node: CAD209921 +Node: graph210231 +Ref: ticks217360 +Ref: pathmarkers230639 +Ref: marker231104 +Ref: markuniform231455 +Ref: errorbars233246 +Ref: automatic scaling237302 +Node: palette247948 +Ref: images248066 +Ref: image252237 +Ref: logimage252715 +Ref: penimage253521 +Node: three253965 +Ref: PostScript3D278507 +Node: obj280199 +Node: graph3280451 +Ref: GaussianSurface285576 +Node: grid3286661 +Node: solids287401 +Node: tube288349 +Node: flowchart290584 +Node: contour295153 +Node: contour3300278 +Node: slopefield300585 +Node: ode302022 +Node: Options302282 +Ref: configuration file308078 +Ref: settings308078 +Ref: convert309279 +Node: Interactive mode312246 +Ref: history314399 +Node: GUI315704 +Node: GUI installation316207 +Node: GUI usage317337 +Node: PostScript to Asymptote318240 +Node: Help318996 +Node: Debugger320732 +Node: Credits322517 +Node: Index323430 End Tag Table diff --git a/Build/source/utils/asymptote/drawelement.h b/Build/source/utils/asymptote/drawelement.h index 0687cd6cd66..2898431b79c 100644 --- a/Build/source/utils/asymptote/drawelement.h +++ b/Build/source/utils/asymptote/drawelement.h @@ -27,7 +27,7 @@ extern void copyArrayC(T* &dest, const vm::array *a, size_t dim, namespace camp { -enum Entity {LINE=0,CURVE,SURFACE,BILLBOARD_SURFACE,nENTITY}; +enum Interaction {EMBEDDED=0,BILLBOARD}; class box { pair p[4]; @@ -100,6 +100,9 @@ typedef mem::vector<box> boxvector; typedef mem::list<bbox> bboxlist; +typedef mem::map<CONST string,unsigned> groupmap; +typedef mem::vector<groupmap> groupsmap; + class drawElement : public gc { public: @@ -150,7 +153,8 @@ public: // Output to a PRC file // The array origin contains the points about which to rotate billboard labels virtual bool write(prcfile *out, unsigned int *count, vm::array *index, - vm::array *origin) { + vm::array *origin, double compressionlimit, + groupsmap& groups) { return false; } diff --git a/Build/source/utils/asymptote/drawgroup.h b/Build/source/utils/asymptote/drawgroup.h index 53b689c8ae6..8cc2cedaa47 100644 --- a/Build/source/utils/asymptote/drawgroup.h +++ b/Build/source/utils/asymptote/drawgroup.h @@ -13,19 +13,12 @@ namespace camp { class drawBegin : public drawElement { - string name; public: - drawBegin(string name="") : name(name) {} + drawBegin() {} virtual ~drawBegin() {} bool begingroup() {return true;} - - bool write(prcfile *out, unsigned int *, vm::array *, vm::array *) { - out->begingroup(name.c_str()); - return true; - } - }; class drawEnd : public drawElement { @@ -35,12 +28,88 @@ public: virtual ~drawEnd() {} bool endgroup() {return true;} +}; + +class drawBegin3 : public drawElement { + string name; + double compression; + double granularity; + bool closed; // render the surface as one-sided; may yield faster rendering + bool tessellate; // use tessellated mesh to store straight patches + bool dobreak; // force breaking + bool nobreak; // force grouping for transparent patches - bool write(prcfile *out, unsigned int *, vm::array *, vm::array *) { - out->endgroup(); + triple center; + int interaction; + + groupmap *g; +public: + drawBegin3(string name, double compression, double granularity, + bool closed, bool tessellate, bool dobreak, bool nobreak, + triple center, int interaction) : + name(name), compression(compression), granularity(granularity), + closed(closed), tessellate(tessellate), dobreak(dobreak), nobreak(nobreak), + center(center), interaction(interaction) {} + + virtual ~drawBegin3() {} + + bool begingroup() {return true;} + + bool write(prcfile *out, unsigned int *count, vm::array *index, + vm::array *origin, double compressionlimit, + groupsmap& groups) { + groupmap& group=groups.back(); + if(name.empty()) name="group"; + groupmap::const_iterator p=group.find(name); + + unsigned c=(p != group.end()) ? p->second+1 : 0; + group[name]=c; + + ostringstream buf; + buf << name; + if(c > 0) buf << "-" << (c+1); + + if(interaction == BILLBOARD) { + buf << "-" << (*count)++ << "\001"; + index->push((Int) origin->size()); + origin->push(center); + } + + PRCoptions options(compression > 0.0 ? + max(compression,compressionlimit) : 0.0, + granularity,closed,tessellate,dobreak,nobreak); + + groups.push_back(groupmap()); + out->begingroup(buf.str().c_str(),&options); return true; } + + drawBegin3(const vm::array& t, const drawBegin3 *s) : + name(s->name), compression(s->compression), granularity(s->granularity), + closed(s->closed), tessellate(s->tessellate), dobreak(s->dobreak), + nobreak(s->nobreak), interaction(s->interaction) { + center=run::operator *(t,s->center); + } + + drawElement *transformed(const array& t) { + return new drawBegin3(t,this); + } +}; + +class drawEnd3 : public drawElement { +public: + drawEnd3() {} + + virtual ~drawEnd3() {} + bool endgroup() {return true;} + + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap& groups) { + groups.pop_back(); + out->endgroup(); + return true; + } }; } diff --git a/Build/source/utils/asymptote/drawpath3.cc b/Build/source/utils/asymptote/drawpath3.cc index 77d1d6aced9..699928b9b38 100644 --- a/Build/source/utils/asymptote/drawpath3.cc +++ b/Build/source/utils/asymptote/drawpath3.cc @@ -10,32 +10,22 @@ namespace camp { using vm::array; -bool drawPath3::write(prcfile *out, unsigned int *count, array *, array *) +bool drawPath3::write(prcfile *out, unsigned int *count, array *, array *, + double, groupsmap&) { Int n=g.length(); if(n == 0 || invisible) return true; - ostringstream buf; - if(straight) { - if(name == "") - buf << "line-" << count[LINE]++; - else - buf << name; - - controls=new(UseGC) Triple[n+1]; + Triple *controls=new(UseGC) Triple[n+1]; for(Int i=0; i <= n; ++i) store(controls[i],g.point(i)); - out->add(new PRCline(out,n+1,controls,color,scale3D,buf.str().c_str())); - } else { - if(name == "") - buf << "curve-" << count[CURVE]++; - else - buf << name; + out->addLine(n+1,controls,color); + } else { int m=3*n+1; - controls=new(UseGC) Triple[m]; + Triple *controls=new(UseGC) Triple[m]; store(controls[0],g.point((Int) 0)); store(controls[1],g.postcontrol((Int) 0)); size_t k=1; @@ -44,10 +34,11 @@ bool drawPath3::write(prcfile *out, unsigned int *count, array *, array *) store(controls[++k],g.point(i)); store(controls[++k],g.postcontrol(i)); } - store(controls[++k],g.precontrol((Int) n)); - store(controls[++k],g.point((Int) n)); - out->add(new PRCBezierCurve(out,3,m,controls,color,buf.str())); + store(controls[++k],g.precontrol(n)); + store(controls[++k],g.point(n)); + out->addBezierCurve(m,controls,color); } + return true; } @@ -102,19 +93,12 @@ drawElement *drawPath3::transformed(const array& t) } bool drawNurbsPath3::write(prcfile *out, unsigned int *count, array *index, - array *origin) + array *origin, double, groupsmap&) { - ostringstream buf; - if(name == "") - buf << "curve-" << count[CURVE]++; - else - buf << name; - if(invisible) return true; - out->add(new PRCcurve(out,degree,n,controls,knots,color,scale3D, - weights != NULL,weights,buf.str().c_str())); + out->addCurve(degree,n,controls,knots,color,weights); return true; } diff --git a/Build/source/utils/asymptote/drawpath3.h b/Build/source/utils/asymptote/drawpath3.h index d267a93b734..97801cdc452 100644 --- a/Build/source/utils/asymptote/drawpath3.h +++ b/Build/source/utils/asymptote/drawpath3.h @@ -19,18 +19,14 @@ protected: RGBAColour color; bool invisible; triple Min,Max; - Triple *controls; - string name; public: - drawPath3(path3 g, const pen& p, const string& name) : + drawPath3(path3 g, const pen& p) : g(g), straight(g.piecewisestraight()), color(rgba(p)), - invisible(p.invisible()), Min(g.min()), Max(g.max()), controls(NULL), - name(name) {} + invisible(p.invisible()), Min(g.min()), Max(g.max()) {} drawPath3(const vm::array& t, const drawPath3 *s) : g(camp::transformed(t,s->g)), straight(s->straight), color(s->color), - invisible(s->invisible), Min(g.min()), Max(g.max()), controls(NULL), - name(s->name) {} + invisible(s->invisible), Min(g.min()), Max(g.max()) {} virtual ~drawPath3() {} @@ -49,8 +45,8 @@ public: } else b=pair(m(b.getx(),z.getx()),m(b.gety(),z.gety())); } - bool write(prcfile *out, unsigned int *count, vm::array *index, - vm::array *origin); + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&); void render(GLUnurbs*, double, const triple&, const triple&, double, bool transparent); @@ -67,7 +63,6 @@ protected: double *knots; RGBAColour color; bool invisible; - string name; triple Min,Max; #ifdef HAVE_GL @@ -77,8 +72,8 @@ protected: public: drawNurbsPath3(const vm::array& g, const vm::array* knot, - const vm::array* weight, const pen& p, const string& name) : - color(rgba(p)), invisible(p.invisible()), name(name) { + const vm::array* weight, const pen& p) : + color(rgba(p)), invisible(p.invisible()) { size_t weightsize=checkArray(weight); string wrongsize="Inconsistent NURBS data"; @@ -115,8 +110,7 @@ public: } drawNurbsPath3(const vm::array& t, const drawNurbsPath3 *s) : - degree(s->degree), n(s->n), color(s->color), invisible(s->invisible), - name(s->name) { + degree(s->degree), n(s->n), color(s->color), invisible(s->invisible) { controls=new(UseGC) Triple[n]; for(size_t i=0; i < n; ++i) { @@ -150,8 +144,8 @@ public: virtual ~drawNurbsPath3() {} - bool write(prcfile *out, unsigned int *count, vm::array *index, - vm::array *origin); + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&); void displacement(); void ratio(pair &b, double (*m)(double, double), double fuzz, bool &first); diff --git a/Build/source/utils/asymptote/drawsurface.cc b/Build/source/utils/asymptote/drawsurface.cc index a19406a714f..e5c8194700f 100644 --- a/Build/source/utils/asymptote/drawsurface.cc +++ b/Build/source/utils/asymptote/drawsurface.cc @@ -141,39 +141,18 @@ void drawSurface::ratio(pair &b, double (*m)(double, double), double fuzz, } } -bool drawSurface::write(prcfile *out, unsigned int *count, array *index, - array *origin) +bool drawSurface::write(prcfile *out, unsigned int *, array *, array *, double, + groupsmap&) { - if(invisible) + if(invisible || !prc) return true; - ostringstream buf; - if(name == "") - buf << "surface-" << count[SURFACE]++; - else - buf << name; - - if(interaction == BILLBOARD) { - size_t n=origin->size(); - - if(n == 0 || center != vm::read<triple>(origin,n-1)) { - origin->push(center); - ++n; - } - - unsigned int i=count[BILLBOARD_SURFACE]++; - buf << "-" << i << "\001"; - index->push((Int) (n-1)); - } - - PRCMaterial m(ambient,diffuse,emissive,specular,opacity,PRCshininess); + PRCmaterial m(ambient,diffuse,emissive,specular,opacity,PRCshininess); if(straight) - out->add(new PRCBezierSurface(out,1,1,2,2,vertices,m,granularity, - buf.str())); + out->addRectangle(vertices,m); else - out->add(new PRCBezierSurface(out,3,3,4,4,controls,m,granularity, - buf.str())); + out->addPatch(controls,m); return true; } @@ -366,8 +345,7 @@ void drawSurface::render(GLUnurbs *nurb, double size2, bool havenormal=normal != zero; if(havebillboard) BB.init(); - if(!havenormal || (!straight && (fraction(d,size3)*size2 >= pixel || - granularity == 0))) { + if(!havenormal || (!straight && fraction(d,size3)*size2 >= pixel)) { if(lighton) { if(havenormal && fraction(dperp,size3)*size2 <= 0.1) { if(havebillboard) @@ -442,22 +420,14 @@ drawElement *drawSurface::transformed(const array& t) return new drawSurface(t,this); } -bool drawNurbs::write(prcfile *out, unsigned int *count, array *index, - array *origin) +bool drawNurbs::write(prcfile *out, unsigned int *, array *, array *, double, + groupsmap&) { - ostringstream buf; - if(name == "") - buf << "surface-" << count[SURFACE]++; - else - buf << name; - if(invisible) return true; - PRCMaterial m(ambient,diffuse,emissive,specular,opacity,PRCshininess); - out->add(new PRCsurface(out,udegree,vdegree,nu,nv,controls, - uknots,vknots,m,scale3D,weights != NULL, - weights,granularity,buf.str().c_str())); + PRCmaterial m(ambient,diffuse,emissive,specular,opacity,PRCshininess); + out->addSurface(udegree,vdegree,nu,nv,controls,uknots,vknots,m,weights); return true; } @@ -653,4 +623,195 @@ void drawNurbs::render(GLUnurbs *nurb, double size2, #endif } +void drawSphere::P(Triple& t, double x, double y, double z) +{ + if(half) { + double temp=z; z=x; x=-temp; + } + + double f=T[12]*x+T[13]*y+T[14]*z+T[15]; + if(f == 0.0) run::dividebyzero(); + f=1.0/f; + + t[0]=(T[0]*x+T[1]*y+T[2]*z+T[3])*f; + t[1]=(T[4]*x+T[5]*y+T[6]*z+T[7])*f; + t[2]=(T[8]*x+T[9]*y+T[10]*z+T[11])*f; +} + +static const Triple origin={0,0,0}; +static const Triple xaxis={1,0,0}; +static const Triple yaxis={0,1,0}; +static const double Identity4[4][4]={{1.0,0.0,0.0,0.0}, + {0.0,1.0,0.0,0.0}, + {0.0,0.0,1.0,0.0}, + {0.0,0.0,0.0,1.0}}; + +bool drawSphere::write(prcfile *out, unsigned int *, array *, array *, double, + groupsmap&) +{ + if(invisible) + return true; + + PRCmaterial m(ambient,diffuse,emissive,specular,opacity,shininess); + + switch(type) { + case 0: // PRCsphere + { + if(half) + out->addHemisphere(1.0,m,origin,xaxis,yaxis,1.0,(double (*)[4]) T); + else + out->addSphere(1.0,m,origin,xaxis,yaxis,1.0,(double (*)[4]) T); + break; + } + case 1: // NURBSsphere + { + static double uknot[]={0.0,0.0,1.0/3.0,0.5,1.0,1.0}; + static double vknot[]={0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0}; + static double Weights[12]={2.0/3.0,2.0/9.0,2.0/9.0,2.0/3.0, + 1.0/3.0,1.0/9.0,1.0/9.0,1.0/3.0, + 1.0,1.0/3.0,1.0/3.0,1.0}; + +// NURBS representation of a sphere using 10 distinct control points +// K. Qin, J. Comp. Sci. and Tech. 12, 210-216 (1997). + + Triple N,S,P1,P2,P3,P4,P5,P6,P7,P8; + + P(N,0.0,0.0,1.0); + P(P1,-2.0,-2.0,1.0); + P(P2,-2.0,-2.0,-1.0); + P(S,0.0,0.0,-1.0); + P(P3,2.0,-2.0,1.0); + P(P4,2.0,-2.0,-1.0); + P(P5,2.0,2.0,1.0); + P(P6,2.0,2.0,-1.0); + P(P7,-2.0,2.0,1.0); + P(P8,-2.0,2.0,-1.0); + + Triple p0[]= + {{N[0],N[1],N[2]}, + {P1[0],P1[1],P1[2]}, + {P2[0],P2[1],P2[2]}, + {S[0],S[1],S[2]}, + + {N[0],N[1],N[2]}, + {P3[0],P3[1],P3[2]}, + {P4[0],P4[1],P4[2]}, + {S[0],S[1],S[2]}, + + {N[0],N[1],N[2]}, + {P5[0],P5[1],P5[2]}, + {P6[0],P6[1],P6[2]}, + {S[0],S[1],S[2]}, + + {N[0],N[1],N[2]}, + {P7[0],P7[1],P7[2]}, + {P8[0],P8[1],P8[2]}, + {S[0],S[1],S[2]}, + + {N[0],N[1],N[2]}, + {P1[0],P1[1],P1[2]}, + {P2[0],P2[1],P2[2]}, + {S[0],S[1],S[2]}, + + {N[0],N[1],N[2]}, + {P3[0],P3[1],P3[2]}, + {P4[0],P4[1],P4[2]}, + {S[0],S[1],S[2]}, + }; + + out->addSurface(2,3,3,4,p0,uknot,vknot,m,Weights); + out->addSurface(2,3,3,4,p0+4,uknot,vknot,m,Weights); + if(!half) { + out->addSurface(2,3,3,4,p0+8,uknot,vknot,m,Weights); + out->addSurface(2,3,3,4,p0+12,uknot,vknot,m,Weights); + } + + break; + } + default: + reportError("Invalid sphere type"); + } + + return true; +} + +bool drawCylinder::write(prcfile *out, unsigned int *, array *, array *, double, + groupsmap&) +{ + if(invisible) + return true; + + PRCmaterial m(ambient,diffuse,emissive,specular,opacity,shininess); + + out->addCylinder(1.0,1.0,m,origin,xaxis,yaxis,1.0,(double (*)[4]) T); + + return true; +} + +bool drawDisk::write(prcfile *out, unsigned int *, array *, array *, double, + groupsmap&) +{ + if(invisible) + return true; + + PRCmaterial m(ambient,diffuse,emissive,specular,opacity,shininess); + + out->addDisk(1.0,m,origin,xaxis,yaxis,1.0,(double (*)[4]) T); + + return true; +} + +bool drawTube::write(prcfile *out, unsigned int *, array *, array *, double, + groupsmap&) +{ + if(invisible) + return true; + + PRCmaterial m(ambient,diffuse,emissive,specular,opacity,shininess); + + Int n=center.length(); + + if(center.piecewisestraight()) { + Triple *centerControls=new(UseGC) Triple[n+1]; + for(Int i=0; i <= n; ++i) + store(centerControls[i],center.point(i)); + size_t N=n+1; + Triple *controls=new(UseGC) Triple[N]; + for(Int i=0; i <= n; ++i) + store(controls[i],g.point(i)); + out->addTube(N,centerControls,controls,true,m,origin,xaxis,yaxis,1.0, + Identity4); + } else { + size_t N=3*n+1; + Triple *centerControls=new(UseGC) Triple[N]; + store(centerControls[0],center.point((Int) 0)); + store(centerControls[1],center.postcontrol((Int) 0)); + size_t k=1; + for(Int i=1; i < n; ++i) { + store(centerControls[++k],center.precontrol(i)); + store(centerControls[++k],center.point(i)); + store(centerControls[++k],center.postcontrol(i)); + } + store(centerControls[++k],center.precontrol(n)); + store(centerControls[++k],center.point(n)); + + Triple *controls=new(UseGC) Triple[N]; + store(controls[0],g.point((Int) 0)); + store(controls[1],g.postcontrol((Int) 0)); + k=1; + for(Int i=1; i < n; ++i) { + store(controls[++k],g.precontrol(i)); + store(controls[++k],g.point(i)); + store(controls[++k],g.postcontrol(i)); + } + store(controls[++k],g.precontrol(n)); + store(controls[++k],g.point(n)); + + out->addTube(N,centerControls,controls,false,m,origin,xaxis,yaxis,1.0, + Identity4); + } + + return true; +} + } //namespace camp diff --git a/Build/source/utils/asymptote/drawsurface.h b/Build/source/utils/asymptote/drawsurface.h index d90402e7105..80ed57515d7 100644 --- a/Build/source/utils/asymptote/drawsurface.h +++ b/Build/source/utils/asymptote/drawsurface.h @@ -14,8 +14,6 @@ namespace camp { -enum Interaction {EMBEDDED=0,BILLBOARD}; - #ifdef HAVE_GL void storecolor(GLfloat *colors, int i, const vm::array &pens, int j); #endif @@ -33,14 +31,13 @@ protected: double opacity; double shininess; double PRCshininess; - double granularity; triple normal; bool invisible; bool lighton; - string name; - Interaction interaction; + int interaction; triple Min,Max; + bool prc; #ifdef HAVE_GL GLfloat *colors; @@ -53,12 +50,11 @@ public: drawSurface(const vm::array& g, triple center, bool straight, const vm::array&p, double opacity, double shininess, - double PRCshininess, double granularity, triple normal, - const vm::array &pens, bool lighton, const string& name, - Int interaction) : + double PRCshininess, triple normal, const vm::array &pens, + bool lighton, int interaction, bool prc) : center(center), straight(straight), opacity(opacity), shininess(shininess), - PRCshininess(PRCshininess), granularity(granularity), normal(unit(normal)), - lighton(lighton), name(name), interaction((Interaction) interaction) { + PRCshininess(PRCshininess), normal(unit(normal)), lighton(lighton), + interaction(interaction), prc(prc) { string wrongsize= "Bezier surface patch requires 4x4 array of triples and array of 4 pens"; if(checkArray(&g) != 4 || checkArray(&p) != 4) @@ -112,8 +108,8 @@ public: straight(s->straight), diffuse(s->diffuse), ambient(s->ambient), emissive(s->emissive), specular(s->specular), opacity(s->opacity), shininess(s->shininess), PRCshininess(s->PRCshininess), - granularity(s->granularity), invisible(s->invisible), - lighton(s->lighton), name(s->name), interaction(s->interaction) { + invisible(s->invisible), lighton(s->lighton), + interaction(s->interaction), prc(s->prc) { for(size_t i=0; i < 4; ++i) { const double *c=s->vertices[i]; @@ -134,7 +130,7 @@ public: #ifdef HAVE_GL if(s->colors) { colors=new(UseGC) GLfloat[16]; - for(int i=0; i < 16; ++i) + for(size_t i=0; i < 16; ++i) colors[i]=s->colors[i]; } else colors=NULL; #endif @@ -148,8 +144,8 @@ public: virtual ~drawSurface() {} - bool write(prcfile *out, unsigned int *count, vm::array *index, - vm::array *origin); + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&); void displacement(); void render(GLUnurbs *nurb, double, const triple& Min, const triple& Max, @@ -172,11 +168,9 @@ protected: double opacity; double shininess; double PRCshininess; - double granularity; triple normal; bool invisible; bool lighton; - string name; triple Min,Max; @@ -190,10 +184,9 @@ protected: public: drawNurbs(const vm::array& g, const vm::array* uknot, const vm::array* vknot, const vm::array* weight, const vm::array&p, double opacity, - double shininess, double PRCshininess, double granularity, - const vm::array &pens, bool lighton, const string& name) : - opacity(opacity), shininess(shininess), PRCshininess(PRCshininess), - granularity(granularity), lighton(lighton), name(name) { + double shininess, double PRCshininess, const vm::array &pens, + bool lighton) : opacity(opacity), shininess(shininess), + PRCshininess(PRCshininess), lighton(lighton) { size_t weightsize=checkArray(weight); string wrongsize="Inconsistent NURBS data"; @@ -238,8 +231,8 @@ public: udegree=nuknots-nu-1; vdegree=nvknots-nv-1; - run::copyArrayC(uknots,uknot,0,NoGC); - run::copyArrayC(vknots,vknot,0,NoGC); + run::copyArrayC(uknots,uknot,0,UseGC); + run::copyArrayC(vknots,vknot,0,UseGC); pen surfacepen=vm::read<camp::pen>(p,0); invisible=surfacepen.invisible(); @@ -268,8 +261,7 @@ public: diffuse(s->diffuse), ambient(s->ambient), emissive(s->emissive), specular(s->specular), opacity(s->opacity), shininess(s->shininess), PRCshininess(s->PRCshininess), - granularity(s->granularity), invisible(s->invisible), lighton(s->lighton), - name(s->name) { + invisible(s->invisible), lighton(s->lighton) { size_t n=nu*nv; controls=new(UseGC) Triple[n]; @@ -303,7 +295,7 @@ public: Controls=NULL; if(s->colors) { colors=new(UseGC) GLfloat[16]; - for(int i=0; i < 16; ++i) + for(size_t i=0; i < 16; ++i) colors[i]=s->colors[i]; } else colors=NULL; #endif @@ -315,8 +307,8 @@ public: virtual ~drawNurbs() {} - bool write(prcfile *out, unsigned int *count, vm::array *index, - vm::array *origin); + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&); void displacement(); void ratio(pair &b, double (*m)(double, double), double, bool &first); @@ -328,6 +320,185 @@ public: drawElement *transformed(const vm::array& t); }; +template<class T> +void copyArray4x4C(T* dest, const vm::array *a) +{ + size_t n=checkArray(a); + string fourbyfour="4x4 array of doubles expected"; + if(n != 4) reportError(fourbyfour); + + for(size_t i=0; i < 4; i++) { + vm::array *ai=vm::read<vm::array*>(a,i); + size_t aisize=checkArray(ai); + if(aisize == 4) { + T *desti=dest+4*i; + for(size_t j=0; j < 4; j++) + desti[j]=vm::read<T>(ai,j); + } else reportError(fourbyfour); + } +} + +// Draw a transformed PRC object. +class drawPRC : public drawElement { +protected: + double T[16]; + RGBAColour diffuse; + RGBAColour ambient; + RGBAColour emissive; + RGBAColour specular; + double opacity; + double shininess; + bool invisible; +public: + drawPRC(const vm::array& t, const vm::array&p, double opacity, + double shininess) : + opacity(opacity), shininess(shininess) { + + copyArray4x4C<double>(T,&t); + + string needfourpens="array of 4 pens required"; + if(checkArray(&p) != 4) + reportError(needfourpens); + + pen surfacepen=vm::read<camp::pen>(p,0); + invisible=surfacepen.invisible(); + + diffuse=rgba(surfacepen); + ambient=rgba(vm::read<camp::pen>(p,1)); + emissive=rgba(vm::read<camp::pen>(p,2)); + specular=rgba(vm::read<camp::pen>(p,3)); + } + + drawPRC(const vm::array& t, const drawPRC *s) : + diffuse(s->diffuse), ambient(s->ambient), emissive(s->emissive), + specular(s->specular), opacity(s->opacity), + shininess(s->shininess), invisible(s->invisible) { + + double S[16]; + copyArray4x4C<double>(S,&t); + + const double *R=s->T; + for(unsigned i=0; i < 16; i += 4) { + double s0=S[i+0]; + double s1=S[i+1]; + double s2=S[i+2]; + double s3=S[i+3]; + T[i]=s0*R[0]+s1*R[4]+s2*R[8]+s3*R[12]; + T[i+1]=s0*R[1]+s1*R[5]+s2*R[9]+s3*R[13]; + T[i+2]=s0*R[2]+s1*R[6]+s2*R[10]+s3*R[14]; + T[i+3]=s0*R[3]+s1*R[7]+s2*R[11]+s3*R[15]; + } + } + + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&) { + return true; + } +}; + +// Draw a PRC unit sphere. +class drawSphere : public drawPRC { + bool half; + int type; +public: + drawSphere(const vm::array& t, bool half, const vm::array&p, double opacity, + double shininess, int type) : + drawPRC(t,p,opacity,shininess), half(half), type(type) {} + + drawSphere(const vm::array& t, const drawSphere *s) : + drawPRC(t,s), half(s->half), type(s->type) {} + + void P(Triple& t, double x, double y, double z); + + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&); + + drawElement *transformed(const vm::array& t) { + return new drawSphere(t,this); + } +}; + +// Draw a PRC unit cylinder. +class drawCylinder : public drawPRC { +public: + drawCylinder(const vm::array& t, const vm::array&p, double opacity, + double shininess) : + drawPRC(t,p,opacity,shininess) {} + + drawCylinder(const vm::array& t, const drawCylinder *s) : + drawPRC(t,s) {} + + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&); + + drawElement *transformed(const vm::array& t) { + return new drawCylinder(t,this); + } +}; + +// Draw a PRC unit disk. +class drawDisk : public drawPRC { +public: + drawDisk(const vm::array& t, const vm::array&p, double opacity, + double shininess) : + drawPRC(t,p,opacity,shininess) {} + + drawDisk(const vm::array& t, const drawDisk *s) : + drawPRC(t,s) {} + + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&); + + drawElement *transformed(const vm::array& t) { + return new drawDisk(t,this); + } +}; + +// Draw a PRC tube. +class drawTube : public drawElement { +protected: + path3 center; + path3 g; + double T[16]; + RGBAColour diffuse; + RGBAColour ambient; + RGBAColour emissive; + RGBAColour specular; + double opacity; + double shininess; + bool invisible; +public: + drawTube(path3 center, path3 g, const vm::array&p, double opacity, + double shininess) : + center(center), g(g), opacity(opacity), shininess(shininess) { + string needfourpens="array of 4 pens required"; + if(checkArray(&p) != 4) + reportError(needfourpens); + + pen surfacepen=vm::read<camp::pen>(p,0); + invisible=surfacepen.invisible(); + + diffuse=rgba(surfacepen); + ambient=rgba(vm::read<camp::pen>(p,1)); + emissive=rgba(vm::read<camp::pen>(p,2)); + specular=rgba(vm::read<camp::pen>(p,3)); + } + + drawTube(const vm::array& t, const drawTube *s) : + center(camp::transformed(t,s->center)), g(camp::transformed(t,s->g)), + diffuse(s->diffuse), ambient(s->ambient), emissive(s->emissive), + specular(s->specular), opacity(s->opacity), + shininess(s->shininess), invisible(s->invisible) { + } + + bool write(prcfile *out, unsigned int *, vm::array *, vm::array *, double, + groupsmap&); + + drawElement *transformed(const vm::array& t) { + return new drawTube(t,this); + } +}; + } #endif diff --git a/Build/source/utils/asymptote/entry.cc b/Build/source/utils/asymptote/entry.cc index 22f973d914f..9871f59766c 100644 --- a/Build/source/utils/asymptote/entry.cc +++ b/Build/source/utils/asymptote/entry.cc @@ -305,7 +305,9 @@ bool venv::add(symbol *src, symbol *dest, ty *venv::getType(symbol *name) { - //cerr << "getType: " << *name << endl; +#if 0 + cout << "getType: " << *name << endl; +#endif types::overloaded set; values &list=names[name]; diff --git a/Build/source/utils/asymptote/entry.h b/Build/source/utils/asymptote/entry.h index 5d02a9c61f2..66d98628d05 100644 --- a/Build/source/utils/asymptote/entry.h +++ b/Build/source/utils/asymptote/entry.h @@ -230,6 +230,13 @@ class venv { key(symbol *name, ty *t) : name(name), t(t) {} + /* A fake key used for searching just based on a signature. */ + key(symbol *name, signature *sig) + : name(name), t(new types::function(types::primError(), sig)) + { + assert(!name->special); + } + key(symbol *name, varEntry *v) : name(name), t(v->getType()) {} }; @@ -342,6 +349,13 @@ public: return lookByType(key(name, t)); } + // An optimization heuristic. Try to guess the signature of a variable and + // look it up. This is allowed to return 0 even if the appropriate variable + // exists. + varEntry *lookBySignature(symbol *name, signature *sig) { + return name->special ? 0 : lookByType(key(name, sig)); + } + ty *getType(symbol *name); void beginScope() { diff --git a/Build/source/utils/asymptote/env.h b/Build/source/utils/asymptote/env.h index 221ff98df81..1d9b2be1166 100644 --- a/Build/source/utils/asymptote/env.h +++ b/Build/source/utils/asymptote/env.h @@ -78,6 +78,11 @@ public: return ve.lookByType(name, t); } + varEntry *lookupVarBySignature(symbol *name, types::signature *sig) + { + return ve.lookBySignature(name, sig); + } + access *lookupInitializer(ty *t) { // The initializer's type is a function returning the desired type. diff --git a/Build/source/utils/asymptote/errors b/Build/source/utils/asymptote/errors index fad3454ce1e..d91b8e7ddb1 100644 --- a/Build/source/utils/asymptote/errors +++ b/Build/source/utils/asymptote/errors @@ -90,3 +90,24 @@ errortest.asy: 411.3: modifying non-public field outside of structure errortest.asy: 412.3: modifying non-public field outside of structure errortest.asy: 413.3: modifying non-public field outside of structure errortest.asy: 414.3: modifying non-public field outside of structure +errortest.asy: 419.7: inferred variable declaration without initializer +errortest.asy: 422.20: cannot cast 'int' to 'var' +errortest.asy: 425.4: cannot cast 'int' to 'var' +errortest.asy: 426.12: cannot cast 'int' to 'var' +errortest.asy: 427.12: cannot cast 'var' to 'int' +errortest.asy: 430.25: cannot cast 'int' to 'var' +errortest.asy: 430.28: cannot cast 'int' to 'var' +errortest.asy: 430.31: cannot cast 'int' to 'var' +errortest.asy: 431.13: cannot cast 'int[]' to 'var[]' +errortest.asy: 432.14: cannot cast 'int' to 'var' +errortest.asy: 432.17: cannot cast 'int' to 'var' +errortest.asy: 432.20: cannot cast 'int' to 'var' +errortest.asy: 433.15: cannot cast 'int' to 'var' +errortest.asy: 433.18: cannot cast 'int' to 'var' +errortest.asy: 433.21: cannot cast 'int' to 'var' +errortest.asy: 434.13: cannot cast 'var[]' to 'int[]' +errortest.asy: 435.3: type 'var' is not a structure +errortest.asy: 438.17: cannot cast 'int' to 'var' +errortest.asy: 442.7: could not infer type of initializer +errortest.asy: 446.7: could not infer type of initializer +errortest.asy: 448.7: could not infer type of initializer diff --git a/Build/source/utils/asymptote/errortest.asy b/Build/source/utils/asymptote/errortest.asy index 500a3972e1f..a3867598bd8 100644 --- a/Build/source/utils/asymptote/errortest.asy +++ b/Build/source/utils/asymptote/errortest.asy @@ -413,3 +413,37 @@ globalwrite=false; globalwrite=true; } + +// Test cases where var is used outside of type inference. +{ + var x; +} +{ + var f() { return 4; } +} +{ + (var)3; + var x = (var)3; + int y = (var)3; +} +{ + var[] b = new var[] { 1, 2, 3}; + var[] b = new int[] { 1, 2, 3}; + var[] c = {1, 2, 3}; + new var[] { 4, 5, 6}; + int[] d = new var[] { 4, 5, 6}; + new var; +} +{ + int f(var x = 3) { return 0; } +} +{ + int f, f(); + var g = f; +} +{ + struct A { int f, f(); } + var g = A.f; + A a; + var h = a.f; +} diff --git a/Build/source/utils/asymptote/examples/100d.views b/Build/source/utils/asymptote/examples/100d.views index b3a1be12936..5e73cb0c8b9 100644 --- a/Build/source/utils/asymptote/examples/100d.views +++ b/Build/source/utils/asymptote/examples/100d.views @@ -1,3 +1,30 @@ -{0 0 -14.425469398498535}{0 0 1}{14.425469398498535}{}{27.905145957890003} -{0.3336401879787445 -0.0024074832908809185 -14.015975952148438}{-0.7636404037475586 -0.17614173889160156 0.6211501359939575}{15.868016873340485}{-58.88738872302071}{27.905145957890003} -[Arbitrary Label]{0.3336401879787445 -0.0024074832908809185 -14.015975952148438}{-0.8299760222434998 0.19688645005226135 -0.5218961238861084}{15.868016035928465}{-94.62674045286937}{27.905145957890003} +VIEW%={View A} + COO=0.000001944790710695088 -0.000000199754154551 -303.740966796875 + C2C=-0.43931567668914795 -0.011656288057565689 0.8982571363449097 + ROO=367.52660744556164 + ROLL=-75.86431813030065 + AAC=34.903342413559436 + BGCOLOR=1. 1. 1. + LIGHTS=Artwork + RENDERMODE=Solid +END +VIEW%={View B} + COO=-52.16141891479492 50.85958480834961 -249.23748779296875 + C2C=-0.0608830563724041 0.722907543182373 -0.6882571578025818 + ROO=117.10558117788756 + ROLL=105.68252665017765 + AAC=34.903342413559436 + BGCOLOR=1. 1. 1. + LIGHTS=Artwork + RENDERMODE=Solid +END +VIEW%={View C} + COO=2.2545230388641357 2.9914066791534424 -300.3456115722656 + C2C=0.8536049127578735 0.3032689690589905 -0.42354053258895874 + ROO=303.7410359852936 + ROLL=-126.08445879535664 + AAC=34.903342413559436 + BGCOLOR=1. 1. 1. + LIGHTS=Artwork + RENDERMODE=Solid +END diff --git a/Build/source/utils/asymptote/examples/BezierSurface.asy b/Build/source/utils/asymptote/examples/BezierSurface.asy index bf386baf7e5..f8cbc458ca0 100644 --- a/Build/source/utils/asymptote/examples/BezierSurface.asy +++ b/Build/source/utils/asymptote/examples/BezierSurface.asy @@ -1,8 +1,13 @@ import three; -string viewpoint="{-24.132780075073242 7.2992024421691895 7.695427417755127}{0.8244762420654297 -0.563306450843811 0.0540805421769619}{35.62141440580922}{17.392748820528627}{}"; +string viewpoint=" +COO=-684.0787963867188 206.90650939941406 218.13809204101562 +C2C=0.8244762420654297 -0.563306450843811 0.0540805421769619 +ROO=1009.7407942621448 +ROLL=17.39344555165265 +"; -//viewpoint=getstring("viewpoint",viewpoint); +// viewpoint=getstring("viewpoint",viewpoint); currentprojection=perspective(viewpoint); triple[][][] P={ diff --git a/Build/source/utils/asymptote/examples/Klein.asy b/Build/source/utils/asymptote/examples/Klein.asy index 0d31c495f01..b2f6d1b0e79 100644 --- a/Build/source/utils/asymptote/examples/Klein.asy +++ b/Build/source/utils/asymptote/examples/Klein.asy @@ -22,7 +22,7 @@ triple f(pair t) { } surface s=surface(f,(0,0),(2pi,2pi),8,8,Spline); -draw(s,lightolive+white); +draw(s,lightolive+white,"bottle"); string lo="$\displaystyle u\in[0,\pi]: \cases{x=3\cos u(1+\sin u)+(2-\cos u)\cos u\cos v,\cr y=8\sin u+(2-\cos u)\sin u\cos v,\cr @@ -34,11 +34,18 @@ z=(2-\cos u)\sin v.\cr}$"; real h=0.0125; -draw(surface(xscale(-0.38)*yscale(-0.18)*lo,s,0,1.7,h,bottom=false)); -draw(surface(xscale(0.26)*yscale(0.1)*rotate(90)*hi,s,4.9,1.4,h,bottom=false)); +begingroup3("parametrization"); +draw(surface(xscale(-0.38)*yscale(-0.18)*lo,s,0,1.7,h,bottom=false), + "[0,pi]"); +draw(surface(xscale(0.26)*yscale(0.1)*rotate(90)*hi,s,4.9,1.4,h,bottom=false), + "[pi,2pi]"); +endgroup3(); + +begingroup3("boundary"); draw(s.uequals(0),blue+dashed); draw(s.uequals(pi),blue+dashed); +endgroup3(); add(new void(frame f, transform3 t, picture pic, projection P) { - draw(f,invert(box(min(f,P),max(f,P)),P)); + draw(f,invert(box(min(f,P),max(f,P)),P),"frame"); }); diff --git a/Build/source/utils/asymptote/examples/NURBSsphere.asy b/Build/source/utils/asymptote/examples/NURBSsphere.asy index d7f0e77321d..5258c9986de 100644 --- a/Build/source/utils/asymptote/examples/NURBSsphere.asy +++ b/Build/source/utils/asymptote/examples/NURBSsphere.asy @@ -1,32 +1,46 @@ import three; -size(400); +/* Reference: +@article{Qin97, + title={{Representing quadric surfaces using NURBS surfaces}}, + author={Qin, K.}, + journal={Journal of Computer Science and Technology}, + volume={12}, + number={3}, + pages={210--216}, + year={1997}, + publisher={Springer} +} +*/ + +size(10cm); currentprojection=perspective(5,4,2,autoadjust=false); -real[] uknot={0,0,0,1,1,2,2,3,3,4,4,4}; - -real[] vknot={0,0,0,1,1,2,2,2}; - -triple[][] P={{(0,0,1),(1,0,1),(1,0,0),(1,0,-1),(0,0,-1)}, - {(0,0,1),(1,1,1),(1,1,0),(1,1,-1),(0,0,-1)}, - {(0,0,1),(0,1,1),(0,1,0),(0,1,-1),(0,0,-1)}, - {(0,0,1),(-1,1,1),(-1,1,0),(-1,1,-1),(0,0,-1)}, - {(0,0,1),(-1,0,1),(-1,0,0),(-1,0,-1),(0,0,-1)}, - {(0,0,1),(-1,-1,1),(-1,-1,0),(-1,-1,-1),(0,0,-1)}, - {(0,0,1),(0,-1,1),(0,-1,0),(0,-1,-1),(0,0,-1)}, - {(0,0,1),(1,-1,1),(1,-1,0),(1,-1,-1),(0,0,-1)}, - {(0,0,1),(1,0,1),(1,0,0),(1,0,-1),(0,0,-1)}}; - -real[][] weights={ - {1,1,2,1,1}, - {1,1,2,1,1}, - {2,2,4,2,2}, - {1,1,2,1,1}, - {1,1,2,1,1}, - {1,1,2,1,1}, - {2,2,4,2,2}, - {1,1,2,1,1}, - {1,1,2,1,1} -}; - -draw(P,uknot,vknot,weights,yellow); +// udegree=2, vdegree=3, nu=3, nv=4; + +real[] W={2/3,1/3,1}; +real[] w={1,1/3,1/3,1}; + +// 10 distinct control points +triple[][] P={{(0,0,1),(-2,-2,1),(-2,-2,-1),(0,0,-1)}, + {(0,0,1),(2,-2,1),(2,-2,-1),(0,0,-1)}, + {(0,0,1),(2,2,1),(2,2,-1),(0,0,-1)}, + {(0,0,1),(-2,2,1),(-2,2,-1),(0,0,-1)}}; + +P.cyclic=true; + +real[][] weights=new real[3][4]; +for(int i=0; i < 3; ++i) +for(int j=0; j < 4; ++j) + weights[i][j]=W[i]*w[j]; + +real[] uknot={0,0,1/3,1/2,1,1}; +real[] vknot={0,0,0,0,1,1,1,1}; + +int N=1; + +for(int k=0; k < N; ++k) +for(int i=0; i < 4; ++i) + draw(shift(k*Z)*P[i:i+3],uknot,vknot,weights,blue); + +// draw(unitsphere,red+opacity(0.1)); diff --git a/Build/source/utils/asymptote/examples/label3zoom.asy b/Build/source/utils/asymptote/examples/label3zoom.asy new file mode 100644 index 00000000000..7eafccd8fcd --- /dev/null +++ b/Build/source/utils/asymptote/examples/label3zoom.asy @@ -0,0 +1,16 @@ +import three; + +currentlight=Headlamp; +size(469.75499pt,0); + +currentprojection=perspective( +camera=(160.119024441391,136.348802919248,253.822628496226), +up=(-0.188035408976828,0.910392236102215,-0.368549401594584), +target=(25.5462739598034,1.77605243766079,-9.93996244768584), +zoom=5.59734733413271, +angle=5.14449021168139, +viewportshift=(0.813449720559684,-0.604674743165144), +autoadjust=false); + +draw(scale3(4)*extrude("$\displaystyle\int\limits_{-\infty}^{+\infty}\!\! e^{-\alpha x^2}\!\!=\sqrt{\frac{\pi}{\alpha}}$",2Z), + material(blue,ambientpen=mediumgray)); diff --git a/Build/source/utils/asymptote/examples/parametricsurface.asy b/Build/source/utils/asymptote/examples/parametricsurface.asy index f78e8470658..de669b59faf 100644 --- a/Build/source/utils/asymptote/examples/parametricsurface.asy +++ b/Build/source/utils/asymptote/examples/parametricsurface.asy @@ -14,10 +14,10 @@ pen p=rgb(0.2,0.5,0.7); surface s=surface(f,(0,0),(2pi,2pi),8,8,Spline); // surface only -draw(s,lightgray); +//draw(s,lightgray); // mesh only // draw(s,nullpen,meshpen=p); // surface & mesh -// draw(s,lightgray,meshpen=p); +draw(s,lightgray,meshpen=p); diff --git a/Build/source/utils/asymptote/examples/pdb.asy b/Build/source/utils/asymptote/examples/pdb.asy index e06b1241bce..b4f9175ae14 100644 --- a/Build/source/utils/asymptote/examples/pdb.asy +++ b/Build/source/utils/asymptote/examples/pdb.asy @@ -9,12 +9,12 @@ bool getviews=true; currentlight=White; //currentlight=nolight; +defaultrender.merge=true; // Fast low-quality rendering +//defaultrender.merge=false; // Slow high-quality rendering + size(200); currentprojection=perspective(30,30,15); -// Uncomment this line for more accurate (but slower) PDF rendering -//dotgranularity=0; - pen chainpen=green; pen hetpen=purple; @@ -121,6 +121,7 @@ while(true) { write("Number of atomic chains: ",chains.length); int natoms; +begingroup3("chained"); for(chain c : chains) { for(int i=0; i < c.a.length-1; ++i) draw(c.a[i].v--c.a[i+1].v,chainpen,currentlight); @@ -128,25 +129,30 @@ for(chain c : chains) { dot(a.v,color(a.name),currentlight); natoms += c.a.length; } +endgroup3(); write("Number of chained atoms: ",natoms); write("Number of hetero atoms: ",atoms.length); +begingroup3("hetero"); for(atom h : atoms) dot(h.v,color(h.name),currentlight); +endgroup3(); write("Number of hetero bonds: ",bonds.length); +begingroup3("bonds"); for(bond b : bonds) { triple v(int i) {return atoms[find(serials == i)].v;} draw(v(b.i)--v(b.j),hetpen,currentlight); } +endgroup3(); string options; string viewfilename=prefix+".views"; if(!error(input(viewfilename,check=false))) - options="3Dviews="+viewfilename; + options="3Dviews2="+viewfilename; if(getviews) { picture pic; @@ -155,3 +161,4 @@ if(getviews) { shipout(prefix,pic,options=options); } else shipout(prefix,options=options); + diff --git a/Build/source/utils/asymptote/examples/pipeintersection.asy b/Build/source/utils/asymptote/examples/pipeintersection.asy index d65b8b562ea..5bf9cfbe6f3 100644 --- a/Build/source/utils/asymptote/examples/pipeintersection.asy +++ b/Build/source/utils/asymptote/examples/pipeintersection.asy @@ -9,4 +9,4 @@ real f(pair z) {return min(sqrt(1-z.x^2),sqrt(1-z.y^2));} surface s=surface(f,(0,0),(1,1),40,Spline); transform3 t=rotate(90,O,Z), t2=t*t, t3=t2*t, i=xscale3(-1)*zscale3(-1); -draw(surface(s,t*s,t2*s,t3*s,i*s,i*t*s,i*t2*s,i*t3*s),blue); +draw(surface(s,t*s,t2*s,t3*s,i*s,i*t*s,i*t2*s,i*t3*s),blue,render(merge=true)); diff --git a/Build/source/utils/asymptote/examples/sphere.asy b/Build/source/utils/asymptote/examples/sphere.asy index 8c5a444d01a..41f3f548895 100644 --- a/Build/source/utils/asymptote/examples/sphere.asy +++ b/Build/source/utils/asymptote/examples/sphere.asy @@ -3,4 +3,4 @@ import three; size(200); currentprojection=orthographic(5,4,3); -draw(unitsphere,green); +draw(unitsphere,green,render(compression=Zero)); diff --git a/Build/source/utils/asymptote/exp.cc b/Build/source/utils/asymptote/exp.cc index e0879665aec..dc9533e2036 100644 --- a/Build/source/utils/asymptote/exp.cc +++ b/Build/source/utils/asymptote/exp.cc @@ -29,10 +29,12 @@ using vm::inst; using mem::vector; +#if 0 void exp::prettyprint(ostream &out, Int indent) { prettyname(out, "exp",indent); } +#endif void exp::transAsType(coenv &e, types::ty *target) { types::ty *t=trans(e); @@ -43,18 +45,22 @@ void exp::transToType(coenv &e, types::ty *target) { types::ty *source=e.e.castSource(target, cgetType(e), symbol::castsym); if (source==0) { - types::ty *sources=cgetType(e); - em.error(getPos()); - em << "cannot cast "; - if (sources->kind==ty_overloaded) - em << "expression"; - else - em << "'" << *sources << "'"; - em << " to '" << *target << "'"; + if (target->kind != ty_error) { + types::ty *sources=cgetType(e); + em.error(getPos()); + em << "cannot cast "; + if (sources->kind==ty_overloaded) + em << "expression"; + else + em << "'" << *sources << "'"; + em << " to '" << *target << "'"; + } } else if (source->kind==ty_overloaded) { - em.error(getPos()); - em << "expression is ambiguous in cast to '" << *target << "'"; + if (target->kind != ty_error) { + em.error(getPos()); + em << "expression is ambiguous in cast to '" << *target << "'"; + } } else { transAsType(e, source); @@ -68,7 +74,7 @@ void exp::testCachedType(coenv &e) { if (!equivalent(t, ct)) { em.compiler(getPos()); em << "cached type '" << *ct - << "' doesn't match actual type '" << *t; + << "' doesn't match actual type '" << *t << "'"; } } } @@ -92,6 +98,10 @@ tempExp::tempExp(coenv &e, varinit *v, types::ty *t) e.c.encode(inst::pop); } +void tempExp::prettyprint(ostream &out, Int indent) { + prettyname(out, "tempExp", indent); +} + types::ty *tempExp::trans(coenv &e) { a->encode(READ, getPos(), e.c); return t; @@ -103,6 +113,10 @@ varEntryExp::varEntryExp(position pos, types::ty *t, access *a) varEntryExp::varEntryExp(position pos, types::ty *t, vm::bltin f) : exp(pos), v(new trans::varEntry(t, new bltinAccess(f), 0, position())) {} +void varEntryExp::prettyprint(ostream &out, Int indent) { + prettyname(out, "varEntryExp", indent); +} + types::ty *varEntryExp::getType(coenv &) { return v->getType(); } @@ -536,16 +550,22 @@ void callExp::prettyprint(ostream &out, Int indent) args->prettyprint(out, indent+1); } -signature *callExp::argTypes(coenv &e) +signature *callExp::argTypes(coenv &e, bool *searchable) { signature *source=new signature; + // The signature is searchable unless one of the arguments is overloaded or + // named. + *searchable = true; + size_t n = args->size(); for (size_t i = 0; i < n; i++) { argument a=(*args)[i]; types::ty *t = a.val->cgetType(e); if (t->kind == types::ty_error) return 0; + if (t->kind == types::ty_overloaded || a.name) + *searchable = false; source->add(types::formal(t,a.name)); } @@ -554,6 +574,8 @@ signature *callExp::argTypes(coenv &e) types::ty *t = a.val->cgetType(e); if (t->kind == types::ty_error) return 0; + if (t->kind == types::ty_overloaded || a.name) + *searchable = false; source->addRest(types::formal(t,a.name)); } @@ -607,8 +629,9 @@ bool hasNamedParameters(signature *sig) { return false; } -void callExp::reportMismatch(symbol *s, function *ft, signature *source) +void callExp::reportMismatch(function *ft, signature *source) { + symbol *s = callee->getName(); const char *separator=ft->getSignature()->getNumFormals() > 1 ? "\n" : " "; em.error(getPos()); @@ -643,44 +666,124 @@ void callExp::reportArgErrors(coenv &e) args->rest.val->trans(e); } -application *callExp::getApplication(coenv &e) +void callExp::reportNonFunction() { + em.error(getPos()); + symbol *s = callee->getName(); + if (s) + em << "\'" << *s << "\' is not a function"; + else + em << "called expression is not a function"; +} + +void callExp::cacheAppOrVarEntry(coenv &e, bool tacit) { + assert(cachedVarEntry == 0 && cachedApp == 0); + // First figure out the signature of what we want to call. - signature *source=argTypes(e); + bool searchable; + signature *source=argTypes(e, &searchable); - if (!source) - return 0; +#ifdef DEBUG_GETAPP /* {{{ */ + cout << "getApp for "; + if (callee->getName()) + cout << *callee->getName(); + else + cout << "unnamed"; + cout << " at " << getPos() << endl; + cout << "searchable: " << searchable << endl; +#endif /* }}} */ + + if (!source) { + ct = primError(); + return; + } + + // An attempt at speeding up compilation: See if the source arguments match + // the (possibly overloaded) function exactly. +#if 0 + if (searchable) { + varEntry *ve = callee->getCallee(e, source); + +#ifdef DEBUG_GETAPP + cout << "guessed: " << (ve!=0) << endl; +#endif + + if (ve) { +#if 0 + cachedApp = application::match(e.e, + (function *)ve->getType(), source, *args); +#endif + cachedVarEntry = ve; + ct = ((function *)ve->getType())->getResult(); + return; + } + } +#endif // Figure out what function types we can call. - trans::ty *ft = callee->cgetType(e); + types::ty *ft = callee->cgetType(e); + +#ifdef DEBUG_GETAPP + string name = callee->getName() ? string(*callee->getName()) : string("unnamed"); + if (!callee->getName()) + cout << getPos() << endl; +#endif + switch (ft->kind) { case ty_error: - // Report callee errors. - //cerr << "reporting callee errors\n"; - callee->trans(e); - return 0; - case ty_function: { - application *a=application::match(e.e, (function *)ft, source, *args); - if (!a) { - //cerr << "reporting mismatch\n"; - reportMismatch(callee->getName(), (function *)ft, source); - } - //cerr << "returning function\n"; - return a; - } - case ty_overloaded: - //cerr << "resolving overloaded\n"; - return resolve(e, (overloaded *)ft, source, false); + if (!tacit) + // Report callee errors. + callee->trans(e); + break; + + case ty_function: + //cout << "name " << name << endl; + cachedApp = application::match(e.e, (function *)ft, source, *args); + if (!cachedApp && !tacit) + reportMismatch((function *)ft, source); + break; + + case ty_overloaded: { +#ifdef DEBUG_GETAPP + int size = ((overloaded *)ft)->sub.size(); + for (int i = 0; i < size; ++i) cout << "name " << name << endl; +#endif + cachedApp = resolve(e, (overloaded *)ft, source, tacit); + break; + } + default: - //cerr << "not a function\n"; - em.error(getPos()); - symbol *s = callee->getName(); - if (s) - em << "\'" << *s << "\' is not a function"; - else - em << "called expression is not a function"; - return 0; + if (!tacit) + reportNonFunction(); + break; } + +#ifdef DEBUG_GETAPP + cout << name << " " << *source << " --> " + << *cachedApp->getType()->getSignature() << endl; +#endif + + // Get type relies on this method setting the cached type. + ct = cachedApp ? cachedApp->getType()->getResult() : primError(); +} + +types::ty *callExp::transPerfectMatch(coenv &e) { + // The varEntry of the callee. (No longer needed after translation.) + varEntry *ve = cachedVarEntry; + cachedVarEntry = 0; + assert(ve); + + // Translate the arguments in turn. + for (size_t i = 0; i < args->size(); ++i) + (*args)[i].val->trans(e); + if (args->rest.val) + args->rest.val->trans(e); + + // Call the function. + ve->encode(CALL, getPos(), e.c); + + // That's it. Return the cached type. + return ct; } types::ty *callExp::trans(coenv &e) @@ -692,15 +795,16 @@ types::ty *callExp::trans(coenv &e) cerr << endl; #endif -#ifdef DEBUG_CACHE - if (ca) - assert(equivalent(ca->getType(), getApplication(e)->getType())); -#endif - application *a= ca ? ca : getApplication(e); - - // The cached application is no longer needed after translation, so - // let it be garbage collected. - ca=0; + if (cachedVarEntry == 0 && cachedApp == 0) + cacheAppOrVarEntry(e, false); + + if (cachedVarEntry) + return transPerfectMatch(e); + + // The cached data is no longer needed after translation, so let it be + // garbage collected. + application *a = cachedApp; + cachedApp=0; if (!a) { reportArgErrors(e); @@ -720,12 +824,20 @@ types::ty *callExp::trans(coenv &e) // Translate the call. temp->transCall(e, t); - assert(ct==0 || equivalent(ct, t->result)); - return t->result; + assert(equivalent(ct, t->result)); + return ct; } types::ty *callExp::getType(coenv &e) { + if (cachedApp == 0 && cachedVarEntry == 0) + /* This sets ct, the cached return type of the call. */ + cacheAppOrVarEntry(e, true); + + assert(ct); + return ct; + +#if 0 // First figure out the signature of what we want to call. signature *source=argTypes(e); if (!source) @@ -750,6 +862,7 @@ types::ty *callExp::getType(coenv &e) default: return primError(); } +#endif } void pairExp::prettyprint(ostream &out, Int indent) diff --git a/Build/source/utils/asymptote/exp.h b/Build/source/utils/asymptote/exp.h index 3e9eca84ba8..425bcc91788 100644 --- a/Build/source/utils/asymptote/exp.h +++ b/Build/source/utils/asymptote/exp.h @@ -39,7 +39,7 @@ public: exp(position pos) : varinit(pos), ct(0) {} - void prettyprint(ostream &out, Int indent); + void prettyprint(ostream &out, Int indent) = 0; // When reporting errors with function calls, it is nice to say "no // function f(int)" instead of "no function matching signature @@ -101,6 +101,17 @@ public: // error. virtual types::ty *getType(coenv &) = 0; + // TODO: Explain what this is! + virtual trans::varEntry *getCallee(coenv &e, types::signature *sig) { +//#define DEBUG_GETAPP +#if DEBUG_GETAPP + cout << "exp fail" << endl; + cout << "at " << getPos() << endl; + prettyprint(cout, 2); +#endif + return 0; + } + // Same result as getType, but caches the result so that subsequent // calls are faster. For this to work correctly, the expression should // only be used in one place, so the environment doesn't change between @@ -156,6 +167,8 @@ class tempExp : public exp { public: tempExp(coenv &e, varinit *v, types::ty *t); + void prettyprint(ostream &out, Int indent); + types::ty *trans(coenv &e); types::ty *getType(coenv &) { @@ -172,6 +185,8 @@ public: varEntryExp(position pos, types::ty *t, access *a); varEntryExp(position pos, types::ty *t, vm::bltin f); + void prettyprint(ostream &out, Int indent); + types::ty *getType(coenv &); types::ty *trans(coenv &e); @@ -234,6 +249,13 @@ public: return t ? t : types::primError(); } + trans::varEntry *getCallee(coenv &e, types::signature *sig) { +#ifdef DEBUG_GETAPP + cout << "nameExp" << endl; +#endif + return value->getCallee(e, sig); + } + void transWrite(coenv &e, types::ty *target) { value->varTrans(trans::WRITE, e, target); @@ -276,6 +298,12 @@ class fieldExp : public nameExp { types::ty *varGetType(coenv &e) { return object->getType(e); } + trans::varEntry *getCallee(coenv &, types::signature *) { +#ifdef DEBUG_GETAPP + cout << "pseudoName" << endl; +#endif + return 0; + } // As a type: types::ty *typeTrans(coenv &, bool tacit = false) { @@ -425,6 +453,11 @@ public: types::ty *trans(coenv &e); types::ty *getType(coenv &e); + + exp *evaluate(coenv &, types::ty *) { + // this has no side-effects + return this; + } }; class literalExp : public exp { @@ -433,6 +466,11 @@ public: : exp(pos) {} bool scalable() { return false; } + + exp *evaluate(coenv &, types::ty *) { + // Literals are constant, they have no side-effects. + return this; + } }; class intExp : public literalExp { @@ -643,9 +681,13 @@ protected: private: // Per object caching - Cache the application when it's determined. - application *ca; + application *cachedApp; + + // In special cases, no application object is needed and we can store the + // varEntry used in advance. + trans::varEntry *cachedVarEntry; - types::signature *argTypes(coenv& e); + types::signature *argTypes(coenv& e, bool *searchable); void reportArgErrors(coenv &e); application *resolve(coenv &e, types::overloaded *o, @@ -655,31 +697,42 @@ private: types::overloaded *o, types::signature *source, bool tacit); - void reportMismatch(symbol *s, - types::function *ft, + void reportMismatch(types::function *ft, types::signature *source); - application *getApplication(coenv &e); + void reportNonFunction(); + + // Caches either the application object used to apply the function to the + // arguments, or in special cases where the arguments match the function + // perfectly, the varEntry of the callee. + void cacheAppOrVarEntry(coenv &e, bool tacit); + + types::ty *transPerfectMatch(coenv &e); public: callExp(position pos, exp *callee, arglist *args) - : exp(pos), callee(callee), args(args), ca(0) { assert(args); } + : exp(pos), callee(callee), args(args), + cachedApp(0), cachedVarEntry(0) { assert(args); } callExp(position pos, exp *callee) - : exp(pos), callee(callee), args(new arglist()), ca(0) {} + : exp(pos), callee(callee), args(new arglist()), + cachedApp(0), cachedVarEntry(0) {} callExp(position pos, exp *callee, exp *arg1) - : exp(pos), callee(callee), args(new arglist()), ca(0) { + : exp(pos), callee(callee), args(new arglist()), + cachedApp(0), cachedVarEntry(0) { args->add(arg1); } callExp(position pos, exp *callee, exp *arg1, exp *arg2) - : exp(pos), callee(callee), args(new arglist()), ca(0) { + : exp(pos), callee(callee), args(new arglist()), + cachedApp(0), cachedVarEntry(0) { args->add(arg1); args->add(arg2); } callExp(position pos, exp *callee, exp *arg1, exp *arg2, exp *arg3) - : exp(pos), callee(callee), args(new arglist()), ca(0) { + : exp(pos), callee(callee), args(new arglist()), + cachedApp(0), cachedVarEntry(0) { args->add(arg1); args->add(arg2); args->add(arg3); @@ -691,6 +744,7 @@ public: types::ty *getType(coenv &e); }; + class pairExp : public exp { exp *x; exp *y; diff --git a/Build/source/utils/asymptote/fftw++.cc b/Build/source/utils/asymptote/fftw++.cc index df4ecaeb4c4..00a24b4c8bd 100644 --- a/Build/source/utils/asymptote/fftw++.cc +++ b/Build/source/utils/asymptote/fftw++.cc @@ -5,12 +5,17 @@ #ifdef HAVE_LIBFFTW3 #include "fftw++.h" +namespace fftwpp { + std::ifstream fftw::ifWisdom; std::ofstream fftw::ofWisdom; bool fftw::Wise=false; +const double fftw::twopi=2.0*acos(-1.0); // User settings: -unsigned int fftw::effort=FFTW_PATIENT; +unsigned int fftw::effort=FFTW_MEASURE; const char *fftw::WisdomName=".wisdom"; +} + #endif diff --git a/Build/source/utils/asymptote/fftw++.h b/Build/source/utils/asymptote/fftw++.h index 658768551be..1b4373a08b6 100644 --- a/Build/source/utils/asymptote/fftw++.h +++ b/Build/source/utils/asymptote/fftw++.h @@ -18,7 +18,7 @@ #ifndef __fftwpp_h__ #define __fftwpp_h__ 1 -#define __FFTWPP_H_VERSION__ 1.05 +#define __FFTWPP_H_VERSION__ 1.08svn #include <cstdlib> #include <fstream> @@ -31,10 +31,6 @@ typedef std::complex<double> Complex; #endif -#ifndef M_PI -#define M_PI acos(-1.0) -#endif - #ifndef HAVE_POSIX_MEMALIGN #ifdef __GLIBC_PREREQ @@ -50,17 +46,12 @@ typedef std::complex<double> Complex; #endif #ifdef __Array_h__ -using Array::array1; -using Array::array2; -using Array::array3; - -static array1<Complex> NULL1; -static array2<Complex> NULL2; -static array3<Complex> NULL3; -static array1<double> NULL1D; -static array2<double> NULL2D; -static array3<double> NULL3D; +namespace Array { +static const array1<Complex> NULL1; +static const array2<Complex> NULL2; +static const array3<Complex> NULL3; +} #else @@ -69,6 +60,8 @@ static array3<double> NULL3D; extern "C" int posix_memalign(void **memptr, size_t alignment, size_t size); #endif #else +namespace Array { + // Adapted from FFTW aligned malloc/free. Assumes that malloc is at least // sizeof(void*)-aligned. Allocated memory must be freed with free0. inline int posix_memalign0(void **memptr, size_t alignment, size_t size) @@ -87,8 +80,12 @@ inline void free0(void *p) { if(p) free(*((void **) p-1)); } + +} #endif +namespace Array { + template<class T> inline void newAlign(T *&v, size_t len, size_t align) { @@ -117,20 +114,23 @@ inline void deleteAlign(T *v, size_t len) free0(v); #endif } +} #endif +namespace fftwpp { + inline Complex *ComplexAlign(size_t size) { Complex *v; - newAlign(v,size,sizeof(Complex)); + Array::newAlign(v,size,sizeof(Complex)); return v; } inline double *doubleAlign(size_t size) { double *v; - newAlign(v,size,sizeof(Complex)); + Array::newAlign(v,size,sizeof(Complex)); return v; } @@ -140,7 +140,7 @@ inline void deleteAlign(T *p) #ifdef HAVE_POSIX_MEMALIGN free(p); #else - free0(p); + Array::free0(p); #endif } @@ -193,6 +193,7 @@ protected: static std::ifstream ifWisdom; static std::ofstream ofWisdom; static bool Wise; + static const double twopi; public: // Shift the Fourier origin to (nx/2,0). @@ -208,7 +209,7 @@ public: } else { if(sign) { unsigned int c=nx/2; - double arg=2.0*M_PI*c/nx; + double arg=twopi*c/nx; for(unsigned int i=0; i < nx; i++) { double iarg=i*arg; Complex zeta(cos(iarg),sign*sin(iarg)); @@ -243,9 +244,8 @@ public: } else { if(sign) { unsigned int cx=nx/2; - unsigned int cy=ny/2; - double twopi=2.0*M_PI; double argx=twopi*cx/nx; + unsigned int cy=ny/2; double argy=twopi*cy/ny; for(unsigned i=0; i < nx; i++) { double iarg=i*argx; @@ -302,7 +302,7 @@ public: exit(1); } - if(alloc) deleteAlign(in,(doubles+1)/2); + if(alloc) Array::deleteAlign(in,(doubles+1)/2); SaveWisdom(); } @@ -326,7 +326,7 @@ public: fftw_execute_dft(plan,(fftw_complex *) in,(fftw_complex *) out); } - void Setout(Complex *in, Complex *&out) { + Complex *Setout(Complex *in, Complex *out) { #ifndef NO_CHECK_ALIGN CheckAlign(in,"input"); if(out) CheckAlign(out,"output"); @@ -338,10 +338,11 @@ public: std::cerr << "ERROR: fft constructor and call must be both in place or both out of place" << std::endl; exit(1); } + return out; } void fft(Complex *in, Complex *out=NULL) { - Setout(in,out); + out=Setout(in,out); Execute(in,out); } @@ -354,7 +355,7 @@ public: } void fft0(Complex *in, Complex *out=NULL) { - Setout(in,out); + out=Setout(in,out); Execute(in,out,true); } @@ -376,13 +377,15 @@ public: } virtual void fftNormalized(Complex *in, Complex *out=NULL) { - Setout(in,out); + out=Setout(in,out); Execute(in,out); Normalize(out); } void fftNormalized(Complex *in, double *out) { - fftNormalized(in,(Complex *) out); + out=(double *) Setout(in,(Complex *) out); + Execute(in,(Complex *) out); + Normalize(out); } void fftNormalized(double *in, Complex *out) { @@ -390,13 +393,15 @@ public: } void fft0Normalized(Complex *in, Complex *out=NULL) { - Setout(in,out); + out=Setout(in,out); Execute(in,out,true); Normalize(out); } void fft0Normalized(Complex *in, double *out) { - fft0Normalized(in,(Complex *) out); + out=(double *) Setout(in,(Complex *) out); + Execute(in,(Complex *) out,true); + Normalize(out); } void fft0Normalized(double *in, Complex *out) { @@ -404,14 +409,14 @@ public: } void fftNormalized(Complex *in, Complex *out, - unsigned int nx, unsigned int m, + unsigned int nx, unsigned int M, unsigned int stride, unsigned int dist) { if(stride == 1 && dist == nx) fftw::fftNormalized(in,out); else if(stride == nx && dist == 1) fftw::fftNormalized(in,out); else { - Setout(in,out); + out=Setout(in,out); Execute(in,out); - for(unsigned int k=0; k < m; k++) { + for(unsigned int k=0; k < M; k++) { for(unsigned int j=0; j < nx; j++) { out[j*stride+k*dist] *= norm; } @@ -451,7 +456,8 @@ public: : fftw(2*nx,sign), nx(nx) {Setup(in,out);} #ifdef __Array_h__ - fft1d(int sign, const array1<Complex>& in, const array1<Complex>& out=NULL1) + fft1d(int sign, const Array::array1<Complex>& in, + const Array::array1<Complex>& out=Array::NULL1) : fftw(2*in.Nx(),sign), nx(in.Nx()) {Setup(in,out);} #endif @@ -461,19 +467,19 @@ public: } }; -// Compute the complex Fourier transform of m complex vectors, each of +// Compute the complex Fourier transform of M complex vectors, each of // length n. // Before calling fft(), the arrays in and out (which may coincide) must be -// allocated as Complex[m*n]. +// allocated as Complex[M*n]. // // Out-of-place usage: // -// mfft1d Forward(n,-1,m,stride,dist,in,out); +// mfft1d Forward(n,-1,M,stride,dist,in,out); // Forward.fft(in,out); // // In-place usage: // -// mfft1d Forward(n,-1,m,stride,dist); +// mfft1d Forward(n,-1,M,stride,dist); // Forward.fft(in); // // Notes: @@ -483,26 +489,26 @@ public: // class mfft1d : public fftw { unsigned int nx; - unsigned int m; + unsigned int M; unsigned int stride; unsigned int dist; public: - mfft1d(unsigned int nx, int sign, unsigned int m=1, unsigned int stride=1, + mfft1d(unsigned int nx, int sign, unsigned int M=1, unsigned int stride=1, unsigned int dist=0, Complex *in=NULL, Complex *out=NULL) - : fftw(2*((nx-1)*stride+(m-1)*Dist(nx,stride,dist)+1),sign,nx), - nx(nx), m(m), stride(stride), dist(Dist(nx,stride,dist)) + : fftw(2*((nx-1)*stride+(M-1)*Dist(nx,stride,dist)+1),sign,nx), + nx(nx), M(M), stride(stride), dist(Dist(nx,stride,dist)) {Setup(in,out);} fftw_plan Plan(Complex *in, Complex *out) { int n[1]={nx}; - return fftw_plan_many_dft(1,n,m, + return fftw_plan_many_dft(1,n,M, (fftw_complex *) in,NULL,stride,dist, (fftw_complex *) out,NULL,stride,dist, sign,effort); } void fftNormalized(Complex *in, Complex *out=NULL) { - fftw::fftNormalized(in,out,nx,m,stride,dist); + fftw::fftNormalized(in,out,nx,M,stride,dist); } }; @@ -535,11 +541,11 @@ public: : fftw(realsize(nx,in,out),-1,nx), nx(nx) {Setup(in,out);} #ifdef __Array_h__ - rcfft1d(unsigned int nx, const array1<Complex>& out) + rcfft1d(unsigned int nx, const Array::array1<Complex>& out) : fftw(out.Size(),-1,nx), nx(nx) {Setup(out);} - rcfft1d(unsigned int nx, const array1<double>& in, - const array1<Complex>& out=NULL1) + rcfft1d(unsigned int nx, const Array::array1<double>& in, + const Array::array1<Complex>& out=Array::NULL1) : fftw(realsize(nx,in(),out()),-1,nx), nx(nx) {Setup(in,out);} #endif @@ -583,12 +589,15 @@ public: : fftw(realsize(nx,in,out),1,nx), nx(nx) {Setup(in,out);} #ifdef __Array_h__ - crfft1d(unsigned int nx, const array1<double>& out) + crfft1d(unsigned int nx, const Array::array1<double>& out) : fftw(out.Size(),1,nx), nx(nx) {Setup(out);} - crfft1d(unsigned int nx, const array1<Complex>& in, - const array1<double>& out=NULL1D) - : fftw(2*in.Size(),1,nx), nx(nx) {Setup(in,out);} + crfft1d(unsigned int nx, const Array::array1<Complex>& in) + : fftw(2*in.Size(),1,nx), nx(nx) {Setup(in);} + + crfft1d(unsigned int nx, const Array::array1<Complex>& in, + const Array::array1<double>& out) + : fftw(out.Size(),1,nx), nx(nx) {Setup(in,out);} #endif fftw_plan Plan(Complex *in, Complex *out) { @@ -600,20 +609,20 @@ public: } }; -// Compute the real Fourier transform of m real vectors, each of length n, +// Compute the real Fourier transform of M real vectors, each of length n, // using phase sign -1. Before calling fft(), the array in must be -// allocated as double[m*n] and the array out must be allocated as -// Complex[m*(n/2+1)]. The arrays in and out may coincide, -// allocated as Complex[m*(n/2+1)]. +// allocated as double[M*n] and the array out must be allocated as +// Complex[M*(n/2+1)]. The arrays in and out may coincide, +// allocated as Complex[M*(n/2+1)]. // // Out-of-place usage: // -// mrcfft1d Forward(n,m,stride,dist,in,out); +// mrcfft1d Forward(n,M,stride,dist,in,out); // Forward.fft(in,out); // // In-place usage: // -// mrcfft1d Forward(n,m,stride,dist); +// mrcfft1d Forward(n,M,stride,dist); // Forward.fft(out); // // Notes: @@ -624,23 +633,23 @@ public: // class mrcfft1d : public fftw { unsigned int nx; - unsigned int m; + unsigned int M; unsigned int stride; unsigned int dist; public: - mrcfft1d(unsigned int nx, unsigned int m=1, unsigned int stride=1, + mrcfft1d(unsigned int nx, unsigned int M=1, unsigned int stride=1, unsigned int dist=0, Complex *out=NULL) - : fftw(2*(nx/2*stride+(m-1)*Dist(nx,stride,dist)+1),-1,nx), nx(nx), m(m), + : fftw(2*(nx/2*stride+(M-1)*Dist(nx,stride,dist)+1),-1,nx), nx(nx), M(M), stride(stride), dist(Dist(nx,stride,dist)) {Setup(out);} - mrcfft1d(unsigned int nx, unsigned int m=1, unsigned int stride=1, + mrcfft1d(unsigned int nx, unsigned int M=1, unsigned int stride=1, unsigned int dist=0, double *in=NULL, Complex *out=NULL) - : fftw(2*(nx/2*stride+(m-1)*Dist(nx,stride,dist)+1),-1,nx), nx(nx), m(m), + : fftw(2*(nx/2*stride+(M-1)*Dist(nx,stride,dist)+1),-1,nx), nx(nx), M(M), stride(stride), dist(Dist(nx,stride,dist)) {Setup(in,out);} fftw_plan Plan(Complex *in, Complex *out) { const int n[1]={nx}; - return fftw_plan_many_dft_r2c(1,n,m, + return fftw_plan_many_dft_r2c(1,n,M, (double *) in,NULL,stride,2*dist, (fftw_complex *) out,NULL,stride,dist, effort); @@ -651,25 +660,25 @@ public: } void fftNormalized(Complex *in, Complex *out=NULL) { - fftw::fftNormalized(in,out,nx/2+1,m,stride,dist); + fftw::fftNormalized(in,out,nx/2+1,M,stride,dist); } }; -// Compute the real inverse Fourier transform of m complex vectors, each of +// Compute the real inverse Fourier transform of M complex vectors, each of // length n/2+1, corresponding to the non-negative parts of the frequency // spectra, using phase sign +1. Before calling fft(), the array in must be -// allocated as Complex[m*(n/2+1)] and the array out must be allocated as -// double[m*n]. The arrays in and out may coincide, -// allocated as Complex[m*(n/2+1)]. +// allocated as Complex[M*(n/2+1)] and the array out must be allocated as +// double[M*n]. The arrays in and out may coincide, +// allocated as Complex[M*(n/2+1)]. // // Out-of-place usage (input destroyed): // -// mcrfft1d Backward(n,m,stride,dist,in,out); +// mcrfft1d Backward(n,M,stride,dist,in,out); // Backward.fft(in,out); // // In-place usage: // -// mcrfft1d Backward(n,m,stride,dist); +// mcrfft1d Backward(n,M,stride,dist); // Backward.fft(out); // // Notes: @@ -680,18 +689,18 @@ public: // class mcrfft1d : public fftw { unsigned int nx; - unsigned int m; + unsigned int M; unsigned int stride; unsigned int dist; public: - mcrfft1d(unsigned int nx, unsigned int m=1, unsigned int stride=1, + mcrfft1d(unsigned int nx, unsigned int M=1, unsigned int stride=1, unsigned int dist=0, Complex *in=NULL, double *out=NULL) - : fftw((realsize(nx,in,out)-2)*stride+2*(m-1)*Dist(nx,stride,dist)+2,1,nx), - nx(nx), m(m), stride(stride), dist(Dist(nx,stride,dist)) {Setup(in,out);} + : fftw((realsize(nx,in,out)-2)*stride+2*(M-1)*Dist(nx,stride,dist)+2,1,nx), + nx(nx), M(M), stride(stride), dist(Dist(nx,stride,dist)) {Setup(in,out);} fftw_plan Plan(Complex *in, Complex *out) { const int n[1]={nx}; - return fftw_plan_many_dft_c2r(1,n,m, + return fftw_plan_many_dft_c2r(1,n,M, (fftw_complex *) in,NULL,stride,dist, (double *) out,NULL,stride,2*dist, effort); @@ -702,7 +711,7 @@ public: } void fftNormalized(Complex *in, Complex *out=NULL) { - fftw::fftNormalized(in,out,(nx/2+1),m,stride,dist); + fftw::fftNormalized(in,out,(nx/2+1),M,stride,dist); } }; @@ -741,7 +750,8 @@ public: : fftw(2*nx*ny,sign), nx(nx), ny(ny) {Setup(in,out);} #ifdef __Array_h__ - fft2d(int sign, const array2<Complex>& in, const array2<Complex>& out=NULL2) + fft2d(int sign, const Array::array2<Complex>& in, + const Array::array2<Complex>& out=Array::NULL2) : fftw(2*in.Size(),sign), nx(in.Nx()), ny(in.Ny()) {Setup(in,out);} #endif @@ -787,11 +797,11 @@ public: : fftw(nx*realsize(ny,in,out),-1,nx*ny), nx(nx), ny(ny) {Setup(in,out);} #ifdef __Array_h__ - rcfft2d(unsigned int ny, const array2<Complex>& out) + rcfft2d(unsigned int ny, const Array::array2<Complex>& out) : fftw(out.Size(),-1,out.Nx()*ny), nx(out.Nx()), ny(ny) {Setup(out);} - rcfft2d(unsigned int ny, const array2<double>& in, - const array2<Complex>& out=NULL2) + rcfft2d(unsigned int ny, const Array::array2<double>& in, + const Array::array2<Complex>& out=Array::NULL2) : fftw(in.Nx()*realsize(ny,in(),out()),-1,in.Nx()*ny), nx(in.Nx()), ny(ny) {Setup(in,out);} #endif @@ -842,12 +852,15 @@ public: fftw(nx*realsize(ny,in,out),1,nx*ny), nx(nx), ny(ny) {Setup(in,out);} #ifdef __Array_h__ - crfft2d(unsigned int ny, const array2<double>& out) + crfft2d(unsigned int ny, const Array::array2<double>& out) : fftw(out.Size(),1,out.Nx()*ny), nx(out.Nx()), ny(ny) {Setup(out);} - crfft2d(unsigned int ny, const array2<Complex>& in, - const array2<double>& out=NULL2D) - : fftw(2*in.Size(),1,in.Nx()*ny), nx(in.Nx()), ny(ny) {Setup(in,out);} + crfft2d(unsigned int ny, const Array::array2<Complex>& in) + : fftw(2*in.Size(),1,in.Nx()*ny), nx(in.Nx()), ny(ny) {Setup(in);} + + crfft2d(unsigned int ny, const Array::array2<Complex>& in, + const Array::array2<double>& out) + : fftw(out.Size(),1,in.Nx()*ny), nx(in.Nx()), ny(ny) {Setup(in,out);} #endif fftw_plan Plan(Complex *in, Complex *out) { @@ -898,7 +911,8 @@ public: : fftw(2*nx*ny*nz,sign), nx(nx), ny(ny), nz(nz) {Setup(in,out);} #ifdef __Array_h__ - fft3d(int sign, const array3<Complex>& in, const array3<Complex>& out=NULL3) + fft3d(int sign, const Array::array3<Complex>& in, + const Array::array3<Complex>& out=Array::NULL3) : fftw(2*in.Size(),sign), nx(in.Nx()), ny(in.Ny()), nz(in.Nz()) {Setup(in,out);} #endif @@ -943,12 +957,12 @@ public: nx(nx), ny(ny), nz(nz) {Setup(in,out);} #ifdef __Array_h__ - rcfft3d(unsigned int nz, const array3<Complex>& out) + rcfft3d(unsigned int nz, const Array::array3<Complex>& out) : fftw(out.Size(),-1,out.Nx()*out.Ny()*nz), nx(out.Nx()), ny(out.Ny()), nz(nz) {Setup(out);} - rcfft3d(unsigned int nz, const array3<double>& in, - const array3<Complex>& out=NULL3) + rcfft3d(unsigned int nz, const Array::array3<double>& in, + const Array::array3<Complex>& out=Array::NULL3) : fftw(in.Nx()*in.Ny()*realsize(nz,in(),out()),-1,in.Size()), nx(in.Nx()), ny(in.Ny()), nz(nz) {Setup(in,out);} #endif @@ -1001,15 +1015,20 @@ public: double *out=NULL) : fftw(nx*ny*(realsize(nz,in,out)),1,nx*ny*nz), nx(nx), ny(ny), nz(nz) {Setup(in,out);} + #ifdef __Array_h__ - crfft3d(unsigned int nz, const array3<double>& out) : - fftw(out.Size(),1,out.Nx()*out.Ny()*nz), + crfft3d(unsigned int nz, const Array::array3<double>& out) + : fftw(out.Size(),1,out.Nx()*out.Ny()*nz), nx(out.Nx()), ny(out.Ny()), nz(nz) {Setup(out);} - crfft3d(unsigned int nz, const array3<Complex>& in, - const array3<double>& out=NULL3D) : - fftw(2*in.Size(),1,in.Nx()*in.Ny()*nz), - nx(in.Nx()), ny(in.Ny()), nz(nz) {Setup(in,out);} + crfft3d(unsigned int nz, const Array::array3<Complex>& in) + : fftw(2*in.Size(),1,in.Nx()*in.Ny()*nz), + nx(in.Nx()), ny(in.Ny()), nz(nz) {Setup(in);} + + crfft3d(unsigned int nz, const Array::array3<Complex>& in, + const Array::array3<double>& out) + : fftw(out.Size(),1,in.Nx()*in.Ny()*nz), + nx(in.Nx()), ny(in.Ny()), nz(nz) {Setup(in,out);} #endif fftw_plan Plan(Complex *in, Complex *out) { @@ -1023,4 +1042,6 @@ public: } }; +} + #endif diff --git a/Build/source/utils/asymptote/findsym.pl b/Build/source/utils/asymptote/findsym.pl new file mode 100644 index 00000000000..38c3865a7af --- /dev/null +++ b/Build/source/utils/asymptote/findsym.pl @@ -0,0 +1,57 @@ +#!/usr/bin/env perl +##### +# findsym.pl +# Andy Hammerlindl 2010/06/01 +# +# Extract static symbols used in builtin.cc and write code so that they are +# translated only once when creating the symbol table. +##### + +$outname = shift(@ARGV); +if (not $outname) { + print STDERR "usage ./findsym.pl out_symbols.h file1.cc file2.cc ...\n"; + exit(1); +} + +open(header, ">$outname") || + die("Couldn't open $outname for writing"); + +print header <<END; +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +END + +sub add { + print header "ADDSYMBOL(".$_[0].");\n"; +} + +my %symbols = (); + +foreach my $inname (@ARGV) { + open(infile, $inname) || + die("Couldn't open $inname"); + while (<infile>) { + while (m/SYM\(([_A-Za-z][_A-Za-z0-9]*)\)/gx) { + $symbols{ $1 } = 1; + } + } +} + +foreach my $s (sort keys %symbols) { + add($s); +} diff --git a/Build/source/utils/asymptote/fundec.cc b/Build/source/utils/asymptote/fundec.cc index 232b7550bb7..07369c7e1c5 100644 --- a/Build/source/utils/asymptote/fundec.cc +++ b/Build/source/utils/asymptote/fundec.cc @@ -116,6 +116,10 @@ public: basicAssignExp(position pos, exp *dest, varinit *value) : exp(pos), dest(dest), value(value) {} + void prettyprint(ostream &out, Int indent) { + prettyname(out, "basicAssignExp", indent); + } + types::ty *getType(coenv &e) { return dest->getType(e); } diff --git a/Build/source/utils/asymptote/glrender.cc b/Build/source/utils/asymptote/glrender.cc index 41c2f66c0c9..ce7554e39f5 100644 --- a/Build/source/utils/asymptote/glrender.cc +++ b/Build/source/utils/asymptote/glrender.cc @@ -98,8 +98,9 @@ double Xfactor,Yfactor; int minimumsize=50; // Minimum initial rendering window width and height -const double degrees=180.0/M_PI; -const double radians=1.0/degrees; +static const double pi=acos(-1); +static const double degrees=180.0/pi; +static const double radians=1.0/degrees; double Background[4]; size_t Nlights; @@ -217,7 +218,7 @@ void setDimensions(int Width, int Height, double X, double Y) double Aspect=((double) Width)/Height; double xshift=X/Width*lastzoom+Shift.getx()*Xfactor; double yshift=Y/Height*lastzoom+Shift.gety()*Yfactor; - double Zoominv=1.0/Zoom; + double Zoominv=1.0/lastzoom; if(orthographic) { double xsize=Xmax-Xmin; double ysize=Ymax-Ymin; diff --git a/Build/source/utils/asymptote/lex.yy.cc b/Build/source/utils/asymptote/lex.yy.cc index 3cbf4000837..20336cd2c40 100644 --- a/Build/source/utils/asymptote/lex.yy.cc +++ b/Build/source/utils/asymptote/lex.yy.cc @@ -767,20 +767,20 @@ int yy_flex_debug = 1; static yyconst flex_int16_t yy_rule_linenum[122] = { 0, - 180, 181, 183, 189, 193, 194, 204, 205, 206, 207, - 211, 212, 222, 223, 224, 225, 226, 227, 228, 229, - 230, 231, 236, 241, 247, 253, 261, 264, 265, 266, - 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, - 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, - 297, 298, 299, 300, 301, 302, 303, 304, 306, 307, - 308, 309, 310, 311, 313, 314, 315, 316, 317, 319, - 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 334, 335, 336, 338, 339, 340, - - 341, 342, 345, 352, 359, 361, 363, 365, 367, 370, - 372, 373, 379, 383, 387, 391, 394, 398, 399, 400, - 404 + 201, 202, 204, 210, 214, 215, 225, 226, 227, 228, + 232, 233, 243, 244, 245, 246, 247, 248, 249, 250, + 251, 252, 257, 262, 268, 274, 282, 285, 286, 287, + 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, + 298, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 324, 325, 326, 328, 329, + 330, 331, 332, 333, 335, 336, 337, 338, 339, 341, + 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, 356, 357, 358, 360, 361, 362, + + 363, 364, 367, 374, 381, 383, 385, 387, 389, 392, + 394, 395, 401, 405, 409, 413, 416, 420, 421, 422, + 426 } ; /* The intent behind this definition is that it'll catch @@ -818,6 +818,8 @@ using mem::string; #include "camp.tab.h" +#include "opsymbols.h" + #define YY_NO_UNPUT fileinfo* fi; @@ -875,8 +877,27 @@ void adjust() yylval.pos = here(); } +void savesymbol(symbol *name) +{ + adjust(); + yylval.ps.pos=here(); + yylval.ps.sym=name; +} + +/* For optimization reasons, the operator names are translated into symbols + * just once, and can be accessed throughout the code as SYM_PLUS, SYM_DASHES, + * etc. Following the Don't Repeat Yourself principle, the mapping from + * strings to names is defined only here in camp.l (because we can't produce + * lex rules from a C style macro). + * The script opsymbols.pl reads this file scanning for rules using DEFSYMBOL + * and creates opsymbols.h which defines the names for use in C++ code. + */ +#define DEFSYMBOL(name) \ + savesymbol(name) + void makesymbol(bool op=true, string text = yytext) { + // TODO: Refactor to a call to savesymbol. adjust(); yylval.ps.pos=here(); yylval.ps.sym=op ? symbol::opTrans(text) : symbol::literalTrans(text); @@ -960,7 +981,7 @@ void getstring(void) -#line 964 "lex.yy.cc" +#line 985 "lex.yy.cc" #define INITIAL 0 #define lexcomment 1 @@ -1207,10 +1228,10 @@ YY_DECL register int yy_act; /* %% [7.0] user's declarations go here */ -#line 177 "camp.l" +#line 198 "camp.l" -#line 1214 "lex.yy.cc" +#line 1235 "lex.yy.cc" if ( !(yy_init) ) { @@ -1326,23 +1347,23 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 180 "camp.l" +#line 201 "camp.l" {adjust(); /*commentDepth++;*/} YY_BREAK case 2: YY_RULE_SETUP -#line 181 "camp.l" +#line 202 "camp.l" {adjust(); /*commentDepth--;*/ /*if (commentDepth == 0)*/ BEGIN INITIAL; } YY_BREAK case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 183 "camp.l" +#line 204 "camp.l" {adjust(); newline(); continue; } YY_BREAK case YY_STATE_EOF(lexcomment): -#line 184 "camp.l" +#line 205 "camp.l" {adjust(); setEOF("comment not terminated"); BEGIN INITIAL; @@ -1351,7 +1372,7 @@ case YY_STATE_EOF(lexcomment): YY_BREAK case 4: YY_RULE_SETUP -#line 189 "camp.l" +#line 210 "camp.l" {adjust(); continue; } YY_BREAK @@ -1362,19 +1383,19 @@ case 5: (yy_c_buf_p) = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 193 "camp.l" +#line 214 "camp.l" {adjust(); BEGIN INITIAL;} YY_BREAK case 6: YY_RULE_SETUP -#line 194 "camp.l" +#line 215 "camp.l" {adjust(); BEGIN INITIAL; getstring(); return STRING; } YY_BREAK case YY_STATE_EOF(texstring): -#line 198 "camp.l" +#line 219 "camp.l" {adjust(); setEOF("string not terminated"); BEGIN INITIAL; @@ -1385,22 +1406,22 @@ case YY_STATE_EOF(texstring): case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 204 "camp.l" +#line 225 "camp.l" {adjust(); newline(); append('\n'); continue; } YY_BREAK case 8: YY_RULE_SETUP -#line 205 "camp.l" +#line 226 "camp.l" {adjust(); append('\\'); append('\\'); continue; } YY_BREAK case 9: YY_RULE_SETUP -#line 206 "camp.l" +#line 227 "camp.l" {adjust(); append('\"'); continue; } YY_BREAK case 10: YY_RULE_SETUP -#line 207 "camp.l" +#line 228 "camp.l" {adjust(); append(*yytext); } YY_BREAK @@ -1411,19 +1432,19 @@ case 11: (yy_c_buf_p) = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 211 "camp.l" +#line 232 "camp.l" {adjust(); BEGIN INITIAL;} YY_BREAK case 12: YY_RULE_SETUP -#line 212 "camp.l" +#line 233 "camp.l" {adjust(); BEGIN INITIAL; getstring(); return STRING; } YY_BREAK case YY_STATE_EOF(cstring): -#line 216 "camp.l" +#line 237 "camp.l" {adjust(); setEOF("string not terminated"); BEGIN INITIAL; @@ -1434,52 +1455,52 @@ case YY_STATE_EOF(cstring): case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 222 "camp.l" +#line 243 "camp.l" {adjust(); newline(); append('\n'); continue; } YY_BREAK case 14: YY_RULE_SETUP -#line 223 "camp.l" +#line 244 "camp.l" {adjust(); append(yytext[1]); continue; } YY_BREAK case 15: YY_RULE_SETUP -#line 224 "camp.l" +#line 245 "camp.l" {adjust(); append('\a'); continue; } YY_BREAK case 16: YY_RULE_SETUP -#line 225 "camp.l" +#line 246 "camp.l" {adjust(); append('\b'); continue; } YY_BREAK case 17: YY_RULE_SETUP -#line 226 "camp.l" +#line 247 "camp.l" {adjust(); append('\f'); continue; } YY_BREAK case 18: YY_RULE_SETUP -#line 227 "camp.l" +#line 248 "camp.l" {adjust(); append('\n'); continue; } YY_BREAK case 19: YY_RULE_SETUP -#line 228 "camp.l" +#line 249 "camp.l" {adjust(); append('\r'); continue; } YY_BREAK case 20: YY_RULE_SETUP -#line 229 "camp.l" +#line 250 "camp.l" {adjust(); append('\t'); continue; } YY_BREAK case 21: YY_RULE_SETUP -#line 230 "camp.l" +#line 251 "camp.l" {adjust(); append('\v'); continue; } YY_BREAK case 22: YY_RULE_SETUP -#line 231 "camp.l" +#line 252 "camp.l" {adjust(); char x=(char)(yytext[1]-'0'); append(x); @@ -1488,7 +1509,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 236 "camp.l" +#line 257 "camp.l" {adjust(); char x=(char)((yytext[1]-'0')*8+yytext[2]-'0'); append(x); @@ -1497,7 +1518,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 241 "camp.l" +#line 262 "camp.l" {adjust(); char x=(char)((yytext[1]-'0')*64+(yytext[2]-'0')*8 +yytext[3]-'0'); @@ -1507,7 +1528,7 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 247 "camp.l" +#line 268 "camp.l" {adjust(); char x=(char) (yytext[2] <= '9' ? yytext[2]-'0' : 10+yytext[2]-'A'); @@ -1517,7 +1538,7 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -#line 253 "camp.l" +#line 274 "camp.l" {adjust(); char x=(char) ((yytext[2] <= '9' ? yytext[2]-'0' : 10+yytext[2]-'A')*16 @@ -1529,390 +1550,390 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 261 "camp.l" +#line 282 "camp.l" {adjust(); append(*yytext); } YY_BREAK case 28: YY_RULE_SETUP -#line 264 "camp.l" +#line 285 "camp.l" {adjust(); continue;} YY_BREAK case 29: /* rule 29 can match eol */ YY_RULE_SETUP -#line 265 "camp.l" +#line 286 "camp.l" {adjust(); newline(); continue;} YY_BREAK case 30: YY_RULE_SETUP -#line 266 "camp.l" +#line 287 "camp.l" {adjust(); continue;} YY_BREAK case 31: YY_RULE_SETUP -#line 267 "camp.l" +#line 288 "camp.l" {adjust(); return ','; } YY_BREAK case 32: YY_RULE_SETUP -#line 268 "camp.l" +#line 289 "camp.l" {adjust(); return ':'; } YY_BREAK case 33: YY_RULE_SETUP -#line 269 "camp.l" +#line 290 "camp.l" {adjust(); return ';'; } YY_BREAK case 34: YY_RULE_SETUP -#line 270 "camp.l" +#line 291 "camp.l" {adjust(); return '('; } YY_BREAK case 35: YY_RULE_SETUP -#line 271 "camp.l" +#line 292 "camp.l" {adjust(); return ')'; } YY_BREAK case 36: YY_RULE_SETUP -#line 272 "camp.l" +#line 293 "camp.l" {adjust(); return '['; } YY_BREAK case 37: YY_RULE_SETUP -#line 273 "camp.l" +#line 294 "camp.l" {adjust(); return ']'; } YY_BREAK case 38: YY_RULE_SETUP -#line 274 "camp.l" +#line 295 "camp.l" {adjust(); return '{'; } YY_BREAK case 39: YY_RULE_SETUP -#line 275 "camp.l" +#line 296 "camp.l" {adjust(); return '}'; } YY_BREAK case 40: YY_RULE_SETUP -#line 276 "camp.l" +#line 297 "camp.l" {adjust(); return '.'; } YY_BREAK case 41: YY_RULE_SETUP -#line 277 "camp.l" +#line 298 "camp.l" {adjust(); return ELLIPSIS; } YY_BREAK case 42: YY_RULE_SETUP -#line 278 "camp.l" -{makesymbol(); return '+'; } +#line 300 "camp.l" +{DEFSYMBOL(SYM_PLUS); return '+'; } YY_BREAK case 43: YY_RULE_SETUP -#line 279 "camp.l" -{makesymbol(); return '-'; } +#line 301 "camp.l" +{DEFSYMBOL(SYM_MINUS); return '-'; } YY_BREAK case 44: YY_RULE_SETUP -#line 280 "camp.l" -{makesymbol(); return '*'; } +#line 302 "camp.l" +{DEFSYMBOL(SYM_TIMES); return '*'; } YY_BREAK case 45: YY_RULE_SETUP -#line 281 "camp.l" -{makesymbol(); return '/'; } +#line 303 "camp.l" +{DEFSYMBOL(SYM_DIVIDE); return '/'; } YY_BREAK case 46: YY_RULE_SETUP -#line 282 "camp.l" -{makesymbol(); return '%'; } +#line 304 "camp.l" +{DEFSYMBOL(SYM_MOD); return '%'; } YY_BREAK case 47: YY_RULE_SETUP -#line 283 "camp.l" -{makesymbol(); return '^'; } +#line 305 "camp.l" +{DEFSYMBOL(SYM_CARET); return '^'; } YY_BREAK case 48: YY_RULE_SETUP -#line 284 "camp.l" -{makesymbol(true,"^"); return '^'; } +#line 306 "camp.l" +{savesymbol(SYM_CARET); return '^'; } YY_BREAK case 49: YY_RULE_SETUP -#line 285 "camp.l" +#line 307 "camp.l" {adjust(); return '?'; } YY_BREAK case 50: YY_RULE_SETUP -#line 286 "camp.l" +#line 308 "camp.l" {adjust(); return ASSIGN; } YY_BREAK case 51: YY_RULE_SETUP -#line 287 "camp.l" -{makesymbol(); return EQ; } +#line 309 "camp.l" +{DEFSYMBOL(SYM_EQ); return EQ; } YY_BREAK case 52: YY_RULE_SETUP -#line 288 "camp.l" -{makesymbol(); return NEQ; } +#line 310 "camp.l" +{DEFSYMBOL(SYM_NEQ); return NEQ; } YY_BREAK case 53: YY_RULE_SETUP -#line 289 "camp.l" -{makesymbol(); return LT; } +#line 311 "camp.l" +{DEFSYMBOL(SYM_LT); return LT; } YY_BREAK case 54: YY_RULE_SETUP -#line 290 "camp.l" -{makesymbol(); return LE; } +#line 312 "camp.l" +{DEFSYMBOL(SYM_LE); return LE; } YY_BREAK case 55: YY_RULE_SETUP -#line 291 "camp.l" -{makesymbol(); return GT; } +#line 313 "camp.l" +{DEFSYMBOL(SYM_GT); return GT; } YY_BREAK case 56: YY_RULE_SETUP -#line 292 "camp.l" -{makesymbol(); return GE; } +#line 314 "camp.l" +{DEFSYMBOL(SYM_GE); return GE; } YY_BREAK case 57: YY_RULE_SETUP -#line 293 "camp.l" -{makesymbol(); return CAND; } +#line 315 "camp.l" +{DEFSYMBOL(SYM_CAND); return CAND; } YY_BREAK case 58: YY_RULE_SETUP -#line 294 "camp.l" -{makesymbol(); return COR; } +#line 316 "camp.l" +{DEFSYMBOL(SYM_COR); return COR; } YY_BREAK case 59: YY_RULE_SETUP -#line 295 "camp.l" -{makesymbol(); return LOGNOT; } +#line 317 "camp.l" +{DEFSYMBOL(SYM_LOGNOT); return LOGNOT; } YY_BREAK case 60: YY_RULE_SETUP -#line 296 "camp.l" -{makesymbol(); return CARETS; } +#line 318 "camp.l" +{DEFSYMBOL(SYM_CARETS); return CARETS; } YY_BREAK case 61: YY_RULE_SETUP -#line 297 "camp.l" -{makesymbol(); return COLONS; } +#line 319 "camp.l" +{DEFSYMBOL(SYM_COLONS); return COLONS; } YY_BREAK case 62: YY_RULE_SETUP -#line 298 "camp.l" -{makesymbol(); return INCR; } +#line 320 "camp.l" +{DEFSYMBOL(SYM_INCR); return INCR; } YY_BREAK case 63: YY_RULE_SETUP -#line 299 "camp.l" -{makesymbol(); return DOTS; } +#line 321 "camp.l" +{DEFSYMBOL(SYM_DOTS); return DOTS; } YY_BREAK case 64: YY_RULE_SETUP -#line 300 "camp.l" -{makesymbol(); return DASHES; } +#line 322 "camp.l" +{DEFSYMBOL(SYM_DASHES); return DASHES; } YY_BREAK case 65: YY_RULE_SETUP -#line 301 "camp.l" -{makesymbol(); return LONGDASH; } +#line 323 "camp.l" +{DEFSYMBOL(SYM_LONGDASH); return LONGDASH; } YY_BREAK case 66: YY_RULE_SETUP -#line 302 "camp.l" -{makesymbol(); return AMPERSAND; } +#line 324 "camp.l" +{DEFSYMBOL(SYM_AMPERSAND); return AMPERSAND; } YY_BREAK case 67: YY_RULE_SETUP -#line 303 "camp.l" -{makesymbol(); return BAR; } +#line 325 "camp.l" +{DEFSYMBOL(SYM_BAR); return BAR; } YY_BREAK case 68: YY_RULE_SETUP -#line 304 "camp.l" +#line 326 "camp.l" {makesymbol(); return OPERATOR; } YY_BREAK case 69: YY_RULE_SETUP -#line 306 "camp.l" +#line 328 "camp.l" {makeselfsymbol(); return ADD; } YY_BREAK case 70: YY_RULE_SETUP -#line 307 "camp.l" +#line 329 "camp.l" {makeselfsymbol(); return SUBTRACT; } YY_BREAK case 71: YY_RULE_SETUP -#line 308 "camp.l" +#line 330 "camp.l" {makeselfsymbol(); return TIMES; } YY_BREAK case 72: YY_RULE_SETUP -#line 309 "camp.l" +#line 331 "camp.l" {makeselfsymbol(); return DIVIDE; } YY_BREAK case 73: YY_RULE_SETUP -#line 310 "camp.l" +#line 332 "camp.l" {makeselfsymbol(); return MOD; } YY_BREAK case 74: YY_RULE_SETUP -#line 311 "camp.l" +#line 333 "camp.l" {makeselfsymbol(); return EXPONENT; } YY_BREAK case 75: YY_RULE_SETUP -#line 313 "camp.l" +#line 335 "camp.l" {adjust(); return AND; } YY_BREAK case 76: YY_RULE_SETUP -#line 314 "camp.l" -{makesymbol(); return CONTROLS; } +#line 336 "camp.l" +{DEFSYMBOL(SYM_CONTROLS); return CONTROLS; } YY_BREAK case 77: YY_RULE_SETUP -#line 315 "camp.l" -{makesymbol(); return TENSION; } +#line 337 "camp.l" +{DEFSYMBOL(SYM_TENSION); return TENSION; } YY_BREAK case 78: YY_RULE_SETUP -#line 316 "camp.l" -{makesymbol(); return ATLEAST; } +#line 338 "camp.l" +{DEFSYMBOL(SYM_ATLEAST); return ATLEAST; } YY_BREAK case 79: YY_RULE_SETUP -#line 317 "camp.l" -{makesymbol(); return CURL; } +#line 339 "camp.l" +{DEFSYMBOL(SYM_CURL); return CURL; } YY_BREAK case 80: YY_RULE_SETUP -#line 319 "camp.l" +#line 341 "camp.l" {adjust(); return IF; } YY_BREAK case 81: YY_RULE_SETUP -#line 320 "camp.l" +#line 342 "camp.l" {adjust(); return ELSE; } YY_BREAK case 82: YY_RULE_SETUP -#line 321 "camp.l" +#line 343 "camp.l" {adjust(); return WHILE; } YY_BREAK case 83: YY_RULE_SETUP -#line 322 "camp.l" +#line 344 "camp.l" {adjust(); return FOR; } YY_BREAK case 84: YY_RULE_SETUP -#line 323 "camp.l" +#line 345 "camp.l" {adjust(); return DO; } YY_BREAK case 85: YY_RULE_SETUP -#line 324 "camp.l" +#line 346 "camp.l" {adjust(); return RETURN_; } YY_BREAK case 86: YY_RULE_SETUP -#line 325 "camp.l" +#line 347 "camp.l" {adjust(); return BREAK; } YY_BREAK case 87: YY_RULE_SETUP -#line 326 "camp.l" +#line 348 "camp.l" {adjust(); return CONTINUE; } YY_BREAK case 88: YY_RULE_SETUP -#line 327 "camp.l" +#line 349 "camp.l" {adjust(); return STRUCT; } YY_BREAK case 89: YY_RULE_SETUP -#line 328 "camp.l" +#line 350 "camp.l" {adjust(); return TYPEDEF; } YY_BREAK case 90: YY_RULE_SETUP -#line 329 "camp.l" +#line 351 "camp.l" {adjust(); return NEW; } YY_BREAK case 91: YY_RULE_SETUP -#line 330 "camp.l" +#line 352 "camp.l" {adjust(); return ACCESS; } YY_BREAK case 92: YY_RULE_SETUP -#line 331 "camp.l" +#line 353 "camp.l" {adjust(); return IMPORT; } YY_BREAK case 93: YY_RULE_SETUP -#line 332 "camp.l" +#line 354 "camp.l" {adjust(); return UNRAVEL; } YY_BREAK case 94: YY_RULE_SETUP -#line 333 "camp.l" +#line 355 "camp.l" {adjust(); return FROM; } YY_BREAK case 95: YY_RULE_SETUP -#line 334 "camp.l" +#line 356 "camp.l" {adjust(); return INCLUDE; } YY_BREAK case 96: YY_RULE_SETUP -#line 335 "camp.l" +#line 357 "camp.l" {adjust(); return QUOTE; } YY_BREAK case 97: YY_RULE_SETUP -#line 336 "camp.l" +#line 358 "camp.l" {adjust(); makemod(trans::EXPLICIT_STATIC); return MODIFIER; } YY_BREAK case 98: YY_RULE_SETUP -#line 338 "camp.l" +#line 360 "camp.l" {adjust(); makeperm(trans::PUBLIC); return PERM; } YY_BREAK case 99: YY_RULE_SETUP -#line 339 "camp.l" +#line 361 "camp.l" {adjust(); makeperm(trans::PRIVATE); return PERM; } YY_BREAK case 100: YY_RULE_SETUP -#line 340 "camp.l" +#line 362 "camp.l" {adjust(); makeperm(trans::RESTRICTED); return PERM; } YY_BREAK case 101: YY_RULE_SETUP -#line 341 "camp.l" +#line 363 "camp.l" {adjust(); return THIS; } YY_BREAK case 102: YY_RULE_SETUP -#line 342 "camp.l" +#line 364 "camp.l" {adjust(); return EXPLICIT; } YY_BREAK case 103: YY_RULE_SETUP -#line 345 "camp.l" +#line 367 "camp.l" try { adjust(); yylval.e= new intExp(here(), lexical::cast<Int>(yytext)); } catch (lexical::bad_cast&) { @@ -1923,7 +1944,7 @@ try { YY_BREAK case 104: YY_RULE_SETUP -#line 352 "camp.l" +#line 374 "camp.l" try { adjust(); yylval.e= new realExp(here(), lexical::cast<double>(yytext)); } catch (lexical::bad_cast&) { @@ -1934,53 +1955,53 @@ try { YY_BREAK case 105: YY_RULE_SETUP -#line 359 "camp.l" +#line 381 "camp.l" { adjust(); yylval.e= new booleanExp(here(), true); return LIT; } YY_BREAK case 106: YY_RULE_SETUP -#line 361 "camp.l" +#line 383 "camp.l" { adjust(); yylval.e= new booleanExp(here(), false); return LIT; } YY_BREAK case 107: YY_RULE_SETUP -#line 363 "camp.l" +#line 385 "camp.l" { adjust(); yylval.e= new nullExp(here()); return LIT; } YY_BREAK case 108: YY_RULE_SETUP -#line 365 "camp.l" +#line 387 "camp.l" { adjust(); yylval.e= new cycleExp(here()); return LIT; } YY_BREAK case 109: YY_RULE_SETUP -#line 367 "camp.l" +#line 389 "camp.l" { adjust(); yylval.e= new newPictureExp(here()); return LIT; } YY_BREAK case 110: YY_RULE_SETUP -#line 370 "camp.l" +#line 392 "camp.l" {adjust(); BEGIN opname; } YY_BREAK case 111: YY_RULE_SETUP -#line 372 "camp.l" +#line 394 "camp.l" {adjust(); continue;} YY_BREAK case 112: /* rule 112 can match eol */ YY_RULE_SETUP -#line 373 "camp.l" +#line 395 "camp.l" {adjust(); newline(); continue;} YY_BREAK case YY_STATE_EOF(opname): -#line 374 "camp.l" +#line 396 "camp.l" {adjust(); setEOF("missing operator name"); BEGIN INITIAL; @@ -1989,7 +2010,7 @@ case YY_STATE_EOF(opname): YY_BREAK case 113: YY_RULE_SETUP -#line 379 "camp.l" +#line 401 "camp.l" { makesymbol(true, "^"); BEGIN INITIAL; return ID; @@ -1997,7 +2018,7 @@ YY_RULE_SETUP YY_BREAK case 114: YY_RULE_SETUP -#line 383 "camp.l" +#line 405 "camp.l" { makesymbol(); BEGIN INITIAL; @@ -2005,7 +2026,7 @@ YY_RULE_SETUP YY_BREAK case 115: YY_RULE_SETUP -#line 387 "camp.l" +#line 409 "camp.l" { makesymbol(true); BEGIN INITIAL; @@ -2013,49 +2034,49 @@ YY_RULE_SETUP YY_BREAK case 116: YY_RULE_SETUP -#line 391 "camp.l" +#line 413 "camp.l" {} YY_BREAK case 117: YY_RULE_SETUP -#line 394 "camp.l" +#line 416 "camp.l" { makesymbol(false); return ID; } YY_BREAK case 118: YY_RULE_SETUP -#line 398 "camp.l" +#line 420 "camp.l" {adjust(); /*commentDepth = 1;*/ BEGIN lexcomment; } YY_BREAK case 119: YY_RULE_SETUP -#line 399 "camp.l" +#line 421 "camp.l" {adjust(); BEGIN texstring; } YY_BREAK case 120: YY_RULE_SETUP -#line 400 "camp.l" +#line 422 "camp.l" {adjust(); BEGIN cstring; } YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(lexformat): -#line 402 "camp.l" +#line 424 "camp.l" { setEOF("unexpected end of input"); yyterminate(); } YY_BREAK case 121: YY_RULE_SETUP -#line 404 "camp.l" +#line 426 "camp.l" { adjust(); error(); em <<"invalid token '" << yytext << "'"; } YY_BREAK case 122: YY_RULE_SETUP -#line 407 "camp.l" +#line 429 "camp.l" ECHO; YY_BREAK -#line 2059 "lex.yy.cc" +#line 2080 "lex.yy.cc" case YY_END_OF_BUFFER: { @@ -3188,4 +3209,4 @@ void yyfree (void * ptr ) /* %ok-for-header */ -#line 407 "camp.l" +#line 429 "camp.l" diff --git a/Build/source/utils/asymptote/memory.h b/Build/source/utils/asymptote/memory.h index 70c36422ffe..be13e5059a0 100644 --- a/Build/source/utils/asymptote/memory.h +++ b/Build/source/utils/asymptote/memory.h @@ -17,7 +17,7 @@ #ifndef NOHASH #ifndef __GNUC_PREREQ #define __GNUC_PREREQ(maj, min) (0) -# endif +#endif #if __GNUC_PREREQ(4,3) || defined(__CYGWIN__) #include <tr1/unordered_map> #define EXT std::tr1 diff --git a/Build/source/utils/asymptote/name.cc b/Build/source/utils/asymptote/name.cc index 0c822792e0c..ac3ad8e70df 100644 --- a/Build/source/utils/asymptote/name.cc +++ b/Build/source/utils/asymptote/name.cc @@ -96,6 +96,12 @@ types::ty *simpleName::varGetType(coenv &e) return e.e.varGetType(id); } +trans::varEntry *simpleName::getCallee(coenv &e, signature *sig) +{ + varEntry *ve = e.e.lookupVarBySignature(id, sig); + return ve; +} + types::ty *simpleName::typeTrans(coenv &e, bool tacit) { types::ty *t = e.e.lookupType(id); @@ -226,6 +232,14 @@ types::ty *qualifiedName::varGetType(coenv &e) return r ? r->e.varGetType(id) : 0; } +trans::varEntry *qualifiedName::getCallee(coenv &e, signature *sig) +{ + // getTypeAsCallee is an optimization attempt. We don't try optimizing the + // rarer qualifiedName call case. + // TODO: See if this is worth implementing. + return 0; +} + trans::varEntry *qualifiedName::getVarEntry(coenv &e) { varEntry *qv = qualifier->getVarEntry(e); diff --git a/Build/source/utils/asymptote/name.h b/Build/source/utils/asymptote/name.h index 9864d5e13ae..b72111d33b2 100644 --- a/Build/source/utils/asymptote/name.h +++ b/Build/source/utils/asymptote/name.h @@ -72,6 +72,7 @@ public: // Returns the possible variable types. Unlike exp, returns 0 if none // match. virtual types::ty *varGetType(coenv &e) = 0; + virtual trans::varEntry *getCallee(coenv &e, types::signature *sig) = 0; // As a type: // Determines the type, as used in a variable declaration. @@ -106,6 +107,7 @@ public: // As a variable: void varTrans(action act, coenv &e, types::ty *target); types::ty *varGetType(coenv &); + trans::varEntry *getCallee(coenv &e, types::signature *sig); // As a type: types::ty *typeTrans(coenv &e, bool tacit = false); @@ -147,6 +149,7 @@ public: // As a variable: void varTrans(action act, coenv &, types::ty *target); types::ty *varGetType(coenv &); + trans::varEntry *getCallee(coenv &e, types::signature *sig); // As a type: types::ty *typeTrans(coenv &e, bool tacit = false); diff --git a/Build/source/utils/asymptote/newexp.cc b/Build/source/utils/asymptote/newexp.cc index 5b5aacca01e..8105a9d9295 100644 --- a/Build/source/utils/asymptote/newexp.cc +++ b/Build/source/utils/asymptote/newexp.cc @@ -30,6 +30,10 @@ void printFrame(frame *f) { } } +void newRecordExp::prettyprint(ostream &out, Int indent) { + prettyname(out, "newRecordExp", indent); +} + bool newRecordExp::encodeLevel(position pos, coenv &e, trans::tyEntry *ent) { record *r = dynamic_cast<record *>(ent->t); diff --git a/Build/source/utils/asymptote/newexp.h b/Build/source/utils/asymptote/newexp.h index 989846a797b..dd64584a6a0 100644 --- a/Build/source/utils/asymptote/newexp.h +++ b/Build/source/utils/asymptote/newexp.h @@ -26,6 +26,8 @@ public: newRecordExp(position pos, ty *result) : exp(pos), result(result) {} + void prettyprint(ostream &out, Int indent); + static types::ty *transFromTyEntry(position pos, coenv &e, trans::tyEntry *ent); diff --git a/Build/source/utils/asymptote/opsymbols.h b/Build/source/utils/asymptote/opsymbols.h new file mode 100644 index 00000000000..a385529ae29 --- /dev/null +++ b/Build/source/utils/asymptote/opsymbols.h @@ -0,0 +1,121 @@ +/***** + * This file is automatically generated by opsymbols.pl + * Changes will be overwritten. + *****/ + +// If the OPSYMBOL macro is not defined for a specific purpose, define it with +// the default purpose of using SYM_PLUS etc. as external pre-translated +// symbols. + +#ifndef OPSYMBOL +#define OPSYMBOL(str, name) extern symbol *name +#endif + +OPSYMBOL("+", SYM_PLUS); +#ifndef PRESYM +#define SYM_PLUS symbol::opTrans("+") +#endif +OPSYMBOL("-", SYM_MINUS); +#ifndef PRESYM +#define SYM_MINUS symbol::opTrans("-") +#endif +OPSYMBOL("*", SYM_TIMES); +#ifndef PRESYM +#define SYM_TIMES symbol::opTrans("*") +#endif +OPSYMBOL("/", SYM_DIVIDE); +#ifndef PRESYM +#define SYM_DIVIDE symbol::opTrans("/") +#endif +OPSYMBOL("%", SYM_MOD); +#ifndef PRESYM +#define SYM_MOD symbol::opTrans("%") +#endif +OPSYMBOL("^", SYM_CARET); +#ifndef PRESYM +#define SYM_CARET symbol::opTrans("^") +#endif +OPSYMBOL("==", SYM_EQ); +#ifndef PRESYM +#define SYM_EQ symbol::opTrans("==") +#endif +OPSYMBOL("!=", SYM_NEQ); +#ifndef PRESYM +#define SYM_NEQ symbol::opTrans("!=") +#endif +OPSYMBOL("<", SYM_LT); +#ifndef PRESYM +#define SYM_LT symbol::opTrans("<") +#endif +OPSYMBOL("<=", SYM_LE); +#ifndef PRESYM +#define SYM_LE symbol::opTrans("<=") +#endif +OPSYMBOL(">", SYM_GT); +#ifndef PRESYM +#define SYM_GT symbol::opTrans(">") +#endif +OPSYMBOL(">=", SYM_GE); +#ifndef PRESYM +#define SYM_GE symbol::opTrans(">=") +#endif +OPSYMBOL("&&", SYM_CAND); +#ifndef PRESYM +#define SYM_CAND symbol::opTrans("&&") +#endif +OPSYMBOL("||", SYM_COR); +#ifndef PRESYM +#define SYM_COR symbol::opTrans("||") +#endif +OPSYMBOL("!", SYM_LOGNOT); +#ifndef PRESYM +#define SYM_LOGNOT symbol::opTrans("!") +#endif +OPSYMBOL("^^", SYM_CARETS); +#ifndef PRESYM +#define SYM_CARETS symbol::opTrans("^^") +#endif +OPSYMBOL("::", SYM_COLONS); +#ifndef PRESYM +#define SYM_COLONS symbol::opTrans("::") +#endif +OPSYMBOL("++", SYM_INCR); +#ifndef PRESYM +#define SYM_INCR symbol::opTrans("++") +#endif +OPSYMBOL("..", SYM_DOTS); +#ifndef PRESYM +#define SYM_DOTS symbol::opTrans("..") +#endif +OPSYMBOL("--", SYM_DASHES); +#ifndef PRESYM +#define SYM_DASHES symbol::opTrans("--") +#endif +OPSYMBOL("---", SYM_LONGDASH); +#ifndef PRESYM +#define SYM_LONGDASH symbol::opTrans("---") +#endif +OPSYMBOL("&", SYM_AMPERSAND); +#ifndef PRESYM +#define SYM_AMPERSAND symbol::opTrans("&") +#endif +OPSYMBOL("|", SYM_BAR); +#ifndef PRESYM +#define SYM_BAR symbol::opTrans("|") +#endif +OPSYMBOL("controls", SYM_CONTROLS); +#ifndef PRESYM +#define SYM_CONTROLS symbol::opTrans("controls") +#endif +OPSYMBOL("tension", SYM_TENSION); +#ifndef PRESYM +#define SYM_TENSION symbol::opTrans("tension") +#endif +OPSYMBOL("atleast", SYM_ATLEAST); +#ifndef PRESYM +#define SYM_ATLEAST symbol::opTrans("atleast") +#endif +OPSYMBOL("curl", SYM_CURL); +#ifndef PRESYM +#define SYM_CURL symbol::opTrans("curl") +#endif diff --git a/Build/source/utils/asymptote/opsymbols.pl b/Build/source/utils/asymptote/opsymbols.pl new file mode 100644 index 00000000000..16ade5374ac --- /dev/null +++ b/Build/source/utils/asymptote/opsymbols.pl @@ -0,0 +1,53 @@ +#!/usr/bin/env perl +##### +# opsymbols.pl +# Andy Hammerlindl 2010/06/01 +# +# Extract mapping such as '+' --> SYM_PLUS from camp.l +##### + +open(header, ">opsymbols.h") || + die("Couldn't open opsymbols.h for writing"); + +print header <<END; +/***** + * This file is automatically generated by opsymbols.pl + * Changes will be overwritten. + *****/ + +// If the OPSYMBOL macro is not defined for a specific purpose, define it with +// the default purpose of using SYM_PLUS etc. as external pre-translated +// symbols. + +#ifndef OPSYMBOL +#define OPSYMBOL(str, name) extern symbol *name +#endif + +END + +sub add { + print header "OPSYMBOL(\"".$_[0]."\", " . $_[1] . ");\n"; + my $sym = $_[0]; + my $name = $_[1]; + print header <<END; +#ifndef PRESYM +#define $name symbol::opTrans("$sym") +#endif +END +} + +open(lexer, "camp.l") || + die("Couldn't open camp.l"); + +while (<lexer>) { + #print $_; + #if (m/^"(\S+)"\s+\{\s+DEFSYMBOL\((\w+)\);/) { + if (m/^"(\S+)"\s*{\s*DEFSYMBOL\((\w+)\);/) { + print $1 . " " . $2 . "\n"; + add($1, $2); + } + if (m/^(\w+)\s*{\s*DEFSYMBOL\((\w+)\);/) { + print $1 . " " . $2 . "\n"; + add($1, $2); + } +} diff --git a/Build/source/utils/asymptote/picture.cc b/Build/source/utils/asymptote/picture.cc index 536a91ef3f6..c35b1e14dd4 100644 --- a/Build/source/utils/asymptote/picture.cc +++ b/Build/source/utils/asymptote/picture.cc @@ -195,8 +195,8 @@ pair picture::ratio(double (*m)(double, double)) { bool first=true; pair b; - bbox3 B=bounds3(); - double fuzz=sqrtFuzz*(B.Max()-B.Min()).length(); + bounds3(); + double fuzz=sqrtFuzz*(b3.Max()-b3.Min()).length(); for(nodelist::const_iterator p=nodes.begin(); p != nodes.end(); ++p) { assert(*p); (*p)->ratio(b,m,fuzz,first); @@ -1047,13 +1047,16 @@ bool picture::shipout3(const string& prefix, array *index, array *center) string prcname=buildname(prefix,"prc"); prcfile prc(prcname); - unsigned int count[nENTITY]; - for(unsigned int i=0; i < nENTITY; ++i) - count[i]=0; + + static const double limit=2.5*10.0/INT_MAX; + double compressionlimit=max(length(b3.Max()),length(b3.Min()))*limit; + + groups.push_back(groupmap()); for(nodelist::iterator p=nodes.begin(); p != nodes.end(); ++p) { assert(*p); - (*p)->write(&prc,count,index,center); + (*p)->write(&prc,&billboard,index,center,compressionlimit,groups); } + groups.pop_back(); if(status) status=prc.finish(); diff --git a/Build/source/utils/asymptote/picture.h b/Build/source/utils/asymptote/picture.h index 98774728f69..7bd876f42e0 100644 --- a/Build/source/utils/asymptote/picture.h +++ b/Build/source/utils/asymptote/picture.h @@ -27,6 +27,8 @@ private: boxvector labelbounds; bboxlist bboxstack; bool transparency; + groupsmap groups; + unsigned billboard; public: bbox3 b3; // 3D bounding box diff --git a/Build/source/utils/asymptote/pipestream.h b/Build/source/utils/asymptote/pipestream.h index fa1fd1dd8ed..20cc6d321b2 100644 --- a/Build/source/utils/asymptote/pipestream.h +++ b/Build/source/utils/asymptote/pipestream.h @@ -138,7 +138,7 @@ public: virtual void pipeclose() { if(pipeopen) { - kill(pid,SIGQUIT); + kill(pid,SIGTERM); eof(); close(out[0]); Running=false; diff --git a/Build/source/utils/asymptote/prc/Makefile b/Build/source/utils/asymptote/prc/Makefile index cfa9ac9be5d..22f67e29725 100644 --- a/Build/source/utils/asymptote/prc/Makefile +++ b/Build/source/utils/asymptote/prc/Makefile @@ -3,20 +3,32 @@ CFLAGS = -O3 -g -Wall CXX = g++ -test: PRCbitStream oPRCFile PRCdouble writePRC test.cc - $(CXX) $(CFLAGS) -o test PRCbitStream.o oPRCFile.o PRCdouble.o writePRC.o test.cc -lz +MAKEDEPEND = $(CFLAGS) -O0 -M -DDEPEND -PRCbitStream: PRCbitStream.cc - $(CXX) $(CFLAGS) -c PRCbitStream.cc -o PRCbitStream.o +FILES = PRCbitStream oPRCFile PRCdouble writePRC -oPRCFile: oPRCFile.cc - $(CXX) $(CFLAGS) -c oPRCFile.cc -o oPRCFile.o +test: $(FILES:=.o) test.cc + $(CXX) $(CFLAGS) -o test $(FILES:=.o) test.cc -lz -PRCdouble: PRCdouble.cc - $(CXX) $(CFLAGS) -c PRCdouble.cc -o PRCdouble.o +.SUFFIXES: .c .cc .o .d +.cc.o: + $(CXX) $(CFLAGS) $(INCL) -o $@ -c $< +.cc.d: + @echo Creating $@; \ + rm -f $@; \ + ${CXX} $(MAKEDEPEND) $(INCL) $(MDOPTS) $< > $@.$$$$ 2>/dev/null && \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ +.c.d: + @echo Creating $@; \ + rm -f $@; \ + ${CC} $(MAKEDEPEND) $(INCL) $(MDOPTS) $< > $@.$$$$ 2>/dev/null && \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -writePRC: writePRC.cc PRCbitStream - $(CXX) $(CFLAGS) -c writePRC.cc -o writePRC.o +ifeq (,$(findstring clean,${MAKECMDGOALS})) +-include $(FILES:=.d) +endif clean: - rm -f *.o test.prc test + rm -f *.o *.d test.prc test diff --git a/Build/source/utils/asymptote/prc/PRC.h b/Build/source/utils/asymptote/prc/PRC.h index ce04cea4801..da1aff7ef9c 100644 --- a/Build/source/utils/asymptote/prc/PRC.h +++ b/Build/source/utils/asymptote/prc/PRC.h @@ -3,198 +3,216 @@ #include <stdint.h> -const uint32_t PRCVersion=7094; // For Adobe Reader 8 or later -//const uint32_t PRCVersion=8137; // For Adobe Reader 9 or later +const uint32_t PRCVersion=8137; // For Adobe Reader 9 or later // from Adobe's documentation -#define PRC_TYPE_ROOT 0 // This type does not correspond to any entity - -#define PRC_TYPE_ROOT_PRCBase ( PRC_TYPE_ROOT + 1 ) // Abstract root type for any PRC entity. -#define PRC_TYPE_ROOT_PRCBaseWithGraphics ( PRC_TYPE_ROOT + 2 ) // Abstract root type for any PRC entity which can bear graphics. - -#define PRC_TYPE_CRV ( PRC_TYPE_ROOT + 10 ) // Types for PRC geometrical curves -#define PRC_TYPE_SURF ( PRC_TYPE_ROOT + 75 ) // Types for PRC geometrical surfaces -#define PRC_TYPE_TOPO ( PRC_TYPE_ROOT + 140 ) // Types for PRC topology -#define PRC_TYPE_TESS ( PRC_TYPE_ROOT + 170 ) // Types for PRC tessellation -#define PRC_TYPE_MISC ( PRC_TYPE_ROOT + 200 ) // Types for PRC global data -#define PRC_TYPE_RI ( PRC_TYPE_ROOT + 230 ) // Types for PRC representation items -#define PRC_TYPE_ASM ( PRC_TYPE_ROOT + 300 ) // Types for PRC assembly -#define PRC_TYPE_MKP ( PRC_TYPE_ROOT + 500 ) // Types for PRC markup -#define PRC_TYPE_GRAPH ( PRC_TYPE_ROOT + 700 ) // Types for PRC graphics -#define PRC_TYPE_MATH ( PRC_TYPE_ROOT + 900 ) // Types for PRC mathematical operators - -#define PRC_TYPE_CRV_Base ( PRC_TYPE_CRV + 1 ) // Abstract type for all geometric curves. -#define PRC_TYPE_CRV_Blend02Boundary ( PRC_TYPE_CRV + 2 ) // Boundary Curve. -#define PRC_TYPE_CRV_NURBS ( PRC_TYPE_CRV + 3 ) // Non Uniform BSpline curve. -#define PRC_TYPE_CRV_Circle ( PRC_TYPE_CRV + 4 ) // Circle. -#define PRC_TYPE_CRV_Composite ( PRC_TYPE_CRV + 5 ) // Array of oriented curves. -#define PRC_TYPE_CRV_OnSurf ( PRC_TYPE_CRV + 6 ) // Curve defined by a UV curve on a surface. -#define PRC_TYPE_CRV_Ellipse ( PRC_TYPE_CRV + 7 ) // Ellipse. -#define PRC_TYPE_CRV_Equation ( PRC_TYPE_CRV + 8 ) // curve described by specific law elements -#define PRC_TYPE_CRV_Helix ( PRC_TYPE_CRV + 9 ) // Helix curve. -#define PRC_TYPE_CRV_Hyperbola ( PRC_TYPE_CRV + 10 ) // Hyperbola. -#define PRC_TYPE_CRV_Intersection ( PRC_TYPE_CRV + 11 ) // Intersection between 2 surfaces. -#define PRC_TYPE_CRV_Line ( PRC_TYPE_CRV + 12 ) // Line. -#define PRC_TYPE_CRV_Offset ( PRC_TYPE_CRV + 13 ) // Offset curve. -#define PRC_TYPE_CRV_Parabola ( PRC_TYPE_CRV + 14 ) // Parabola. -#define PRC_TYPE_CRV_PolyLine ( PRC_TYPE_CRV + 15 ) // Polyedric curve. -#define PRC_TYPE_CRV_Transform ( PRC_TYPE_CRV + 16 ) // Transformed curve. - -#define PRC_TYPE_SURF_Base ( PRC_TYPE_SURF + 1 ) // Abstract type for all geometric surfaces. -#define PRC_TYPE_SURF_Blend01 ( PRC_TYPE_SURF + 2 ) // Blend surface. -#define PRC_TYPE_SURF_Blend02 ( PRC_TYPE_SURF + 3 ) // Blend Surface. -#define PRC_TYPE_SURF_Blend03 ( PRC_TYPE_SURF + 4 ) // Blend Surface. -#define PRC_TYPE_SURF_NURBS ( PRC_TYPE_SURF + 5 ) // Non Uniform BSpline surface. -#define PRC_TYPE_SURF_Cone ( PRC_TYPE_SURF + 6 ) // Cone. -#define PRC_TYPE_SURF_Cylinder ( PRC_TYPE_SURF + 7 ) // Cylinder. -#define PRC_TYPE_SURF_Cylindrical ( PRC_TYPE_SURF + 8 ) // Surface who is defined in cylindrical space. -#define PRC_TYPE_SURF_Offset ( PRC_TYPE_SURF + 9 ) // Offset surface. -#define PRC_TYPE_SURF_Pipe ( PRC_TYPE_SURF + 10 ) // Pipe. -#define PRC_TYPE_SURF_Plane ( PRC_TYPE_SURF + 11 ) // Plane. -#define PRC_TYPE_SURF_Ruled ( PRC_TYPE_SURF + 12 ) // Ruled surface. -#define PRC_TYPE_SURF_Sphere ( PRC_TYPE_SURF + 13 ) // Sphere. -#define PRC_TYPE_SURF_Revolution ( PRC_TYPE_SURF + 14 ) // Surface of revolution. -#define PRC_TYPE_SURF_Extrusion ( PRC_TYPE_SURF + 15 ) // Surface of extrusion. -#define PRC_TYPE_SURF_FromCurves ( PRC_TYPE_SURF + 16 ) // Surface from two curves. -#define PRC_TYPE_SURF_Torus ( PRC_TYPE_SURF + 17 ) // Torus. -#define PRC_TYPE_SURF_Transform ( PRC_TYPE_SURF + 18 ) // Transformed surface. -#define PRC_TYPE_SURF_Blend04 ( PRC_TYPE_SURF + 19 ) // defined for future use. - -#define PRC_TYPE_TOPO_Context ( PRC_TYPE_TOPO + 1 ) // Self-containing set of topological entities. -#define PRC_TYPE_TOPO_Item ( PRC_TYPE_TOPO + 2 ) // Abstract root type for any topological entity (body or single item). -#define PRC_TYPE_TOPO_MultipleVertex ( PRC_TYPE_TOPO + 3 ) // Vertex whose position is the average of all edges' extremity positions to whom it belongs. -#define PRC_TYPE_TOPO_UniqueVertex ( PRC_TYPE_TOPO + 4 ) // Vertex with one set of coordinates (absolute position). -#define PRC_TYPE_TOPO_WireEdge ( PRC_TYPE_TOPO + 5 ) // Edge belonging to a wire body / single wire body. -#define PRC_TYPE_TOPO_Edge ( PRC_TYPE_TOPO + 6 ) // Edge belonging to a brep data. -#define PRC_TYPE_TOPO_CoEdge ( PRC_TYPE_TOPO + 7 ) // Usage of an edge in a loop. -#define PRC_TYPE_TOPO_Loop ( PRC_TYPE_TOPO + 8 ) // Array of co edges which delimits a face. -#define PRC_TYPE_TOPO_Face ( PRC_TYPE_TOPO + 9 ) // Topological face delimiting a shell. -#define PRC_TYPE_TOPO_Shell ( PRC_TYPE_TOPO + 10 ) // Topological shell (open or closed). -#define PRC_TYPE_TOPO_Connex ( PRC_TYPE_TOPO + 11 ) // Topological region delimited by one or several shells. -#define PRC_TYPE_TOPO_Body ( PRC_TYPE_TOPO + 12 ) // Abstract root type for any topological body. -#define PRC_TYPE_TOPO_SingleWireBody ( PRC_TYPE_TOPO + 13 ) // Single wire body. -#define PRC_TYPE_TOPO_BrepData ( PRC_TYPE_TOPO + 14 ) // Main entry to solid and surface topology (regular form). -#define PRC_TYPE_TOPO_SingleWireBodyCompress ( PRC_TYPE_TOPO + 15 ) // Single wire body. (ultra compressed form). -#define PRC_TYPE_TOPO_BrepDataCompress ( PRC_TYPE_TOPO + 16 ) // Main entry to solid and surface topology (ultra compressed form). -#define PRC_TYPE_TOPO_WireBody ( PRC_TYPE_TOPO + 17 ) // This type is the main entry to wire topology. - -#define PRC_TYPE_TESS_Base ( PRC_TYPE_TESS + 1 ) // Abstract root type for any tessellated entity. -#define PRC_TYPE_TESS_3D ( PRC_TYPE_TESS + 2 ) // Tessellated faceted data; regular form. -#define PRC_TYPE_TESS_3D_Compressed ( PRC_TYPE_TESS + 3 ) // Tessellated faceted data; highly compressed form. -#define PRC_TYPE_TESS_Face ( PRC_TYPE_TESS + 4 ) // Tessellated face. -#define PRC_TYPE_TESS_3D_Wire ( PRC_TYPE_TESS + 5 ) // Tessellated wireframe. -#define PRC_TYPE_TESS_Markup ( PRC_TYPE_TESS + 6 ) // Tessellated markup. - -#define PRC_TYPE_MISC_Attribute ( PRC_TYPE_MISC + 1 ) // Entity attribute. -#define PRC_TYPE_MISC_CartesianTransformation ( PRC_TYPE_MISC + 2 ) // Cartesian transformation. -#define PRC_TYPE_MISC_EntityReference ( PRC_TYPE_MISC + 3 ) // Entity reference. -#define PRC_TYPE_MISC_MarkupLinkedItem ( PRC_TYPE_MISC + 4 ) // Link between a markup and an entity. -#define PRC_TYPE_MISC_ReferenceOnPRCBase ( PRC_TYPE_MISC + 5 ) // Reference pointing on a regular entity (not topological). -#define PRC_TYPE_MISC_ReferenceOnTopology ( PRC_TYPE_MISC + 6 ) // Reference pointing on a topological entity. - -#define PRC_TYPE_RI_RepresentationItem ( PRC_TYPE_RI + 1 ) // Basic abstract type for representation items. -#define PRC_TYPE_RI_BrepModel ( PRC_TYPE_RI + 2 ) // Basic type for surfaces and solids. -#define PRC_TYPE_RI_Curve ( PRC_TYPE_RI + 3 ) // Basic type for curves. -#define PRC_TYPE_RI_Direction ( PRC_TYPE_RI + 4 ) // Optional point + vector. -#define PRC_TYPE_RI_Plane ( PRC_TYPE_RI + 5 ) // Construction plane, as opposed to planar surface. -#define PRC_TYPE_RI_PointSet ( PRC_TYPE_RI + 6 ) // Set of points. -#define PRC_TYPE_RI_PolyBrepModel ( PRC_TYPE_RI + 7 ) // Basic type to polyhedral surfaces and solids. -#define PRC_TYPE_RI_PolyWire ( PRC_TYPE_RI + 8 ) // Polyedric wireframe entity. -#define PRC_TYPE_RI_Set ( PRC_TYPE_RI + 9 ) // Logical grouping of arbitrary number of representation items. -#define PRC_TYPE_RI_CoordinateSystem ( PRC_TYPE_RI + 10 ) // Coordinate system. - -#define PRC_TYPE_ASM_ModelFile ( PRC_TYPE_ASM + 1 ) // Basic entry type for PRC. -#define PRC_TYPE_ASM_FileStructure ( PRC_TYPE_ASM + 2 ) // Basic structure for PRC files. -#define PRC_TYPE_ASM_FileStructureGlobals ( PRC_TYPE_ASM + 3 ) // Basic structure for PRC files : globals. -#define PRC_TYPE_ASM_FileStructureTree ( PRC_TYPE_ASM + 4 ) // Basic structure for PRC files : tree. -#define PRC_TYPE_ASM_FileStructureTessellation ( PRC_TYPE_ASM + 5 ) // Basic structure for PRC files : tessellation. -#define PRC_TYPE_ASM_FileStructureGeometry ( PRC_TYPE_ASM + 6 ) // Basic structure for PRC files : geometry. -#define PRC_TYPE_ASM_FileStructureExtraGeometry ( PRC_TYPE_ASM + 7 ) // Basic structure for PRC files : extra geometry data. -#define PRC_TYPE_ASM_ProductOccurence ( PRC_TYPE_ASM + 10 ) // Basic contruct for assemblies. -#define PRC_TYPE_ASM_PartDefinition ( PRC_TYPE_ASM + 11 ) // Basic construct for parts. - -#define PRC_TYPE_MKP_View ( PRC_TYPE_MKP + 1 ) // Grouping of markup by views. -#define PRC_TYPE_MKP_Markup ( PRC_TYPE_MKP + 2 ) // Basic type for simple markups. -#define PRC_TYPE_MKP_Leader ( PRC_TYPE_MKP + 3 ) // basic type for markup leader -#define PRC_TYPE_MKP_AnnotationItem ( PRC_TYPE_MKP + 4 ) // Usage of a markup. -#define PRC_TYPE_MKP_AnnotationSet ( PRC_TYPE_MKP + 5 ) // Group of annotations. -#define PRC_TYPE_MKP_AnnotationReference ( PRC_TYPE_MKP + 6 ) // Logical grouping of annotations for reference. - -#define PRC_TYPE_GRAPH_Style ( PRC_TYPE_GRAPH + 1 ) // Display style. -#define PRC_TYPE_GRAPH_Material ( PRC_TYPE_GRAPH + 2 ) // Display material properties. -#define PRC_TYPE_GRAPH_Picture ( PRC_TYPE_GRAPH + 3 ) // Picture. -#define PRC_TYPE_GRAPH_TextureApplication ( PRC_TYPE_GRAPH + 11 ) // Texture application. -#define PRC_TYPE_GRAPH_TextureDefinition ( PRC_TYPE_GRAPH + 12 ) // Texture definition. -#define PRC_TYPE_GRAPH_TextureTransformation ( PRC_TYPE_GRAPH + 13 ) // Texture transformation. -#define PRC_TYPE_GRAPH_LinePattern ( PRC_TYPE_GRAPH + 21 ) // One dimensional display style. -#define PRC_TYPE_GRAPH_FillPattern ( PRC_TYPE_GRAPH + 22 ) // Abstract class for two-dimensional display style. -#define PRC_TYPE_GRAPH_DottingPattern ( PRC_TYPE_GRAPH + 23 ) // Two-dimensional filling with dots. -#define PRC_TYPE_GRAPH_HatchingPattern ( PRC_TYPE_GRAPH + 24 ) // Two-dimensional filling with hatches. -#define PRC_TYPE_GRAPH_SolidPattern ( PRC_TYPE_GRAPH + 25 ) // Two-dimensional filling with particular style (color, material, texture). -#define PRC_TYPE_GRAPH_VPicturePattern ( PRC_TYPE_GRAPH + 26 ) // Two-dimensional filling with vectorised picture. -#define PRC_TYPE_GRAPH_AmbientLight ( PRC_TYPE_GRAPH + 31 ) // Scene ambient illumination. -#define PRC_TYPE_GRAPH_PointLight ( PRC_TYPE_GRAPH + 32 ) // Scene point illumination. -#define PRC_TYPE_GRAPH_DirectionalLight ( PRC_TYPE_GRAPH + 33 ) // Scene directional illumination. -#define PRC_TYPE_GRAPH_SpotLight ( PRC_TYPE_GRAPH + 34 ) // Scene spot illumination. -#define PRC_TYPE_GRAPH_SceneDisplayParameters ( PRC_TYPE_GRAPH + 41 ) // Parameters for scene visualisation. -#define PRC_TYPE_GRAPH_Camera ( PRC_TYPE_GRAPH + 42 ) // - -#define PRC_TYPE_MATH_FCT_1D ( PRC_TYPE_MATH + 1 ) // Basic type for one degree equation object. -#define PRC_TYPE_MATH_FCT_1D_Polynom ( PRC_TYPE_MATH_FCT_1D + 1 ) // Polynomial equation. -#define PRC_TYPE_MATH_FCT_1D_Trigonometric ( PRC_TYPE_MATH_FCT_1D + 2 ) // Cosinus based equation. -#define PRC_TYPE_MATH_FCT_1D_Fraction ( PRC_TYPE_MATH_FCT_1D + 3 ) // Fraction between 2 one degree equation object. -#define PRC_TYPE_MATH_FCT_1D_ArctanCos ( PRC_TYPE_MATH_FCT_1D + 4 ) // Specific equation. -#define PRC_TYPE_MATH_FCT_1D_Combination ( PRC_TYPE_MATH_FCT_1D + 5 ) // Combination of one degree equation object. -#define PRC_TYPE_MATH_FCT_3D ( PRC_TYPE_MATH + 10 ) // Basic type for 3rd degree equation object. -#define PRC_TYPE_MATH_FCT_3D_Linear ( PRC_TYPE_MATH_FCT_3D + 1 ) // Linear transformation ( with a matrix ). -#define PRC_TYPE_MATH_FCT_3D_NonLinear ( PRC_TYPE_MATH_FCT_3D + 2 ) // Specific transformation. - -#define PRC_PRODUCT_FLAG_DEFAULT 0x0001 -#define PRC_PRODUCT_FLAG_INTERNAL 0x0002 -#define PRC_PRODUCT_FLAG_CONTAINER 0x0004 -#define PRC_PRODUCT_FLAG_CONFIG 0x0008 -#define PRC_PRODUCT_FLAG_VIEW 0x0010 - -#define PRC_TRANSFORMATION_Identity 0x00 -#define PRC_TRANSFORMATION_Translate 0x01 -#define PRC_TRANSFORMATION_Rotate 0x02 -#define PRC_TRANSFORMATION_Mirror 0x04 -#define PRC_TRANSFORMATION_Scale 0x08 -#define PRC_TRANSFORMATION_NonUniformScale 0x10 -#define PRC_TRANSFORMATION_NonOrtho 0x20 -#define PRC_TRANSFORMATION_Homogeneous 0x40 - -#define PRC_FACETESSDATA_Polyface 0x0001 -#define PRC_FACETESSDATA_Triangle 0x0002 -#define PRC_FACETESSDATA_TriangleFan 0x0004 -#define PRC_FACETESSDATA_TriangleStripe 0x0008 -#define PRC_FACETESSDATA_PolyfaceOneNormal 0x0010 -#define PRC_FACETESSDATA_TriangleOneNormal 0x0020 -#define PRC_FACETESSDATA_TriangleFanOneNormal 0x0040 -#define PRC_FACETESSDATA_TriangleStripeOneNormal 0x0080 -#define PRC_FACETESSDATA_PolyfaceTextured 0x0100 -#define PRC_FACETESSDATA_TriangleTextured 0x0200 -#define PRC_FACETESSDATA_TriangleFanTextured 0x0400 -#define PRC_FACETESSDATA_TriangleStripeTextured 0x0800 -#define PRC_FACETESSDATA_PolyfaceOneNormalTextured 0x1000 -#define PRC_FACETESSDATA_TriangleOneNormalTextured 0x2000 -#define PRC_FACETESSDATA_TriangleFanOneNormalTextured 0x4000 -#define PRC_FACETESSDATA_TriangleStripeOneNormalTextured 0x8000 - -#define PRC_TEXTURE_MAPPING_DIFFUSE 0x0001 -#define PRC_TEXTURE_MAPPING_BUMP 0x0002 -#define PRC_TEXTURE_MAPPING_OPACITY 0x0004 -#define PRC_TEXTURE_MAPPING_SPHERICAL_REFLECTION 0x0008 -#define PRC_TEXTURE_MAPPING_CUBICAL_REFLECTION 0x0010 -#define PRC_TEXTURE_MAPPING_REFRACTION 0x0020 -#define PRC_TEXTURE_MAPPING_SPECULAR 0x0040 -#define PRC_TEXTURE_MAPPING_AMBIENT 0x0080 -#define PRC_TEXTURE_MAPPING_EMISSION 0x0100 -#define PRC_TEXTURE_APPLYING_MODE_NONE 0x00 // let the application choose -#define PRC_TEXTURE_APPLYING_MODE_LIGHTING 0x01 // use lighting mode -#define PRC_TEXTURE_APPLYING_MODE_ALPHATEST 0x02 // use alpha test -#define PRC_TEXTURE_APPLYING_MODE_VERTEXCOLOR 0x04 // combine a texture with one-color-per-vertex mode +#define PRC_TYPE_Unknown ( (uint32_t)-1 ) + +#define PRC_TYPE_ROOT 0 // This type does not correspond to any entity + +#define PRC_TYPE_ROOT_PRCBase ( PRC_TYPE_ROOT + 1 ) // Abstract root type for any PRC entity. +#define PRC_TYPE_ROOT_PRCBaseWithGraphics ( PRC_TYPE_ROOT + 2 ) // Abstract root type for any PRC entity which can bear graphics. + +#define PRC_TYPE_CRV ( PRC_TYPE_ROOT + 10 ) // Types for PRC geometrical curves +#define PRC_TYPE_SURF ( PRC_TYPE_ROOT + 75 ) // Types for PRC geometrical surfaces +#define PRC_TYPE_TOPO ( PRC_TYPE_ROOT + 140 ) // Types for PRC topology +#define PRC_TYPE_TESS ( PRC_TYPE_ROOT + 170 ) // Types for PRC tessellation +#define PRC_TYPE_MISC ( PRC_TYPE_ROOT + 200 ) // Types for PRC global data +#define PRC_TYPE_RI ( PRC_TYPE_ROOT + 230 ) // Types for PRC representation items +#define PRC_TYPE_ASM ( PRC_TYPE_ROOT + 300 ) // Types for PRC assembly +#define PRC_TYPE_MKP ( PRC_TYPE_ROOT + 500 ) // Types for PRC markup +#define PRC_TYPE_GRAPH ( PRC_TYPE_ROOT + 700 ) // Types for PRC graphics +#define PRC_TYPE_MATH ( PRC_TYPE_ROOT + 900 ) // Types for PRC mathematical operators + +#define PRC_TYPE_CRV_Base ( PRC_TYPE_CRV + 1 ) // Abstract type for all geometric curves. +#define PRC_TYPE_CRV_Blend02Boundary ( PRC_TYPE_CRV + 2 ) // Boundary Curve. +#define PRC_TYPE_CRV_NURBS ( PRC_TYPE_CRV + 3 ) // Non Uniform BSpline curve. +#define PRC_TYPE_CRV_Circle ( PRC_TYPE_CRV + 4 ) // Circle. +#define PRC_TYPE_CRV_Composite ( PRC_TYPE_CRV + 5 ) // Array of oriented curves. +#define PRC_TYPE_CRV_OnSurf ( PRC_TYPE_CRV + 6 ) // Curve defined by a UV curve on a surface. +#define PRC_TYPE_CRV_Ellipse ( PRC_TYPE_CRV + 7 ) // Ellipse. +#define PRC_TYPE_CRV_Equation ( PRC_TYPE_CRV + 8 ) // curve described by specific law elements +#define PRC_TYPE_CRV_Helix ( PRC_TYPE_CRV + 9 ) // Helix curve. +#define PRC_TYPE_CRV_Hyperbola ( PRC_TYPE_CRV + 10 ) // Hyperbola. +#define PRC_TYPE_CRV_Intersection ( PRC_TYPE_CRV + 11 ) // Intersection between 2 surfaces. +#define PRC_TYPE_CRV_Line ( PRC_TYPE_CRV + 12 ) // Line. +#define PRC_TYPE_CRV_Offset ( PRC_TYPE_CRV + 13 ) // Offset curve. +#define PRC_TYPE_CRV_Parabola ( PRC_TYPE_CRV + 14 ) // Parabola. +#define PRC_TYPE_CRV_PolyLine ( PRC_TYPE_CRV + 15 ) // Polyedric curve. +#define PRC_TYPE_CRV_Transform ( PRC_TYPE_CRV + 16 ) // Transformed curve. + +#define PRC_TYPE_SURF_Base ( PRC_TYPE_SURF + 1 ) // Abstract type for all geometric surfaces. +#define PRC_TYPE_SURF_Blend01 ( PRC_TYPE_SURF + 2 ) // Blend surface. +#define PRC_TYPE_SURF_Blend02 ( PRC_TYPE_SURF + 3 ) // Blend Surface. +#define PRC_TYPE_SURF_Blend03 ( PRC_TYPE_SURF + 4 ) // Blend Surface. +#define PRC_TYPE_SURF_NURBS ( PRC_TYPE_SURF + 5 ) // Non Uniform BSpline surface. +#define PRC_TYPE_SURF_Cone ( PRC_TYPE_SURF + 6 ) // Cone. +#define PRC_TYPE_SURF_Cylinder ( PRC_TYPE_SURF + 7 ) // Cylinder. +#define PRC_TYPE_SURF_Cylindrical ( PRC_TYPE_SURF + 8 ) // Surface who is defined in cylindrical space. +#define PRC_TYPE_SURF_Offset ( PRC_TYPE_SURF + 9 ) // Offset surface. +#define PRC_TYPE_SURF_Pipe ( PRC_TYPE_SURF + 10 ) // Pipe. +#define PRC_TYPE_SURF_Plane ( PRC_TYPE_SURF + 11 ) // Plane. +#define PRC_TYPE_SURF_Ruled ( PRC_TYPE_SURF + 12 ) // Ruled surface. +#define PRC_TYPE_SURF_Sphere ( PRC_TYPE_SURF + 13 ) // Sphere. +#define PRC_TYPE_SURF_Revolution ( PRC_TYPE_SURF + 14 ) // Surface of revolution. +#define PRC_TYPE_SURF_Extrusion ( PRC_TYPE_SURF + 15 ) // Surface of extrusion. +#define PRC_TYPE_SURF_FromCurves ( PRC_TYPE_SURF + 16 ) // Surface from two curves. +#define PRC_TYPE_SURF_Torus ( PRC_TYPE_SURF + 17 ) // Torus. +#define PRC_TYPE_SURF_Transform ( PRC_TYPE_SURF + 18 ) // Transformed surface. +#define PRC_TYPE_SURF_Blend04 ( PRC_TYPE_SURF + 19 ) // defined for future use. + +#define PRC_TYPE_TOPO_Context ( PRC_TYPE_TOPO + 1 ) // Self-containing set of topological entities. +#define PRC_TYPE_TOPO_Item ( PRC_TYPE_TOPO + 2 ) // Abstract root type for any topological entity (body or single item). +#define PRC_TYPE_TOPO_MultipleVertex ( PRC_TYPE_TOPO + 3 ) // Vertex whose position is the average of all edges' extremity positions to whom it belongs. +#define PRC_TYPE_TOPO_UniqueVertex ( PRC_TYPE_TOPO + 4 ) // Vertex with one set of coordinates (absolute position). +#define PRC_TYPE_TOPO_WireEdge ( PRC_TYPE_TOPO + 5 ) // Edge belonging to a wire body / single wire body. +#define PRC_TYPE_TOPO_Edge ( PRC_TYPE_TOPO + 6 ) // Edge belonging to a brep data. +#define PRC_TYPE_TOPO_CoEdge ( PRC_TYPE_TOPO + 7 ) // Usage of an edge in a loop. +#define PRC_TYPE_TOPO_Loop ( PRC_TYPE_TOPO + 8 ) // Array of co edges which delimits a face. +#define PRC_TYPE_TOPO_Face ( PRC_TYPE_TOPO + 9 ) // Topological face delimiting a shell. +#define PRC_TYPE_TOPO_Shell ( PRC_TYPE_TOPO + 10 ) // Topological shell (open or closed). +#define PRC_TYPE_TOPO_Connex ( PRC_TYPE_TOPO + 11 ) // Topological region delimited by one or several shells. +#define PRC_TYPE_TOPO_Body ( PRC_TYPE_TOPO + 12 ) // Abstract root type for any topological body. +#define PRC_TYPE_TOPO_SingleWireBody ( PRC_TYPE_TOPO + 13 ) // Single wire body. +#define PRC_TYPE_TOPO_BrepData ( PRC_TYPE_TOPO + 14 ) // Main entry to solid and surface topology (regular form). +#define PRC_TYPE_TOPO_SingleWireBodyCompress ( PRC_TYPE_TOPO + 15 ) // Single wire body. (ultra compressed form). +#define PRC_TYPE_TOPO_BrepDataCompress ( PRC_TYPE_TOPO + 16 ) // Main entry to solid and surface topology (ultra compressed form). +#define PRC_TYPE_TOPO_WireBody ( PRC_TYPE_TOPO + 17 ) // This type is the main entry to wire topology. + +#define PRC_TYPE_TESS_Base ( PRC_TYPE_TESS + 1 ) // Abstract root type for any tessellated entity. +#define PRC_TYPE_TESS_3D ( PRC_TYPE_TESS + 2 ) // Tessellated faceted data; regular form. +#define PRC_TYPE_TESS_3D_Compressed ( PRC_TYPE_TESS + 3 ) // Tessellated faceted data; highly compressed form. +#define PRC_TYPE_TESS_Face ( PRC_TYPE_TESS + 4 ) // Tessellated face. +#define PRC_TYPE_TESS_3D_Wire ( PRC_TYPE_TESS + 5 ) // Tessellated wireframe. +#define PRC_TYPE_TESS_Markup ( PRC_TYPE_TESS + 6 ) // Tessellated markup. + +#define PRC_TYPE_MISC_Attribute ( PRC_TYPE_MISC + 1 ) // Entity attribute. +#define PRC_TYPE_MISC_CartesianTransformation ( PRC_TYPE_MISC + 2 ) // Cartesian transformation. +#define PRC_TYPE_MISC_EntityReference ( PRC_TYPE_MISC + 3 ) // Entity reference. +#define PRC_TYPE_MISC_MarkupLinkedItem ( PRC_TYPE_MISC + 4 ) // Link between a markup and an entity. +#define PRC_TYPE_MISC_ReferenceOnPRCBase ( PRC_TYPE_MISC + 5 ) // Reference pointing on a regular entity (not topological). +#define PRC_TYPE_MISC_ReferenceOnTopology ( PRC_TYPE_MISC + 6 ) // Reference pointing on a topological entity. +#define PRC_TYPE_MISC_GeneralTransformation ( PRC_TYPE_MISC + 7 ) // General transformation. + +#define PRC_TYPE_RI_RepresentationItem ( PRC_TYPE_RI + 1 ) // Basic abstract type for representation items. +#define PRC_TYPE_RI_BrepModel ( PRC_TYPE_RI + 2 ) // Basic type for surfaces and solids. +#define PRC_TYPE_RI_Curve ( PRC_TYPE_RI + 3 ) // Basic type for curves. +#define PRC_TYPE_RI_Direction ( PRC_TYPE_RI + 4 ) // Optional point + vector. +#define PRC_TYPE_RI_Plane ( PRC_TYPE_RI + 5 ) // Construction plane, as opposed to planar surface. +#define PRC_TYPE_RI_PointSet ( PRC_TYPE_RI + 6 ) // Set of points. +#define PRC_TYPE_RI_PolyBrepModel ( PRC_TYPE_RI + 7 ) // Basic type to polyhedral surfaces and solids. +#define PRC_TYPE_RI_PolyWire ( PRC_TYPE_RI + 8 ) // Polyedric wireframe entity. +#define PRC_TYPE_RI_Set ( PRC_TYPE_RI + 9 ) // Logical grouping of arbitrary number of representation items. +#define PRC_TYPE_RI_CoordinateSystem ( PRC_TYPE_RI + 10 ) // Coordinate system. + +#define PRC_TYPE_ASM_ModelFile ( PRC_TYPE_ASM + 1 ) // Basic entry type for PRC. +#define PRC_TYPE_ASM_FileStructure ( PRC_TYPE_ASM + 2 ) // Basic structure for PRC files. +#define PRC_TYPE_ASM_FileStructureGlobals ( PRC_TYPE_ASM + 3 ) // Basic structure for PRC files : globals. +#define PRC_TYPE_ASM_FileStructureTree ( PRC_TYPE_ASM + 4 ) // Basic structure for PRC files : tree. +#define PRC_TYPE_ASM_FileStructureTessellation ( PRC_TYPE_ASM + 5 ) // Basic structure for PRC files : tessellation. +#define PRC_TYPE_ASM_FileStructureGeometry ( PRC_TYPE_ASM + 6 ) // Basic structure for PRC files : geometry. +#define PRC_TYPE_ASM_FileStructureExtraGeometry ( PRC_TYPE_ASM + 7 ) // Basic structure for PRC files : extra geometry data. +#define PRC_TYPE_ASM_ProductOccurence ( PRC_TYPE_ASM + 10 ) // Basic contruct for assemblies. +#define PRC_TYPE_ASM_PartDefinition ( PRC_TYPE_ASM + 11 ) // Basic construct for parts. +#define PRC_TYPE_ASM_Filter ( PRC_TYPE_ASM + 20 ) + +#define PRC_TYPE_MKP_View ( PRC_TYPE_MKP + 1 ) // Grouping of markup by views. +#define PRC_TYPE_MKP_Markup ( PRC_TYPE_MKP + 2 ) // Basic type for simple markups. +#define PRC_TYPE_MKP_Leader ( PRC_TYPE_MKP + 3 ) // basic type for markup leader +#define PRC_TYPE_MKP_AnnotationItem ( PRC_TYPE_MKP + 4 ) // Usage of a markup. +#define PRC_TYPE_MKP_AnnotationSet ( PRC_TYPE_MKP + 5 ) // Group of annotations. +#define PRC_TYPE_MKP_AnnotationReference ( PRC_TYPE_MKP + 6 ) // Logical grouping of annotations for reference. + +#define PRC_TYPE_GRAPH_Style ( PRC_TYPE_GRAPH + 1 ) // Display style. +#define PRC_TYPE_GRAPH_Material ( PRC_TYPE_GRAPH + 2 ) // Display material properties. +#define PRC_TYPE_GRAPH_Picture ( PRC_TYPE_GRAPH + 3 ) // Picture. +#define PRC_TYPE_GRAPH_TextureApplication ( PRC_TYPE_GRAPH + 11 ) // Texture application. +#define PRC_TYPE_GRAPH_TextureDefinition ( PRC_TYPE_GRAPH + 12 ) // Texture definition. +#define PRC_TYPE_GRAPH_TextureTransformation ( PRC_TYPE_GRAPH + 13 ) // Texture transformation. +#define PRC_TYPE_GRAPH_LinePattern ( PRC_TYPE_GRAPH + 21 ) // One dimensional display style. +#define PRC_TYPE_GRAPH_FillPattern ( PRC_TYPE_GRAPH + 22 ) // Abstract class for two-dimensional display style. +#define PRC_TYPE_GRAPH_DottingPattern ( PRC_TYPE_GRAPH + 23 ) // Two-dimensional filling with dots. +#define PRC_TYPE_GRAPH_HatchingPattern ( PRC_TYPE_GRAPH + 24 ) // Two-dimensional filling with hatches. +#define PRC_TYPE_GRAPH_SolidPattern ( PRC_TYPE_GRAPH + 25 ) // Two-dimensional filling with particular style (color, material, texture). +#define PRC_TYPE_GRAPH_VPicturePattern ( PRC_TYPE_GRAPH + 26 ) // Two-dimensional filling with vectorised picture. +#define PRC_TYPE_GRAPH_AmbientLight ( PRC_TYPE_GRAPH + 31 ) // Scene ambient illumination. +#define PRC_TYPE_GRAPH_PointLight ( PRC_TYPE_GRAPH + 32 ) // Scene point illumination. +#define PRC_TYPE_GRAPH_DirectionalLight ( PRC_TYPE_GRAPH + 33 ) // Scene directional illumination. +#define PRC_TYPE_GRAPH_SpotLight ( PRC_TYPE_GRAPH + 34 ) // Scene spot illumination. +#define PRC_TYPE_GRAPH_SceneDisplayParameters ( PRC_TYPE_GRAPH + 41 ) // Parameters for scene visualisation. +#define PRC_TYPE_GRAPH_Camera ( PRC_TYPE_GRAPH + 42 ) // + +#define PRC_TYPE_MATH_FCT_1D ( PRC_TYPE_MATH + 1 ) // Basic type for one degree equation object. +#define PRC_TYPE_MATH_FCT_1D_Polynom ( PRC_TYPE_MATH_FCT_1D + 1 ) // Polynomial equation. +#define PRC_TYPE_MATH_FCT_1D_Trigonometric ( PRC_TYPE_MATH_FCT_1D + 2 ) // Cosinus based equation. +#define PRC_TYPE_MATH_FCT_1D_Fraction ( PRC_TYPE_MATH_FCT_1D + 3 ) // Fraction between 2 one degree equation object. +#define PRC_TYPE_MATH_FCT_1D_ArctanCos ( PRC_TYPE_MATH_FCT_1D + 4 ) // Specific equation. +#define PRC_TYPE_MATH_FCT_1D_Combination ( PRC_TYPE_MATH_FCT_1D + 5 ) // Combination of one degree equation object. +#define PRC_TYPE_MATH_FCT_3D ( PRC_TYPE_MATH + 10 ) // Basic type for 3rd degree equation object. +#define PRC_TYPE_MATH_FCT_3D_Linear ( PRC_TYPE_MATH_FCT_3D + 1 ) // Linear transformation ( with a matrix ). +#define PRC_TYPE_MATH_FCT_3D_NonLinear ( PRC_TYPE_MATH_FCT_3D + 2 ) // Specific transformation. + +#define PRC_PRODUCT_FLAG_DEFAULT 0x0001 +#define PRC_PRODUCT_FLAG_INTERNAL 0x0002 +#define PRC_PRODUCT_FLAG_CONTAINER 0x0004 +#define PRC_PRODUCT_FLAG_CONFIG 0x0008 +#define PRC_PRODUCT_FLAG_VIEW 0x0010 + +#define PRC_TRANSFORMATION_Identity 0x00 +#define PRC_TRANSFORMATION_Translate 0x01 +#define PRC_TRANSFORMATION_Rotate 0x02 +#define PRC_TRANSFORMATION_Mirror 0x04 +#define PRC_TRANSFORMATION_Scale 0x08 +#define PRC_TRANSFORMATION_NonUniformScale 0x10 +#define PRC_TRANSFORMATION_NonOrtho 0x20 +#define PRC_TRANSFORMATION_Homogeneous 0x40 + +#define PRC_FACETESSDATA_Polyface 0x0001 +#define PRC_FACETESSDATA_Triangle 0x0002 +#define PRC_FACETESSDATA_TriangleFan 0x0004 +#define PRC_FACETESSDATA_TriangleStripe 0x0008 +#define PRC_FACETESSDATA_PolyfaceOneNormal 0x0010 +#define PRC_FACETESSDATA_TriangleOneNormal 0x0020 +#define PRC_FACETESSDATA_TriangleFanOneNormal 0x0040 +#define PRC_FACETESSDATA_TriangleStripeOneNormal 0x0080 +#define PRC_FACETESSDATA_PolyfaceTextured 0x0100 +#define PRC_FACETESSDATA_TriangleTextured 0x0200 +#define PRC_FACETESSDATA_TriangleFanTextured 0x0400 +#define PRC_FACETESSDATA_TriangleStripeTextured 0x0800 +#define PRC_FACETESSDATA_PolyfaceOneNormalTextured 0x1000 +#define PRC_FACETESSDATA_TriangleOneNormalTextured 0x2000 +#define PRC_FACETESSDATA_TriangleFanOneNormalTextured 0x4000 +#define PRC_FACETESSDATA_TriangleStripeOneNormalTextured 0x8000 +#define PRC_FACETESSDATA_NORMAL_Single 0x40000000 +#define PRC_FACETESSDATA_NORMAL_Mask 0x3FFFFFFF +#define PRC_FACETESSDATA_WIRE_IsNotDrawn 0x4000 // Indicates that the edge should not be drawn (its neighbor will be drawn). +#define PRC_FACETESSDATA_WIRE_IsClosing 0x8000 // Indicates that this is the last edge of a loop. + +#define PRC_3DWIRETESSDATA_IsClosing 0x10000000 // Indicates that the first point is implicitely repeated after the last one to close the wire edge. +#define PRC_3DWIRETESSDATA_IsContinuous 0x20000000 // Indicates that the last point of the preceding wire should be linked with the first point of the current one. + +#define PRC_TEXTURE_MAPPING_DIFFUSE 0x0001 // Diffuse texture mapping attribute. Default value. +#define PRC_TEXTURE_MAPPING_BUMP 0x0002 // Bump texture mapping attribute. +#define PRC_TEXTURE_MAPPING_OPACITY 0x0004 // Opacity texture mapping attribute. +#define PRC_TEXTURE_MAPPING_SPHERICAL_REFLECTION 0x0008 // Spherical reflection texture mapping attribute (used for environment mapping). +#define PRC_TEXTURE_MAPPING_CUBICAL_REFLECTION 0x0010 // Cubical reflection texture mapping attribute (used for environment mapping). +#define PRC_TEXTURE_MAPPING_REFRACTION 0x0020 // Refraction texture mapping attribute. +#define PRC_TEXTURE_MAPPING_SPECULAR 0x0040 // Specular texture mapping attribute. +#define PRC_TEXTURE_MAPPING_AMBIENT 0x0080 // Ambient texture mapping attribute. +#define PRC_TEXTURE_MAPPING_EMISSION 0x0100 // Emission texture mapping attribute. + +#define PRC_TEXTURE_APPLYING_MODE_NONE 0x00 // let the application choose +#define PRC_TEXTURE_APPLYING_MODE_LIGHTING 0x01 // use lighting mode +#define PRC_TEXTURE_APPLYING_MODE_ALPHATEST 0x02 // use alpha test +#define PRC_TEXTURE_APPLYING_MODE_VERTEXCOLOR 0x04 // combine a texture with one-color-per-vertex mode + +#define PRC_TEXTURE_MAPPING_COMPONENTS_RED 0x0001 // Red texture mapping component. +#define PRC_TEXTURE_MAPPING_COMPONENTS_GREEN 0x0002 // Green texture mapping component. +#define PRC_TEXTURE_MAPPING_COMPONENTS_BLUE 0x0004 // Blue texture mapping component. +#define PRC_TEXTURE_MAPPING_COMPONENTS_RGB 0x0007 // RGB texture mapping component. +#define PRC_TEXTURE_MAPPING_COMPONENTS_ALPHA 0x0008 // Alpha texture mapping component. +#define PRC_TEXTURE_MAPPING_COMPONENTS_RGBA 0x000F // RGBA texture mapping component. enum EPRCModellerAttributeType { KEPRCModellerAttributeTypeNull = 0, @@ -221,83 +239,260 @@ enum EPRCProductLoadStatus { KEPRCProductLoadStatus_Loaded }; -enum EPRCExtendType { - KEPRCExtendTypeNone = 0, - KEPRCExtendTypeExt1 = 2, - KEPRCExtendTypeExt2 = 4, - KEPRCExtendTypeG1 = 6, - KEPRCExtendTypeG1R = 8, - KEPRCExtendTypeG1_G2 = 10, - KEPRCExtendTypeCInfinity = 12 +enum EPRCExtendType { + KEPRCExtendTypeNone = 0, // Discontinuous position. + KEPRCExtendTypeExt1 = 2, // Same as EPRCExtendTypeCInfinity. + KEPRCExtendTypeExt2 = 4, // Same as EPRCExtendTypeG1R for surface, and EPRCExtendTypeG1 for curve. + KEPRCExtendTypeG1 = 6, // Continuous in direction but not magnitude of first derivative. + KEPRCExtendTypeG1R = 8, // Surface extended with a ruled surface that connects with G1-continuity. + KEPRCExtendTypeG1_G2 = 10, // Extended by reflection, yielding a G2 continuous extension. + KEPRCExtendTypeCInfinity = 12 // Unlimited continuity. }; -enum EPRCKnotType { - KEPRCKnotTypeUniformKnots, - KEPRCKnotTypeUnspecified, - KEPRCKnotTypeQuasiUniformKnots, - KEPRCKnotTypePiecewiseBezierKnots -}; +enum EPRCKnotType { // Knot vector type + KEPRCKnotTypeUniformKnots, // Uniform knot vector. + KEPRCKnotTypeUnspecified, // Unspecified knot type. + KEPRCKnotTypeQuasiUniformKnots, // Quasi-uniform knot vector. + KEPRCKnotTypePiecewiseBezierKnots // Extrema with multiplicities of degree +1. +}; // Note : this value is currently unused and should be set to KEPRCKnotTypeUnspecified. + enum EPRCBSplineSurfaceForm { - KEPRCBSplineSurfaceFormPlane, - KEPRCBSplineSurfaceFormCylindrical, - KEPRCBSplineSurfaceFormConical, - KEPRCBSplineSurfaceFormSpherical, - KEPRCBSplineSurfaceFormRevolution, - KEPRCBSplineSurfaceFormRuled, - KEPRCBSplineSurfaceFormGeneralizedCone, - KEPRCBSplineSurfaceFormQuadric, - KEPRCBSplineSurfaceFormLinearExtrusion, - KEPRCBSplineSurfaceFormUnspecified, - KEPRCBSplineSurfaceFormPolynomial + KEPRCBSplineSurfaceFormPlane, // Planar surface. + KEPRCBSplineSurfaceFormCylindrical, // Cylindrical surface. + KEPRCBSplineSurfaceFormConical, // Conical surface. + KEPRCBSplineSurfaceFormSpherical, // Spherical surface. + KEPRCBSplineSurfaceFormRevolution, // Surface of revolution. + KEPRCBSplineSurfaceFormRuled, // Ruled surface. + KEPRCBSplineSurfaceFormGeneralizedCone, // Cone. + KEPRCBSplineSurfaceFormQuadric, // Quadric surface. + KEPRCBSplineSurfaceFormLinearExtrusion, // Surface of extrusion. + KEPRCBSplineSurfaceFormUnspecified, // Unspecified surface. + KEPRCBSplineSurfaceFormPolynomial // Polynomial surface. +}; + +enum EPRCBSplineCurveForm { // NURBS curve form + KEPRCBSplineCurveFormUnspecified, // Unspecified curve form. + KEPRCBSplineCurveFormPolyline, // Polygon. + KEPRCBSplineCurveFormCircularArc, // Circle arc. + KEPRCBSplineCurveFormEllipticArc, // Elliptical arc. + KEPRCBSplineCurveFormParabolicArc, // Parabolic arc. + KEPRCBSplineCurveFormHyperbolicArc // Hyperbolic arc. +}; // Note : this value is currently unused and should be set to KEPRCBSplineCurveFormUnspecified. + +enum EPRCTextureMappingType { // Defines how to retrieve mapping coordinates. + KEPRCTextureMappingType_Unknown, // Let the application choose. + KEPRCTextureMappingType_Stored, // Use the mapping coordinates that are stored on a 3D tessellation object + KEPRCTextureMappingType_Parametric, // Retrieve the UV coordinates on the surface as mapping coordinates + KEPRCTextureMappingType_Operator // Use the defined Texture mapping operator to calculate mapping coordinates +}; + +enum EPRCTextureFunction { // Defines how to paint a texture on the surface being rendered. + KEPRCTextureFunction_Unknown, // Let the application choose. + KEPRCTextureFunction_Modulate, // Combine lighting with texturing. This is the default value. + KEPRCTextureFunction_Replace, // Replace the object color with texture color data. + KEPRCTextureFunction_Blend, // Reserved for future use. + KEPRCTextureFunction_Decal // Reserved for future use. }; -enum EPRCBSplineCurveForm { - KEPRCBSplineCurveFormUnspecified, - KEPRCBSplineCurveFormPolyline, - KEPRCBSplineCurveFormCircularArc, - KEPRCBSplineCurveFormEllipticArc, - KEPRCBSplineCurveFormParabolicArc, - KEPRCBSplineCurveFormHyperbolicArc +enum EPRCTextureMappingOperator { // The operator to use when computing mapping coordinates. + KEPRCTextureMappingOperator_Unknown, // Default value + KEPRCTextureMappingOperator_Planar, // Reserved for future use + KEPRCTextureMappingOperator_Cylindrical, // Reserved for future use + KEPRCTextureMappingOperator_Spherical, // Reserved for future use + KEPRCTextureMappingOperator_Cubical // Reserved for future use }; -enum EPRCTextureMappingType { - KEPRCTextureMappingType_Unknown, - KEPRCTextureMappingType_Stored, - KEPRCTextureMappingType_Parametric, - KEPRCTextureMappingType_Operator +enum EPRCTextureBlendParameter { // Reserved for future use. Defines how to apply blending. + KEPRCTextureBlendParameter_Unknown, // Default value. + KEPRCTextureBlendParameter_Zero, // Reserved for future use. + KEPRCTextureBlendParameter_One, // Reserved for future use. + KEPRCTextureBlendParameter_SrcColor, // Reserved for future use. + KEPRCTextureBlendParameter_OneMinusSrcColor, // Reserved for future use. + KEPRCTextureBlendParameter_DstColor, // Reserved for future use. + KEPRCTextureBlendParameter_OneMinusDstColor, // Reserved for future use. + KEPRCTextureBlendParameter_SrcAlpha, // Reserved for future use. + KEPRCTextureBlendParameter_OneMinusSrcAlpha, // Reserved for future use. + KEPRCTextureBlendParameter_DstAlpha, // Reserved for future use. + KEPRCTextureBlendParameter_OneMinusDstAlpha, // Reserved for future use. + KEPRCTextureBlendParameter_SrcAlphaSaturate // Reserved for future use. }; -enum EPRCTextureFunction { - KEPRCTextureFunction_Unknown, - KEPRCTextureFunction_Modulate, - KEPRCTextureFunction_Replace, - KEPRCTextureFunction_Blend, - KEPRCTextureFunction_Decal +enum EPRCTextureWrappingMode { // Defines repeating and clamping texture modes. + KEPRCTextureWrappingMode_Unknown, // Let the application choose. + KEPRCTextureWrappingMode_Repeat, // Display the repeated texture on the surface. + KEPRCTextureWrappingMode_ClampToBorder, // Clamp the texture to the border. Display the surface color along the texture limits. + KEPRCTextureWrappingMode_Clamp, // Reserved for future use. + KEPRCTextureWrappingMode_ClampToEdge, // Reserved for future use. + KEPRCTextureWrappingMode_MirroredRepeat // Reserved for future use. }; -enum EPRCTextureBlendParameter { - KEPRCTextureBlendParameter_Unknown, - KEPRCTextureBlendParameter_Zero, - KEPRCTextureBlendParameter_One, - KEPRCTextureBlendParameter_SrcColor, - KEPRCTextureBlendParameter_OneMinusSrcColor, - KEPRCTextureBlendParameter_DstColor, - KEPRCTextureBlendParameter_OneMinusDstColor, - KEPRCTextureBlendParameter_SrcAlpha, - KEPRCTextureBlendParameter_OneMinusSrcAlpha, - KEPRCTextureBlendParameter_DstAlpha, - KEPRCTextureBlendParameter_OneMinusDstAlpha, - KEPRCTextureBlendParameter_SrcAlphaSaturate +enum EPRCTextureAlphaTest { // Reserved for future use. Defines how to use a texture alpha test. + KEPRCTextureAlphaTest_Unknown, // Default value. + KEPRCTextureAlphaTest_Never, // Reserved for future use. + KEPRCTextureAlphaTest_Less, // Reserved for future use. + KEPRCTextureAlphaTest_Equal, // Reserved for future use. + KEPRCTextureAlphaTest_Lequal, // Reserved for future use. + KEPRCTextureAlphaTest_Greater, // Reserved for future use. + KEPRCTextureAlphaTest_Notequal, // Reserved for future use. + KEPRCTextureAlphaTest_Gequal, // Reserved for future use. + KEPRCTextureAlphaTest_Always // Reserved for future use. }; -enum EPRCTextureWrappingMode { - KEPRCTextureWrappingMode_Unknown, - KEPRCTextureWrappingMode_Repeat, - KEPRCTextureWrappingMode_ClampToBorder, - KEPRCTextureWrappingMode_Clamp, - KEPRCTextureWrappingMode_ClampToEdge, - KEPRCTextureWrappingMode_MirroredRepeat + +// Bit field for graphics behavior +#define PRC_GRAPHICS_Show 0x0001 // The entity is shown. +#define PRC_GRAPHICS_SonHeritShow 0x0002 // Shown entity son inheritance. +#define PRC_GRAPHICS_FatherHeritShow 0x0004 // Shown entity father inheritance. +#define PRC_GRAPHICS_SonHeritColor 0x0008 // Color/material son inheritance. +#define PRC_GRAPHICS_FatherHeritColor 0x0010 // Color/material father inheritance. +#define PRC_GRAPHICS_SonHeritLayer 0x0020 // Layer son inheritance. +#define PRC_GRAPHICS_FatherHeritLayer 0x0040 // Layer father inheritance. +#define PRC_GRAPHICS_SonHeritTransparency 0x0080 // Transparency son inheritance. +#define PRC_GRAPHICS_FatherHeritTransparency 0x0100 // Transparency father inheritance. +#define PRC_GRAPHICS_SonHeritLinePattern 0x0200 // Line pattern son inheritance. +#define PRC_GRAPHICS_FatherHeritLinePattern 0x0400 // Line pattern father inheritance. +#define PRC_GRAPHICS_SonHeritLineWidth 0x0800 // Line width son inheritance. +#define PRC_GRAPHICS_FatherHeritLineWidth 0x1000 // Line width father inheritance. +#define PRC_GRAPHICS_Removed 0x2000 // The entity has been removed and no longer appears in the tree. + +enum EPRCMarkupType { + KEPRCMarkupType_Unknown = 0, + KEPRCMarkupType_Text, + KEPRCMarkupType_Dimension, + KEPRCMarkupType_Arrow, + KEPRCMarkupType_Balloon, + KEPRCMarkupType_CircleCenter, + KEPRCMarkupType_Coordinate, + KEPRCMarkupType_Datum, + KEPRCMarkupType_Fastener, + KEPRCMarkupType_Gdt, + KEPRCMarkupType_Locator, + KEPRCMarkupType_MeasurementPoint, + KEPRCMarkupType_Roughness, + KEPRCMarkupType_Welding, + KEPRCMarkupType_Table, + KEPRCMarkupType_Other +}; + +enum EPRCMarkupSubType { + KEPRCMarkupSubType_Unknown = 0, + KEPRCMarkupSubType_EnumMax, + + KEPRCMarkupSubType_Datum_Ident = 1 , + KEPRCMarkupSubType_Datum_EnumMax, + + KEPRCMarkupSubType_Dimension_Distance = 1, + KEPRCMarkupSubType_Dimension_Radius_Tangent, + KEPRCMarkupSubType_Dimension_Radius_Cylinder, + KEPRCMarkupSubType_Dimension_Radius_Edge, + KEPRCMarkupSubType_Dimension_Diameter, + KEPRCMarkupSubType_Dimension_Diameter_Tangent, + KEPRCMarkupSubType_Dimension_Diameter_Cylinder, + KEPRCMarkupSubType_Dimension_Diameter_Edge, + KEPRCMarkupSubType_Dimension_Diameter_Cone, + KEPRCMarkupSubType_Dimension_Length, + KEPRCMarkupSubType_Dimension_Length_Curvilinear, + KEPRCMarkupSubType_Dimension_Length_Circular, + KEPRCMarkupSubType_Dimension_Angle, + KEPRCMarkupSubType_Dimension_EnumMax, + + KEPRCMarkupSubType_Gdt_Fcf = 1, + KEPRCMarkupSubType_Gdt_EnumMax, + + KEPRCMarkupSubType_Welding_Line = 1, + KEPRCMarkupSubType_Welding_EnumMax, + + KEPRCMarkupSubType_Other_Symbol_User = 1, + KEPRCMarkupSubType_Other_EnumMax }; +#define PRC_MARKUP_IsHidden 0x01 // The tessellation is hidden. +#define PRC_MARKUP_HasFrame 0x02 // The tessellation has a frame. +#define PRC_MARKUP_IsNotModifiable 0x04 // The tessellation is given and should not be modified. +#define PRC_MARKUP_IsZoomable 0x08 // The tessellation has zoom capability. +#define PRC_MARKUP_IsOnTop 0x10 // The tessellation is on top of the geometry. +#define PRC_MARKUP_IsFlipable 0x20 // The text tessellation can be flipped to always be readable on screen. This value is currently unused. + +#define PRC_RENDERING_PARAMETER_SPECIAL_CULLING 0x0001 // special culling strategy to apply +#define PRC_RENDERING_PARAMETER_FRONT_CULLING 0x0002 // apply front culling (ignored if no special culling strategy) +#define PRC_RENDERING_PARAMETER_BACK_CULLING 0x0004 // apply back culling (ignored if no special culling strategy) +#define PRC_RENDERING_PARAMETER_NO_LIGHT 0x0008 // if set, no light will apply on corresponding object + +#define PRC_MARKUP_IsMatrix 0x08000000 // Bit to denote that the current entity is a matrix. +#define PRC_MARKUP_IsExtraData 0x04000000 // Bit to denote that the current entity is extra data (it is neither a matrix nor a polyline). +#define PRC_MARKUP_IntegerMask 0xFFFFF // Integer mask to retrieve sizes. +#define PRC_MARKUP_ExtraDataType 0x3E00000 // Mask to retrieve the integer type of the entity. + +#define PRC_MARKUP_ExtraDataType_Pattern (( 0<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Picture (( 1<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Triangles (( 2<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Quads (( 3<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_FaceViewMode (( 6<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_FrameDrawMode (( 7<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_FixedSizeMode (( 8<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Symbol (( 9<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Cylinder ((10<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Color ((11<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_LineStipple ((12<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Font ((13<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Text ((14<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Points ((15<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_Polygon ((16<<21)|PRC_MARKUP_IsExtraData) +#define PRC_MARKUP_ExtraDataType_LineWidth ((17<<21)|PRC_MARKUP_IsExtraData) + +enum EPRCCharSet +{ + KEPRCCharsetUnknown = -1, + KEPRCCharsetRoman = 0, + KEPRCCharsetJapanese, + KEPRCCharsetTraditionalChinese, + KEPRCCharsetKorean, + KEPRCCharsetArabic, + KEPRCCharsetHebrew, + KEPRCCharsetGreek, + KEPRCCharsetCyrillic, + KEPRCCharsetRightLeft, + KEPRCCharsetDevanagari, + KEPRCCharsetGurmukhi, + KEPRCCharsetGujarati, + KEPRCCharsetOriya, + KEPRCCharsetBengali, + KEPRCCharsetTamil, + KEPRCCharsetTelugu, + KEPRCCharsetKannada, + KEPRCCharsetMalayalam, + KEPRCCharsetSinhalese, + KEPRCCharsetBurmese, + KEPRCCharsetKhmer, + KEPRCCharsetThai, + KEPRCCharsetLaotian, + KEPRCCharsetGeorgian, + KEPRCCharsetArmenian, + KEPRCCharsetSimplifiedChinese, + KEPRCCharsetTibetan, + KEPRCCharsetMongolian, + KEPRCCharsetGeez, + KEPRCCharsetEastEuropeanRoman, + KEPRCCharsetVietnamese, + KEPRCCharsetExtendedArabic +}; + +#define PRC_Font_Bold 0x02 /*!< Bold. */ +#define PRC_Font_Italic 0x04 /*!< Italic. */ +#define PRC_Font_Underlined 0x08 /*!< Underlined. */ +#define PRC_Font_StrikedOut 0x10 /*!< Striked-out. */ +#define PRC_Font_Overlined 0x20 /*!< Overlined. */ +#define PRC_Font_Streched 0x40 /*!< Streched. In case the font used is not the original font, it indicates that the text needs to be stretched to fit its bounding box. */ +#define PRC_Font_Wired 0x80 /*!< Wired. Indicates that the original font is a wirefame font. */ +#define PRC_Font_FixedWidth 0x100 /*!< Fixed width. Indicates that the original font is not proportional (each glyph has the same width). */ + +#define PRC_CONTEXT_OuterLoopFirst 0x0001 // Outer loops are always first loops (specific to PRC_TYPE_TOPO_BrepData). +#define PRC_CONTEXT_NoClamp 0x0002 // UV curves are clamped on the surface (specific to PRC_TYPE_TOPO_BrepData). +#define PRC_CONTEXT_NoSplit 0x0004 // Faces are split (specific to PRC_TYPE_TOPO_BrepData). + +#define PRC_BODY_BBOX_Evaluation 0x0001 // Bounding box based on geometry. +#define PRC_BODY_BBOX_Precise 0x0002 // Bounding box based on tessellation. +#define PRC_BODY_BBOX_CADData 0x0003 // Bounding box given by a CAD data file. + #endif // __PRC_H diff --git a/Build/source/utils/asymptote/prc/PRCdouble.h b/Build/source/utils/asymptote/prc/PRCdouble.h index c21d33e5dc9..ae4e8fedb8c 100644 --- a/Build/source/utils/asymptote/prc/PRCdouble.h +++ b/Build/source/utils/asymptote/prc/PRCdouble.h @@ -8,6 +8,17 @@ #include "config.h" #endif +#ifdef BYTE_ORDER +# undef WORDS_BIG_ENDIAN +# undef WORDS_LITTLE_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN +# define WORDS_BIG_ENDIAN 1 +# endif +# if BYTE_ORDER == LITTLE_ENDIAN +# define WORDS_LITTLE_ENDIAN 1 +# endif +#endif + // from Adobe's documentation union ieee754_double @@ -32,8 +43,22 @@ union ieee754_double } ieee; }; - - +union ieee754_float +{ + float f; + /* This is the IEEE 754 float-precision format. */ + struct { +#ifdef WORDS_BIGENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int mantissa:23; +#else + unsigned int mantissa:23; + unsigned int exponent:8; + unsigned int negative:1; +#endif + } ieee; +}; enum ValueType {VT_double,VT_exponent}; diff --git a/Build/source/utils/asymptote/prc/oPRCFile.cc b/Build/source/utils/asymptote/prc/oPRCFile.cc index 73c7ef32efe..37397b1e675 100644 --- a/Build/source/utils/asymptote/prc/oPRCFile.cc +++ b/Build/source/utils/asymptote/prc/oPRCFile.cc @@ -2,6 +2,7 @@ * * This file is part of a tool for producing 3D content in the PRC format. * Copyright (C) 2008 Orest Shardt <shardtor (at) gmail dot com> +* with enhancements contributed by Michail Vidiassov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -21,269 +22,37 @@ #include "oPRCFile.h" #include <time.h> #include <sstream> +#include <iostream> +#include <fstream> +#include <string> +#include <zlib.h> +#include <string.h> + +#define WriteUnsignedInteger( value ) out << (uint32_t)(value); +#define WriteInteger( value ) out << (int32_t)(value); +#define SerializeContentPRCBase write(out); +#define SerializeRgbColor( value ) (value).serializeRgbColor(out); +#define SerializePicture( value ) (value).serializePicture(out); +#define SerializeTextureDefinition( value ) (value)->serializeTextureDefinition(out); +#define SerializeMarkup( value ) (value)->serializeMarkup(out); +#define SerializeAnnotationEntity( value ) (value)->serializeAnnotationEntity(out); +#define SerializeFontKeysSameFont( value ) (value).serializeFontKeysSameFont(out); +#define SerializeMaterial( value ) (value)->serializeMaterial(out); + +#define SerializeCategory1LineStyle( value ) (value)->serializeCategory1LineStyle(out); +#define SerializeCoordinateSystem( value ) (value)->serializeCoordinateSystem(out); +#define SerializeRepresentationItem( value ) (value)->serializeRepresentationItem(out); +#define SerializePartDefinition( value ) (value)->serializePartDefinition(out); +#define SerializeProductOccurrence( value ) (value)->serializeProductOccurrence(out); +#define SerializeContextAndBodies( value ) (fileStructure->value)->serializeContextAndBodies(out); +#define SerializeGeometrySummary( value ) (fileStructure->value)->serializeGeometrySummary(out); +#define SerializeContextGraphics( value ) (fileStructure->value)->serializeContextGraphics(out); using std::string; +using namespace std; +using namespace std::tr1; -uint32_t PRCentity::getGraphicsIndex() -{ - if(useMaterial) - return parent->colourMap.size()+parent->getMaterialIndex(material); - else - return parent->getColourIndex(colour); -} - -void PRCline::writeRepresentationItem(PRCbitStream &out,uint32_t index) -{ - out << (uint32_t)(PRC_TYPE_RI_Curve); - ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out); - writeGraphics(out,m1,getGraphicsIndex(),1); - out << (uint32_t)0 // index_local_coordinate_system+1 - << (uint32_t)0; // index_tessellation - - out << true // has wire body - << (uint32_t)index+1 // index of context in geometry section - << (uint32_t)1; // body index in topological context - UserData(0,0).write(out); -} - -void PRCline::writeTopologicalContext(PRCbitStream &out) -{ - // topological context - out << (uint32_t)(PRC_TYPE_TOPO_Context); - EMPTY_CONTENTPRCBASE.write(out); - out << (uint8_t)0 // behaviour - << 0.0 // granularity - << 0.0 // tolerance - << false // have smallest face thickness - << false; // have scale - - out << (uint32_t)1; // number of bodies - // body - out << (uint32_t)PRC_TYPE_TOPO_SingleWireBody; - - out << false // base topology: no base information - << (uint8_t)0; // content body: behaviour - // Not sure what a 0 means, since it satisfies no #define, - // but I think it means no bbox - - // wire edge - out << false // not already stored - << (uint32_t)PRC_TYPE_TOPO_WireEdge - << false; // base topology: no base information - - // polyline - out << false // not already stored - << (uint32_t)PRC_TYPE_CRV_PolyLine - << false // base topology: no base information - << (uint32_t)KEPRCExtendTypeNone // extend info - << true // is 3d - << false // no transformation - << 0.0 << static_cast<double>(numberOfPoints-1) // parameterization interval - << 1.0 // no reparameterization - << 0.0 // no reparameterization - << (uint32_t)numberOfPoints; - - // points - for(uint32_t i = 0; i < numberOfPoints; ++i) - out << points[i][0]*scale << points[i][1]*scale << points[i][2]*scale; - - // ending of wire edge - out << false; // trim surface domain -} - -void PRCline::writeExtraGeometryContext(PRCbitStream &out) -{ - //geometry summary - out << (uint32_t)1; // number of bodies - out << (uint32_t)PRC_TYPE_TOPO_SingleWireBody; // body's serial type - //context graphics - out << (uint32_t)0; // number of treat types -} - -void PRCcurve::writeRepresentationItem(PRCbitStream &out,uint32_t index) -{ - out << (uint32_t)(PRC_TYPE_RI_Curve); - ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out); - writeGraphics(out,m1,getGraphicsIndex(),1); - out << (uint32_t)0 // index_local_coordinate_system+1 - << (uint32_t)0; // index_tessellation - - out << true // has wire body - << (uint32_t)index+1 // index of context in geometry section - << (uint32_t)1; // body index in topological context - UserData(0,0).write(out); -} - -void PRCcurve::writeTopologicalContext(PRCbitStream &out) -{ - // topological context - out << (uint32_t)(PRC_TYPE_TOPO_Context); - EMPTY_CONTENTPRCBASE.write(out); - out << (uint8_t)0 // behaviour - << 0.0 // granularity - << 0.0 // tolerance - << false // have smallest face thickness - << false; // have scale - - out << (uint32_t)1; // number of bodies - // body - out << (uint32_t)PRC_TYPE_TOPO_SingleWireBody; - - out << false // base topology: no base information - << (uint8_t)0; // content body: behaviour - // Not sure what a 0 means, since it satisfies no #define, - // but I think it means no bbox - - // wire edge - out << false // not already stored - << (uint32_t)PRC_TYPE_TOPO_WireEdge - << false; // base topology: no base information - - // curve - out << false // not already stored - << (uint32_t)PRC_TYPE_CRV_NURBS - << false // base topology: no base information - << (uint32_t)KEPRCExtendTypeNone // extend info - << true // is 3D - << isRational - << (uint32_t)degree // degree - << (uint32_t)numberOfControlPoints-1 // control points - 1 - << (uint32_t)degree+numberOfControlPoints; // knots - 1 - - // control points - for(uint32_t i = 0; i < numberOfControlPoints; ++i) - { - double Scale=scale; - if(isRational) Scale *= weights[i]; - out << controlPoints[i][0]*Scale << controlPoints[i][1]*Scale - << controlPoints[i][2]*Scale; - if(isRational) - out << weights[i]; - } - - writeKnots(out); - - out << (uint32_t)KEPRCKnotTypeUnspecified // KEPRCKnotTypePiecewiseBezierKnots - << (uint32_t)KEPRCBSplineCurveFormUnspecified; // curve form - - // ending of wire edge - out << false; // trim surface domain - -} - -void PRCcurve::writeExtraGeometryContext(PRCbitStream &out) -{ - //geometry summary - out << (uint32_t)1; // number of bodies - out << (uint32_t)PRC_TYPE_TOPO_SingleWireBody; // body's serial type - //context graphics - out << (uint32_t)0; // number of treat types -} - -void PRCsurface::writeRepresentationItem(PRCbitStream &out,uint32_t index) -{ - out << (uint32_t)(PRC_TYPE_RI_BrepModel); - ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out); - writeGraphics(out,0,getGraphicsIndex(),1); - out << (uint32_t)0 // index_local_coordinate_system+1 - << (uint32_t)0; // index_tessellation - - out << true // has brep data - << (uint32_t)index+1 // index of context in geometry section - << (uint32_t)1 // body index in topological context - << false; // is closed???? when is it closed? - UserData(0,0).write(out); -} - -void PRCsurface::writeTopologicalContext(PRCbitStream &out) -{ - // topological context - out << (uint32_t)(PRC_TYPE_TOPO_Context); - EMPTY_CONTENTPRCBASE.write(out); - out << (uint8_t)0 // behaviour - << granularity // granularity - << 0.0 // tolerance - << false // have smallest face thickness - << false; // have scale - - out << (uint32_t)1; // number of bodies - // body - out << (uint32_t)PRC_TYPE_TOPO_BrepData; - - out << false // base topology: no base information - << (uint8_t)0 // content body: behaviour. Not sure what a 0 means, since it satisfies no #define, but I think it means no bbox - << (uint32_t)1; // number of connex - - // connex - out << false // not already stored - << (uint32_t)PRC_TYPE_TOPO_Connex - << false // base topology: no base information - << (uint32_t)1; // number of shells - - // shell - out << false // not already stored - << (uint32_t)PRC_TYPE_TOPO_Shell - << false // base topology: no base information - << false // shell is closed - << (uint32_t)1; // number of faces - - // face - out << false // not already stored - << (uint32_t)PRC_TYPE_TOPO_Face - << false; // base topology: no base information - - // NURBS - out << false // not already stored - << (uint32_t)PRC_TYPE_SURF_NURBS - << false // base topology: no base information - << (uint32_t)KEPRCExtendTypeNone // Extend Info - << isRational // is rational - << (uint32_t)degreeU // degree in u - << (uint32_t)degreeV // degree in v - << (uint32_t)numberOfControlPointsU-1 // control points in u - 1 - << (uint32_t)numberOfControlPointsV-1 // control points in v - 1 - << (uint32_t)degreeU+numberOfControlPointsU // knots in u - 1 - << (uint32_t)degreeV+numberOfControlPointsV; // knots in v -1 - - // control points - for(uint32_t i = 0; i < numberOfControlPointsU*numberOfControlPointsV; ++i) - { - double Scale=scale; - if(isRational) Scale *= weights[i]; - out << controlPoints[i][0]*Scale << controlPoints[i][1]*Scale - << controlPoints[i][2]*Scale; - if(isRational) - out << weights[i]; - } - - writeKnots(out); - - out << (uint32_t)KEPRCKnotTypeUnspecified // KEPRCKnotTypePiecewiseBezierKnots - << (uint32_t)KEPRCBSplineSurfaceFormUnspecified; // surface form - - // ending of face - out << false // trim surface domain - << false // have tolerance - << (uint32_t)0 // number of loops - << (int32_t)-1; // outer loop index - - // ending of shell - out << (uint8_t)1; - // orientation of surface normal w.r.t. face normal: - // 0: same, 1: opposite, 2: unknown, 1 used in example -} - -void PRCsurface::writeExtraGeometryContext(PRCbitStream &out) -{ - //geometry summary - out << (uint32_t)1; // number of bodies - out << (uint32_t)PRC_TYPE_TOPO_BrepData; // body's serial type - //context graphics - out << (uint32_t)0; // number of treat types -} - - -void PRCCompressedSection::write(std::ostream &out) +void PRCCompressedSection::write(ostream &out) { if(prepared) out.write((char*)data,getSize()); @@ -309,6 +78,7 @@ void PRCGlobalsSection::writeData() // even though this is technically not part of this section, // it is handled here for convenience out << (uint32_t)(0); // number of schemas + uint32_t i=0; // universal index for PRC standard compatibility out << (uint32_t)PRC_TYPE_ASM_FileStructureGlobals; SingleAttributeData value = {PRCVersion}; @@ -322,29 +92,33 @@ void PRCGlobalsSection::writeData() out << tessellationAngleDegrees; out << defaultFontFamilyName; // markup serialization helper - out << numberOfFonts - << (uint32_t)parent->colourMap.size(); - for(std::vector<RGBAColour>::iterator i = parent->colourMap.begin(); i != parent->colourMap.end(); i++) + const uint32_t number_of_fonts = font_keys_of_font.size(); + WriteUnsignedInteger (number_of_fonts) + for (i=0;i<number_of_fonts;i++) { - out << i->R << i->G << i->B; + SerializeFontKeysSameFont (font_keys_of_font[i]) } - out << numberOfPictures << numberOfTextureDefinitions; - out << (uint32_t)parent->materialMap.size(); // number of materials - for(std::vector<PRCMaterial>::iterator i = parent->materialMap.begin(); i != parent->materialMap.end(); i++) - { - out << (uint32_t)PRC_TYPE_GRAPH_Material; - ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out); - out << 3*parent->getColourIndex(i->ambient)+1 // ambient + 1 - << 3*parent->getColourIndex(i->diffuse)+1 // diffuse + 1 - << 3*parent->getColourIndex(i->emissive)+1 // emissive + 1 - << 3*parent->getColourIndex(i->specular)+1 // specular + 1 - << i->shininess // shininess - << i->ambient.A // ambient_alpha - << i->diffuse.A // diffuse_alpha - << i->emissive.A // emissive_alpha - << i->specular.A; // specular_alpha - } + + const uint32_t number_of_colors = colors.size(); + WriteUnsignedInteger (number_of_colors) + for (i=0;i<number_of_colors;i++) + SerializeRgbColor (colors[i]) + + const uint32_t number_of_pictures = pictures.size(); + WriteUnsignedInteger (number_of_pictures) + for (i=0;i<number_of_pictures;i++) + SerializePicture (pictures[i]) + + const uint32_t number_of_texture_definitions = texture_definitions.size(); + WriteUnsignedInteger (number_of_texture_definitions) + for (i=0;i<number_of_texture_definitions;i++) + SerializeTextureDefinition (texture_definitions[i]) + + const uint32_t number_of_materials = materials.size(); + WriteUnsignedInteger (number_of_materials) + for (i=0;i<number_of_materials;i++) + SerializeMaterial (materials[i]) out << (uint32_t)1 // number of line patterns hard coded for now << (uint32_t)PRC_TYPE_GRAPH_LinePattern; @@ -353,47 +127,18 @@ void PRCGlobalsSection::writeData() << 0.0 // phase << false; // is real length - out << (uint32_t)(parent->colourMap.size()+parent->materialMap.size()); // number of styles - uint32_t index = 0; - // colours are written first - for(std::vector<RGBAColour>::iterator i = parent->colourMap.begin(); i != parent->colourMap.end(); i++, ++index) - { - out << (uint32_t)PRC_TYPE_GRAPH_Style; - ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out); - out << 0.0 // line width in mm - << false // is vpicture - << (uint32_t)1 // line pattern index+1 - << false // is material - << (uint32_t)(3*index+1); // 3*color_index+1 - if(i->A < 1.0) - out << true << (uint8_t)(i->A * 256); - else - out << false; - out << false // additional 1 not defined - << false // additional 2 not defined - << false; // additional 3 not defined - } - // materials are after colours - index = 0; - for(std::vector<PRCMaterial>::iterator i = parent->materialMap.begin(); i != parent->materialMap.end(); i++, ++index) - { - out << (uint32_t)PRC_TYPE_GRAPH_Style; - ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out); - out << 0.0 // line width in mm - << false // is vpicture - << (uint32_t)1 // line pattern index+1 - << true // is material - << index+1; // material_index+1 - if(i->alpha < 1.0) - out << true << (uint8_t)(i->alpha * 256); - else - out << false; - out << false // additional 1 not defined - << false // additional 2 not defined - << false; // additional 3 not defined - } - out << numberOfFillPatterns - << numberOfReferenceCoordinateSystems; + const uint32_t number_of_styles = styles.size(); + WriteUnsignedInteger (number_of_styles) + for (i=0;i<number_of_styles;i++) + SerializeCategory1LineStyle (styles[i]) + + out << numberOfFillPatterns; + + const uint32_t number_of_reference_coordinate_systems = reference_coordinate_systems.size(); + WriteUnsignedInteger (number_of_reference_coordinate_systems) + for (i=0;i<number_of_reference_coordinate_systems;i++) + SerializeCoordinateSystem (reference_coordinate_systems[i]) + userData.write(out); } @@ -403,68 +148,20 @@ void PRCTreeSection::writeData() EMPTY_CONTENTPRCBASE.write(out); - out << (uint32_t)1; // number of part definitions - // part definitions - out << (uint32_t)(PRC_TYPE_ASM_PartDefinition); - ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out); - writeGraphics(out,m1,m1,1,true); - Point3d M=Point3d(1e20,1e20,1e20); - Point3d m=Point3d(-1e20,-1e20,-1e20); - Extent3d(M,m).write(out); - - out << (uint32_t)parent->fileEntities.size(); // number of representation items - for(uint32_t i = 0; i < parent->fileEntities.size(); ++i) + uint32_t number_of_part_definitions = part_definitions.size(); + WriteUnsignedInteger (number_of_part_definitions) + for (uint32_t i=0;i<number_of_part_definitions;i++) + SerializePartDefinition (part_definitions[i]) + + uint32_t number_of_product_occurrences = product_occurrences.size(); + WriteUnsignedInteger (number_of_product_occurrences) + for (uint32_t i=0;i<number_of_product_occurrences;i++) { - parent->fileEntities[i]->writeRepresentationItem(out,i); + product_occurrences[i]->unit_information.unit_from_CAD_file = true; + product_occurrences[i]->unit_information.unit = unit; + SerializeProductOccurrence (product_occurrences[i]) } - writeEmptyMarkups(out); - - out << (uint32_t)0; // no views - - UserData(0,0).write(out); - out << (uint32_t)1; // number of product occurrences - // only one product occurrence - out << (uint32_t)(PRC_TYPE_ASM_ProductOccurence); - SingleAttribute sas[3]; - SingleAttributeData sad; - AttributeTitle at; - - at.text = "FilePath"; - sad.text = "file name not specified"; - sas[0] = SingleAttribute(false,at,KEPRCModellerAttributeTypeString,sad); - - at.text = "FileSize"; - sad.integer = 1234; - sas[1] = SingleAttribute(false,at,KEPRCModellerAttributeTypeInt,sad); - - at.text = "FileModificationTime"; - sad.time = time(NULL); - sas[2] = SingleAttribute(false,at,KEPRCModellerAttributeTypeInt,sad); - - at.text = "__PRC_RESERVED_ATTRIBUTE_A3DF_ProductInformation"; - Attribute attr(false,at,3,sas); - Attributes attrs(1,&attr); - ContentPRCBase(&attrs,"root",true,makeCADID(),0,makePRCID()).write(out); - - writeGraphics(out,m1,m1,1,true); - out << (uint32_t)1 // index_part+1 - << (uint32_t)0 // index_prototype+1 - << (uint32_t)0 // index_external_data+1 - << (uint32_t)0 // number of son product occurrences - << (uint8_t)0; // product behaviour - writeUnit(out,true,10.0); - out << (uint8_t)0 // product information flags - << (uint32_t)KEPRCProductLoadStatus_Loaded; // product_load_status - out << false // has location - << (uint32_t)0; // number of references - writeEmptyMarkups(out); - out << (uint32_t)0 // number_of_views - << false // has entity filter - << (uint32_t)0 // number_of_display_filters - << (uint32_t)0; // number_of_scene_display_parameters - UserData(0,0).write(out); - // File Structure Internal Data out << (uint32_t)(PRC_TYPE_ASM_FileStructure); EMPTY_CONTENTPRCBASE.write(out); @@ -479,34 +176,38 @@ void PRCTessellationSection::writeData() out << (uint32_t)(PRC_TYPE_ASM_FileStructureTessellation); EMPTY_CONTENTPRCBASE.write(out); - out << (uint32_t)0; // number of tessellations + const uint32_t number_of_tessellations = tessellations.size(); + WriteUnsignedInteger (number_of_tessellations) + for (uint32_t i=0;i<number_of_tessellations;i++) + tessellations[i]->serializeBaseTessData(out); UserData(0,0).write(out); // no user data } void PRCGeometrySection::writeData() { - out << (uint32_t)(PRC_TYPE_ASM_FileStructureGeometry); + WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureGeometry) EMPTY_CONTENTPRCBASE.write(out); - out << (uint32_t)parent->fileEntities.size(); // number of topological contexts - for(uint32_t i = 0; i < parent->fileEntities.size(); ++i) - { - parent->fileEntities[i]->writeTopologicalContext(out); - } + const uint32_t number_of_contexts = fileStructure->contexts.size(); + WriteUnsignedInteger (number_of_contexts) + for (uint32_t i=0;i<number_of_contexts;i++) + SerializeContextAndBodies (contexts[i]) UserData(0,0).write(out); } void PRCExtraGeometrySection::writeData() { - out << (uint32_t)(PRC_TYPE_ASM_FileStructureExtraGeometry); + WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureExtraGeometry) EMPTY_CONTENTPRCBASE.write(out); - out << (uint32_t)parent->fileEntities.size(); // number of contexts - for(uint32_t i = 0; i < parent->fileEntities.size(); ++i) - { - parent->fileEntities[i]->writeExtraGeometryContext(out); - } + const uint32_t number_of_contexts = fileStructure->contexts.size(); + WriteUnsignedInteger (number_of_contexts) + for (uint32_t i=0;i<number_of_contexts;i++) + { + SerializeGeometrySummary (contexts[i]) + SerializeContextGraphics (contexts[i]) + } UserData(0,0).write(out); } @@ -525,7 +226,7 @@ void PRCModelFile::writeData() Attributes as(1,&a); ContentPRCBase(&as,"PRC file").write(out); - writeUnit(out,true,10); // unit is 10 mm, and happens to come from a CAD file + writeUnit(out,true,unit); // unit is specified, and happens to come from a CAD file out << (uint32_t)1; // 1 product occurrence //UUID @@ -534,7 +235,7 @@ void PRCModelFile::writeData() << parent->fileStructures[0]->header.fileStructureUUID[2] << parent->fileStructures[0]->header.fileStructureUUID[3]; // index+1 - out << (uint32_t)1; + out << (uint32_t)parent->fileStructures[0]->tree.product_occurrences.size(); // active out << true; out << (uint32_t)0; // index in model file @@ -562,7 +263,7 @@ void makeAppUUID(uint32_t *UUID) UUID[0] = UUID[1] = UUID[2] = UUID[3] = 0; } -void writeUINT32_T(std::ostream &out, uint32_t data) +void writeUINT32_T(ostream &out, uint32_t data) { #ifdef WORDS_BIGENDIAN out.write(((char*)&data)+3,1); @@ -577,10 +278,13 @@ void writeUINT32_T(std::ostream &out, uint32_t data) #endif } -void PRCUncompressedFile::write(std::ostream &out) +void PRCUncompressedFile::write(ostream &out) { - writeUINT32_T(out,file_size); - out.write((char*)data,file_size); + if(data!=NULL) + { + writeUINT32_T(out,file_size); + out.write((char*)data,file_size); + } } uint32_t PRCUncompressedFile::getSize() @@ -589,7 +293,7 @@ uint32_t PRCUncompressedFile::getSize() } -void PRCStartHeader::write(std::ostream &out) +void PRCStartHeader::write(ostream &out) { out.write("PRC",3); writeUINT32_T(out,minimal_version_for_read); @@ -611,14 +315,13 @@ uint32_t PRCStartHeader::getSize() } -void PRCFileStructure::write(std::ostream &out) +void PRCFileStructure::write(ostream &out) { header.write(out); + uint32_t number_of_uncompressed_files = uncompressedFiles.size(); writeUINT32_T(out,number_of_uncompressed_files); - for(uint32_t i = 0; i < number_of_uncompressed_files; ++i) - { - uncompressedFiles[i].write(out); - } + for(list<PRCUncompressedFile>::iterator i = uncompressedFiles.begin(); i != uncompressedFiles.end(); i++) + i->write(out); globals.write(out); tree.write(out); tessellations.write(out); @@ -649,8 +352,8 @@ uint32_t PRCFileStructure::getSize() uint32_t size = 0; size += header.getSize(); size += sizeof(uint32_t); - for(uint32_t i = 0; i < number_of_uncompressed_files; ++i) - size += uncompressedFiles[i].getSize(); + for(list<PRCUncompressedFile>::iterator i = uncompressedFiles.begin(); i != uncompressedFiles.end(); i++) + size += i->getSize(); size += globals.getSize(); size += tree.getSize(); size += tessellations.getSize(); @@ -660,7 +363,7 @@ uint32_t PRCFileStructure::getSize() } -void PRCFileStructureInformation::write(std::ostream &out) +void PRCFileStructureInformation::write(ostream &out) { writeUINT32_T(out,UUID[0]); writeUINT32_T(out,UUID[1]); @@ -680,7 +383,7 @@ uint32_t PRCFileStructureInformation::getSize() return (4+2+number_of_offsets)*sizeof(uint32_t); } -void PRCHeader::write(std::ostream &out) +void PRCHeader::write(ostream &out) { startHeader.write(out); writeUINT32_T(out,number_of_file_structures); @@ -690,11 +393,10 @@ void PRCHeader::write(std::ostream &out) } writeUINT32_T(out,model_file_offset); writeUINT32_T(out,file_size); + uint32_t number_of_uncompressed_files = uncompressedFiles.size(); writeUINT32_T(out,number_of_uncompressed_files); - for(uint32_t i = 0; i < number_of_uncompressed_files; ++i) - { - uncompressedFiles[i].write(out); - } + for(list<PRCUncompressedFile>::iterator i = uncompressedFiles.begin(); i != uncompressedFiles.end(); i++) + i->write(out); } uint32_t PRCHeader::getSize() @@ -703,53 +405,361 @@ uint32_t PRCHeader::getSize() for(uint32_t i = 0; i < number_of_file_structures; ++i) size += fileStructureInformation[i].getSize(); size += 3*sizeof(uint32_t); - for(uint32_t i = 0; i < number_of_uncompressed_files; ++i) - size += uncompressedFiles[i].getSize(); + for(list<PRCUncompressedFile>::iterator i = uncompressedFiles.begin(); i != uncompressedFiles.end(); i++) + size += i->getSize(); return size; } -bool oPRCFile::add(PRCentity *p) +void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence) { - fileEntities.push_back(p); - if(p->useMaterial) - { - if(getMaterialIndex(p->material) == m1) + const string& name = group.name; + + PRCPartDefinition *part_definition = new PRCPartDefinition; + + if(group.options.tess) + { + if(!group.lines.empty()) + { + bool same_color = true; + const PRCRgbColor &color = group.lines.front().color; + for(PRCtesslineList::const_iterator lit=group.lines.begin(); lit!=group.lines.end(); lit++) + if(color!=lit->color) + { + same_color = false; + break; + } + map<PRCVector3d,uint32_t> points; + PRC3DWireTess *tess = new PRC3DWireTess(); + if(!same_color) + { + tess->is_segment_color = true; + tess->is_rgba = false; + } + for(PRCtesslineList::const_iterator lit=group.lines.begin(); lit!=group.lines.end(); lit++) + { + tess->wire_indexes.push_back(lit->point.size()); + for(uint32_t i=0; i<lit->point.size(); i++) + { + map<PRCVector3d,uint32_t>::iterator pPoint = points.find(lit->point[i]); + if(pPoint!=points.end()) + tess->wire_indexes.push_back(pPoint->second); + else + { + uint32_t point_index = m1; + points.insert(make_pair(lit->point[i],(point_index = tess->coordinates.size()))); + tess->wire_indexes.push_back(point_index); + tess->coordinates.push_back(lit->point[i].x); + tess->coordinates.push_back(lit->point[i].y); + tess->coordinates.push_back(lit->point[i].z); + } + if(!same_color && i>0) + { + tess->rgba_vertices.push_back((uint8_t)(255*lit->color.red)); + tess->rgba_vertices.push_back((uint8_t)(255*lit->color.green)); + tess->rgba_vertices.push_back((uint8_t)(255*lit->color.blue)); + } + } + } + const uint32_t tess_index = add3DWireTess(tess); + PRCPolyWire *polyWire = new PRCPolyWire(); + polyWire->index_tessellation = tess_index; + if(same_color) + polyWire->index_of_line_style = addColour(RGBAColour(color.red,color.green,color.blue)); + part_definition->addPolyWire(polyWire); + } +// make rectangles pairs of triangles in a tesselation + if(!group.rectangles.empty()) + { + bool same_color = true; + const uint32_t &style = group.rectangles.front().style; + for(PRCtessrectangleList::const_iterator rit=group.rectangles.begin(); rit!=group.rectangles.end(); rit++) + if(style!=rit->style) + { + same_color = false; + break; + } + map<PRCVector3d,uint32_t> points; + PRC3DTess *tess = new PRC3DTess(); + PRCTessFace *tessFace = new PRCTessFace(); + tessFace->used_entities_flag=PRC_FACETESSDATA_Triangle; + uint32_t triangles = 0; + for(PRCtessrectangleList::const_iterator rit=group.rectangles.begin(); rit!=group.rectangles.end(); rit++) + { + const bool degenerate = (rit->vertices[0]==rit->vertices[1]); + uint32_t vertex_indices[4]; + for(size_t i = (degenerate?1:0); i < 4; ++i) + { + map<PRCVector3d,uint32_t>::iterator pPoint = points.find(rit->vertices[i]); + if(pPoint!=points.end()) + vertex_indices[i] = pPoint->second; + else + { + points.insert(make_pair(rit->vertices[i],(vertex_indices[i] = tess->coordinates.size()))); + tess->coordinates.push_back(rit->vertices[i].x); + tess->coordinates.push_back(rit->vertices[i].y); + tess->coordinates.push_back(rit->vertices[i].z); + } + } + if(degenerate) + { + tess->triangulated_index.push_back(vertex_indices[1]); + tess->triangulated_index.push_back(vertex_indices[2]); + tess->triangulated_index.push_back(vertex_indices[3]); + triangles++; + if(!same_color) + tessFace->line_attributes.push_back(rit->style); + } + else + { + tess->triangulated_index.push_back(vertex_indices[0]); + tess->triangulated_index.push_back(vertex_indices[2]); + tess->triangulated_index.push_back(vertex_indices[3]); + triangles++; + if(!same_color) + tessFace->line_attributes.push_back(rit->style); + tess->triangulated_index.push_back(vertex_indices[3]); + tess->triangulated_index.push_back(vertex_indices[1]); + tess->triangulated_index.push_back(vertex_indices[0]); + triangles++; + if(!same_color) + tessFace->line_attributes.push_back(rit->style); + } + } + tessFace->sizes_triangulated.push_back(triangles); + tess->addTessFace(tessFace); + const uint32_t tess_index = add3DTess(tess); + PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel(); + polyBrepModel->index_tessellation = tess_index; + polyBrepModel->is_closed = group.options.closed; + if(same_color) + polyBrepModel->index_of_line_style = style; + part_definition->addPolyBrepModel(polyBrepModel); + } + } + + if(!group.points.empty()) + { + for(PRCpointsetMap::const_iterator pit=group.points.begin(); pit!=group.points.end(); pit++) + { + PRCPointSet *pointset = new PRCPointSet(); + pointset->index_of_line_style = pit->first; + pointset->point = pit->second; + part_definition->addPointSet(pointset); + } + } + + if(!group.wires.empty()) { - materialMap.push_back(p->material); + PRCTopoContext *wireContext = new PRCTopoContext; + uint32_t context_index = addTopoContext(wireContext); + for(PRCwireList::const_iterator wit=group.wires.begin(); wit!=group.wires.end(); wit++) + { + PRCSingleWireBody *wireBody = new PRCSingleWireBody; + const uint32_t wire_body_index = wireContext->addSingleWireBody(wireBody); + PRCWireEdge *wireEdge = new PRCWireEdge; + wireBody->setWireEdge(wireEdge); + wireEdge->setCurve(wit->curve); + PRCWire *wire = new PRCWire(); + wire->index_of_line_style = wit->style; + wire->context_id = context_index; + wire->body_id = wire_body_index; + if(wit->transform) + wire->index_local_coordinate_system = addTransform(wit->transform); + part_definition->addWire(wire); + } + } - if(getColourIndex(p->material.ambient) == m1) - colourMap.push_back(p->material.ambient); + const PRCfaceList &faces = group.faces; + if(!faces.empty()) + { + bool same_color = true; + uint32_t style = faces.front().style; + for(PRCfaceList::const_iterator fit=faces.begin(); fit!=faces.end(); fit++) + if(style!=fit->style) + { + same_color = false; + break; + } + PRCTopoContext *context = new PRCTopoContext; + context->granularity = group.options.granularity; + const uint32_t context_index = addTopoContext(context); + PRCShell *shell = new PRCShell; + + for(PRCfaceList::const_iterator fit=faces.begin(); fit!=faces.end(); fit++) + { + if(fit->transform || group.options.do_break || + (fit->transparent && !group.options.no_break)) + { + PRCBrepData *body = new PRCBrepData; + const uint32_t body_index = context->addBrepData(body); + PRCConnex *connex = new PRCConnex; + body->addConnex(connex); + PRCShell *shell = new PRCShell; + connex->addShell(shell); + shell->addFace(fit->face); + + PRCBrepModel *brepmodel = new PRCBrepModel(); + brepmodel->index_of_line_style = fit->style; + brepmodel->context_id = context_index; + brepmodel->body_id = body_index; + brepmodel->is_closed = group.options.closed; + + brepmodel->index_local_coordinate_system = addTransform(fit->transform); + + part_definition->addBrepModel(brepmodel); + } + else + { + if(!same_color) + fit->face->index_of_line_style = fit->style; + shell->addFace(fit->face); + } + } + if(shell->face.empty()) + { + delete shell; + } + else + { + PRCBrepData *body = new PRCBrepData; + const uint32_t body_index = context->addBrepData(body); + PRCConnex *connex = new PRCConnex; + body->addConnex(connex); + connex->addShell(shell); + PRCBrepModel *brepmodel = new PRCBrepModel(); + if(same_color) + brepmodel->index_of_line_style = style; + brepmodel->context_id = context_index; + brepmodel->body_id = body_index; + brepmodel->is_closed = group.options.closed; + part_definition->addBrepModel(brepmodel); + } + } - if(getColourIndex(p->material.diffuse) == m1) - colourMap.push_back(p->material.diffuse); + const PRCcompfaceList &compfaces = group.compfaces; + if(!compfaces.empty()) + { + bool same_color = true; + uint32_t style = compfaces.front().style; + for(PRCcompfaceList::const_iterator fit=compfaces.begin(); fit!=compfaces.end(); fit++) + if(style!=fit->style) + { + same_color = false; + break; + } + PRCTopoContext *context = new PRCTopoContext; + context->granularity = group.options.granularity; + const uint32_t context_index = addTopoContext(context); + PRCCompressedBrepData *body = new PRCCompressedBrepData; + + body->serial_tolerance=group.options.compression; + body->brep_data_compressed_tolerance=0.1*group.options.compression; + + for(PRCcompfaceList::const_iterator fit=compfaces.begin(); fit!=compfaces.end(); fit++) + { + if(group.options.do_break || + (fit->transparent && !group.options.no_break)) + { + PRCCompressedBrepData *body = new PRCCompressedBrepData; + const uint32_t body_index = context->addCompressedBrepData(body); + body->face.push_back(fit->face); + + body->serial_tolerance=group.options.compression; + body->brep_data_compressed_tolerance=2.8346456* + group.options.compression; + + PRCBrepModel *brepmodel = new PRCBrepModel(); + brepmodel->index_of_line_style = fit->style; + brepmodel->context_id = context_index; + brepmodel->body_id = body_index; + brepmodel->is_closed = group.options.closed; + + part_definition->addBrepModel(brepmodel); + } + else + { + if(!same_color) + fit->face->index_of_line_style = fit->style; + body->face.push_back(fit->face); + } + } + if(body->face.empty()) + { + delete body; + } + else + { + const uint32_t body_index = context->addCompressedBrepData(body); + PRCBrepModel *brepmodel = new PRCBrepModel(); + if(same_color) + brepmodel->index_of_line_style = style; + brepmodel->context_id = context_index; + brepmodel->body_id = body_index; + brepmodel->is_closed = group.options.closed; + part_definition->addBrepModel(brepmodel); + } + } - if(getColourIndex(p->material.emissive) == m1) - colourMap.push_back(p->material.emissive); + PRCProductOccurrence *product_occurrence = new PRCProductOccurrence(name); - if(getColourIndex(p->material.specular) == m1) - colourMap.push_back(p->material.specular); + for(PRCgroupList::const_iterator it=group.groupList.begin(); it!=group.groupList.end(); it++) + { + doGroup(*it, part_definition, product_occurrence); } - } - else - { - if(getColourIndex(p->colour) == m1) + + // Simplify and reduce to as simple entities as possible + // First option - reduce to one element in parent + if (parent_part_definition && product_occurrence->index_son_occurrence.empty() && + part_definition->representation_item.size() == 1 && + ( name.empty() || part_definition->representation_item.front()->name.empty() ) && + ( !group.transform || part_definition->representation_item.front()->index_local_coordinate_system==m1) ) { - colourMap.push_back(p->colour); + if(part_definition->representation_item.front()->name.empty() ) + part_definition->representation_item.front()->name = name; + if(part_definition->representation_item.front()->index_local_coordinate_system==m1) + part_definition->representation_item.front()->index_local_coordinate_system = addTransform(group.transform); + parent_part_definition->addRepresentationItem(part_definition->representation_item.front()); + delete product_occurrence; + delete part_definition; } - } - return true; + // Second option - reduce to a set + else if (parent_part_definition && product_occurrence->index_son_occurrence.empty() && + !part_definition->representation_item.empty() && + !group.options.do_break ) + { + PRCSet *set = new PRCSet(name); + set->index_local_coordinate_system = addTransform(group.transform); + for(PRCRepresentationItemList::const_iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++) + set->addRepresentationItem(*it); + parent_part_definition->addSet(set); + delete product_occurrence; + delete part_definition; + } + // Third option - create product + else + { + if (part_definition->representation_item.empty()) + delete part_definition; + else + product_occurrence->index_part = addPartDefinition(part_definition); + if (group.transform) { + product_occurrence->location = group.transform; + product_occurrence->has_location = true; + } + if (parent_product_occurrence) { + parent_product_occurrence->index_son_occurrence.push_back(addProductOccurrence(product_occurrence)); + } + else { + addProductOccurrence(product_occurrence); + } + } + } bool oPRCFile::finish() { - // only one file structure is currently used - // prepare data - fileStructures[0] = new PRCFileStructure(this,0); - fileStructures[0]->header.minimal_version_for_read = PRCVersion; - fileStructures[0]->header.authoring_version = PRCVersion; - makeFileUUID(fileStructures[0]->header.fileStructureUUID); - makeAppUUID(fileStructures[0]->header.applicationUUID); - fileStructures[0]->number_of_uncompressed_files = 0; + rootGroup.name = "root"; + doGroup(rootGroup, NULL, NULL); // write each section's bit data fileStructures[0]->prepare(); @@ -758,7 +768,6 @@ bool oPRCFile::finish() // create the header // fill out enough info so that sizes can be computed correctly - header.number_of_uncompressed_files = 0; header.number_of_file_structures = number_of_file_structures; header.fileStructureInformation = new PRCFileStructureInformation[number_of_file_structures]; for(uint32_t i = 0; i < number_of_file_structures; ++i) @@ -786,8 +795,8 @@ bool oPRCFile::finish() { header.fileStructureInformation[i].offsets[0] = currentOffset; // header offset currentOffset += fileStructures[i]->header.getSize() + sizeof(uint32_t); - for(uint32_t j = 0; j < fileStructures[i]->number_of_uncompressed_files; ++j) - currentOffset += fileStructures[i]->uncompressedFiles[j].getSize(); + for(list<PRCUncompressedFile>::iterator j = fileStructures[i]->uncompressedFiles.begin(); j != fileStructures[i]->uncompressedFiles.end(); j++) + currentOffset += j->getSize(); header.fileStructureInformation[i].offsets[1] = currentOffset; // globals offset currentOffset += fileStructures[i]->globals.getSize(); header.fileStructureInformation[i].offsets[2] = currentOffset; // tree offset @@ -818,35 +827,695 @@ bool oPRCFile::finish() return true; } -uint32_t oPRCFile::getColourIndex(const RGBAColour &c) +uint32_t oPRCFile::getSize() { - for(uint32_t i = 0; i < colourMap.size(); ++i) + uint32_t size = header.getSize(); + + for(uint32_t i = 0; i < number_of_file_structures; ++i) { - if(colourMap[i] == c) - return i; + size += fileStructures[i]->getSize(); } - return m1; + + size += modelFile.getSize(); + return size; } -uint32_t oPRCFile::getMaterialIndex(const PRCMaterial &m) +#define REPORT_ERROR( value ) { cerr << value << endl; return m1; } + +uint32_t PRCFileStructure::addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *p, uint32_t width, uint32_t height, string name) { - for(uint32_t i = 0; i < materialMap.size(); ++i) + if(size==0 || p==NULL) + REPORT_ERROR( "image not set" ) + PRCPicture picture(name); + PRCUncompressedFile uncompressedFile; + uint32_t components=0; + uint8_t *data = NULL; + switch(format) { - if(materialMap[i] == m) - return i; + case KEPRCPicture_BITMAP_RGB_BYTE: + components = 3; + case KEPRCPicture_BITMAP_RGBA_BYTE: + components = 4; + case KEPRCPicture_BITMAP_GREY_BYTE: + components = 1; + case KEPRCPicture_BITMAP_GREYA_BYTE: + components = 2; + if(width==0 || height==0) + REPORT_ERROR( "width or height parameter not set" ) + if (size < width*height*components) + REPORT_ERROR( "image too small" ) + + { + uint32_t compressedDataSize = 0; + const int CHUNK= 1024; // is this reasonable? + + z_stream strm; + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + if(deflateInit(&strm,Z_DEFAULT_COMPRESSION) != Z_OK) + REPORT_ERROR ( "Compression initialization failed" ) + unsigned int sizeAvailable = deflateBound(&strm,size); + uint8_t *compressedData = (uint8_t*) malloc(sizeAvailable); + strm.avail_in = size; + strm.next_in = (unsigned char*)p; + strm.next_out = (unsigned char*)compressedData; + strm.avail_out = sizeAvailable; + + int code; + unsigned int chunks = 0; + while((code = deflate(&strm,Z_FINISH)) == Z_OK) + { + ++chunks; + // strm.avail_out should be 0 if we got Z_OK + compressedDataSize = sizeAvailable - strm.avail_out; + compressedData = (uint8_t*) realloc(compressedData,CHUNK*chunks); + strm.next_out = (Bytef*)(compressedData + compressedDataSize); + strm.avail_out += CHUNK; + sizeAvailable += CHUNK; + } + compressedDataSize = sizeAvailable-strm.avail_out; + + if(code != Z_STREAM_END) + { + deflateEnd(&strm); + free(compressedData); + REPORT_ERROR ( "Compression error" ) + } + + deflateEnd(&strm); + size = compressedDataSize; + data = new uint8_t[compressedDataSize]; + memcpy(data, compressedData, compressedDataSize); + free(compressedData); + } + uncompressedFiles.push_back(uncompressedFile); + uncompressedFiles.back().file_size = size; + uncompressedFiles.back().data = data; + picture.format = format; + picture.uncompressed_file_index = uncompressedFiles.size()-1; + picture.pixel_width = width; + picture.pixel_height = height; + globals.pictures.push_back(picture); + return globals.pictures.size()-1; + break; + + case KEPRCPicture_PNG: + case KEPRCPicture_JPG: + data = new uint8_t[size]; + memcpy(data, p, size); + uncompressedFiles.push_back(uncompressedFile); + uncompressedFiles.back().file_size = size; + uncompressedFiles.back().data = data; + picture.format = format; + picture.uncompressed_file_index = uncompressedFiles.size()-1; + picture.pixel_width = 0; // width and height are ignored for JPG and PNG pictures - but let us keep things clean + picture.pixel_height = 0; + globals.pictures.push_back(picture); + return globals.pictures.size()-1; + break; + + default: + REPORT_ERROR( "unknown picture format" ) } return m1; } +#undef REPORT_ERROR -uint32_t oPRCFile::getSize() +uint32_t PRCFileStructure::addTextureDefinition(PRCTextureDefinition *pTextureDefinition) { - uint32_t size = header.getSize(); + globals.texture_definitions.push_back(PRCpTextureDefinition(pTextureDefinition)); + return globals.texture_definitions.size()-1; +} - for(uint32_t i = 0; i < number_of_file_structures; ++i) +uint32_t PRCFileStructure::addRgbColor(const PRCRgbColor &color) +{ + globals.colors.push_back(color); + return 3*(globals.colors.size()-1); +} + +uint32_t PRCFileStructure::addRgbColorUnique(const PRCRgbColor &color) +{ + for(uint32_t i = 0; i < globals.colors.size(); ++i) { - size += fileStructures[i]->getSize(); + if(globals.colors[i] == color) + return 3*i; } + globals.colors.push_back(color); + return 3*(globals.colors.size()-1); +} - size += modelFile.getSize(); - return size; +uint32_t oPRCFile::addColor(const PRCRgbColor &color) +{ + PRCcolorMap::iterator pColor = colorMap.find(color); + uint32_t color_index = m1; + if(pColor!=colorMap.end()) + return pColor->second; +// color_index = addRgbColorUnique(color); + color_index = fileStructures[0]->addRgbColor(color); + colorMap.insert(make_pair(color,color_index)); + return color_index; +} + +uint32_t oPRCFile::addColour(const RGBAColour &colour) +{ + PRCcolourMap::iterator pColour = colourMap.find(colour); + if(pColour!=colourMap.end()) + return pColour->second; + const uint32_t color_index = addColor(PRCRgbColor(colour.R, colour.G, colour.B)); + PRCStyle *style = new PRCStyle(); + style->line_width = 1.0; + style->is_vpicture = false; + style->line_pattern_vpicture_index = 0; + style->is_material = false; + style->color_material_index = color_index; + style->is_transparency_defined = (colour.A < 1.0); + style->transparency = (uint8_t)(colour.A * 256); + style->additional = 0; + const uint32_t style_index = fileStructures[0]->addStyle(style); + colourMap.insert(make_pair(colour,style_index)); + return style_index; +} + +uint32_t oPRCFile::addTransform(const PRCpGeneralTransformation3d &transform) +{ + if(!transform) + return m1; + PRCtransformMap::iterator pTransform = transformMap.find(*transform); + if(pTransform!=transformMap.end()) + return pTransform->second; + PRCCoordinateSystem *coordinateSystem = new PRCCoordinateSystem(); + coordinateSystem->axis_set = transform; + const uint32_t coordinate_system_index = fileStructures[0]->addCoordinateSystem(coordinateSystem); + transformMap.insert(make_pair(*transform,coordinate_system_index)); + return coordinate_system_index; +} + +uint32_t oPRCFile::addMaterial(const PRCmaterial &material) +{ + PRCmaterialMap::iterator pMaterial = materialMap.find(material); + if(pMaterial!=materialMap.end()) + return pMaterial->second; + PRCMaterialGeneric *materialGeneric = new PRCMaterialGeneric(); + const PRCRgbColor ambient(material.ambient.R, material.ambient.G, material.ambient.B); + materialGeneric->ambient = addColor(ambient); + const PRCRgbColor diffuse(material.diffuse.R, material.diffuse.G, material.diffuse.B); + materialGeneric->diffuse = addColor(diffuse); + const PRCRgbColor emissive(material.emissive.R, material.emissive.G, material.emissive.B); + materialGeneric->emissive = addColor(emissive); + const PRCRgbColor specular(material.specular.R, material.specular.G, material.specular.B); + materialGeneric->specular = addColor(specular); + materialGeneric->shininess = material.shininess; + materialGeneric->ambient_alpha = material.ambient.A; + materialGeneric->diffuse_alpha = material.diffuse.A; + materialGeneric->emissive_alpha = material.emissive.A; + materialGeneric->specular_alpha = material.specular.A; + const uint32_t material_index = fileStructures[0]->addMaterialGeneric(materialGeneric); + PRCStyle *style = new PRCStyle(); + style->line_width = 0.0; + style->is_vpicture = false; + style->line_pattern_vpicture_index = 0; + style->is_material = true; + style->color_material_index = material_index; + style->is_transparency_defined = (material.alpha < 1.0); + style->transparency = (uint8_t)(material.alpha * 256); + style->additional = 0; + const uint32_t style_index = fileStructures[0]->addStyle(style); + materialMap.insert(make_pair(material,style_index)).first; + return style_index; +} + +bool isid(const double t[][4]) +{ + return( + t[0][0]==1 && t[0][1]==0 && t[0][2]==0 && t[0][3]==0 && + t[1][0]==0 && t[1][1]==1 && t[1][2]==0 && t[1][3]==0 && + t[2][0]==0 && t[2][1]==0 && t[2][2]==1 && t[2][3]==0 && + t[3][0]==0 && t[3][1]==0 && t[3][2]==0 && t[3][3]==1 ); +} + +void oPRCFile::begingroup(const char *name, PRCoptions *options, + const double t[][4]) +{ + if(currentGroups.empty()) + currentGroups.push(rootGroup.groupList.insert(rootGroup.groupList.end(),PRCgroup())); + else + currentGroups.push(currentGroups.top()->groupList.insert(currentGroups.top()->groupList.end(),PRCgroup())); + PRCgroup &group = *(currentGroups.top()); + group.name=name; + if(options) group.options=*options; + if(t&&!isid(t)) + group.transform.reset(new PRCGeneralTransformation3d(t)); +} + +void oPRCFile::endgroup() +{ + if(!currentGroups.empty()) + currentGroups.pop(); +} + +PRCgroup& oPRCFile::findGroup() +{ + if(!currentGroups.empty()) + return *(currentGroups.top()); + else + return rootGroup; +} + +#define ADDWIRE(curvtype) \ + PRCgroup &group = findGroup(); \ + group.wires.push_back(PRCwire()); \ + PRCwire &wire = group.wires.back(); \ + curvtype *curve = new curvtype; \ + wire.curve.reset(curve); \ + wire.style = addColour(c); + +#define ADDFACE(surftype) \ + PRCgroup &group = findGroup(); \ + group.faces.push_back(PRCface()); \ + PRCface& face = group.faces.back(); \ + surftype *surface = new surftype; \ + face.face.reset(new PRCFace); \ + face.face->setSurface(surface); \ + face.transparent = m.alpha < 1.0; \ + face.style = addMaterial(m); + +#define ADDCOMPFACE \ + PRCgroup &group = findGroup(); \ + group.compfaces.push_back(PRCcompface()); \ + PRCcompface& face = group.compfaces.back(); \ + PRCCompressedFace *compface = new PRCCompressedFace; \ + face.face.reset(compface); \ + face.transparent = m.alpha < 1.0; \ + face.style = addMaterial(m); + +void oPRCFile::addPoint(const double P[3], const RGBAColour &c) +{ + PRCgroup &group = findGroup(); + group.points[addColour(c)].push_back(PRCVector3d(P[0],P[1],P[2])); +} + +void oPRCFile::addLine(uint32_t n, const double P[][3], const RGBAColour &c) +{ + PRCgroup &group = findGroup(); + if(group.options.tess) + { + group.lines.push_back(PRCtessline()); + group.lines.back().color.red = c.R; + group.lines.back().color.green = c.G; + group.lines.back().color.blue = c.B; + for(uint32_t i=0; i<n; i++) + group.lines.back().point.push_back(PRCVector3d(P[i][0],P[i][1],P[i][2])); + } + else + { + ADDWIRE(PRCPolyLine) + curve->point.resize(n); + for(uint32_t i=0; i<n; i++) + curve->point[i].Set(P[i][0],P[i][1],P[i][2]); + curve->interval.min = 0; + curve->interval.max = curve->point.size()-1; + } +} + +void oPRCFile::addBezierCurve(uint32_t n, const double cP[][3], + const RGBAColour &c) +{ + ADDWIRE(PRCNURBSCurve) + curve->is_rational = false; + curve->degree = 3; + const size_t NUMBER_OF_POINTS = n; + curve->control_point.resize(NUMBER_OF_POINTS); + for(size_t i = 0; i < NUMBER_OF_POINTS; ++i) + curve->control_point[i].Set(cP[i][0],cP[i][1],cP[i][2]); + curve->knot.resize(3+NUMBER_OF_POINTS+1); + curve->knot[0] = 1; + for(size_t i = 1; i < 3+NUMBER_OF_POINTS; ++i) + curve->knot[i] = (i+2)/3; // integer division is intentional + curve->knot[3+NUMBER_OF_POINTS] = (3+NUMBER_OF_POINTS+1)/3; +} + +void oPRCFile::addCurve(uint32_t d, uint32_t n, const double cP[][3], const double *k, const RGBAColour &c, const double w[]) +{ + ADDWIRE(PRCNURBSCurve) + curve->is_rational = w; + curve->degree = d; + curve->control_point.resize(n); + for(uint32_t i = 0; i < n; i++) + if(w) + curve->control_point[i].Set(cP[i][0]*w[i],cP[i][1]*w[i],cP[i][2]*w[i],w[i]); + else + curve->control_point[i].Set(cP[i][0],cP[i][1],cP[i][2]); + curve->knot.resize(d+n+1); + for(uint32_t i = 0; i < d+n+1; i++) + curve->knot[i] = k[i]; +} + +void oPRCFile::addRectangle(const double P[][3], const PRCmaterial &m) +{ + PRCgroup &group = findGroup(); + if(group.options.tess) + { + PRCgroup &group = findGroup(); + group.rectangles.push_back(PRCtessrectangle()); + PRCtessrectangle &rectangle = group.rectangles.back(); + rectangle.style = addMaterial(m); + for(size_t i = 0; i < 4; i++) + { + rectangle.vertices[i].x = P[i][0]; + rectangle.vertices[i].y = P[i][1]; + rectangle.vertices[i].z = P[i][2]; + } + } + else if(group.options.compression == 0.0) + { + ADDFACE(PRCNURBSSurface) + + surface->is_rational = false; + surface->degree_in_u = 1; + surface->degree_in_v = 1; + surface->control_point.resize(4); + for(size_t i = 0; i < 4; ++i) + { + surface->control_point[i].x = P[i][0]; + surface->control_point[i].y = P[i][1]; + surface->control_point[i].z = P[i][2]; + } + surface->knot_u.resize(4); + surface->knot_v.resize(4); + surface->knot_v[0] = surface->knot_u[0] = 1; + surface->knot_v[1] = surface->knot_u[1] = 3; + surface->knot_v[2] = surface->knot_u[2] = 4; + surface->knot_v[3] = surface->knot_u[3] = 4; + } + else + { + ADDCOMPFACE + + compface->degree = 1; + compface->control_point.resize(4); + for(size_t i = 0; i < 4; ++i) + { + compface->control_point[i].x = P[i][0]; + compface->control_point[i].y = P[i][1]; + compface->control_point[i].z = P[i][2]; + } + } +} + +void oPRCFile::addPatch(const double cP[][3], const PRCmaterial &m) +{ + PRCgroup &group = findGroup(); + if(group.options.compression == 0.0) + { + ADDFACE(PRCNURBSSurface) + + surface->is_rational = false; + surface->degree_in_u = 3; + surface->degree_in_v = 3; + surface->control_point.resize(16); + for(size_t i = 0; i < 16; ++i) + { + surface->control_point[i].x = cP[i][0]; + surface->control_point[i].y = cP[i][1]; + surface->control_point[i].z = cP[i][2]; + } + surface->knot_u.resize(8); + surface->knot_v.resize(8); + surface->knot_v[0] = surface->knot_u[0] = 1; + surface->knot_v[1] = surface->knot_u[1] = 1; + surface->knot_v[2] = surface->knot_u[2] = 1; + surface->knot_v[3] = surface->knot_u[3] = 1; + surface->knot_v[4] = surface->knot_u[4] = 2; + surface->knot_v[5] = surface->knot_u[5] = 2; + surface->knot_v[6] = surface->knot_u[6] = 2; + surface->knot_v[7] = surface->knot_u[7] = 2; + } + else + { + ADDCOMPFACE + + compface->degree = 3; + compface->control_point.resize(16); + for(size_t i = 0; i < 16; ++i) + { + compface->control_point[i].x = cP[i][0]; + compface->control_point[i].y = cP[i][1]; + compface->control_point[i].z = cP[i][2]; + } + } +} + +void oPRCFile::addSurface(uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV, + const double cP[][3], const double *kU, + const double *kV, const PRCmaterial &m, + const double w[]) +{ + ADDFACE(PRCNURBSSurface) + + surface->is_rational = w; + surface->degree_in_u = dU; + surface->degree_in_v = dV; + surface->control_point.resize(nU*nV); + for(size_t i = 0; i < nU*nV; i++) + if(w) + surface->control_point[i]=PRCControlPoint(cP[i][0]*w[i],cP[i][1]*w[i],cP[i][2]*w[i],w[i]); + else + surface->control_point[i]=PRCControlPoint(cP[i][0],cP[i][1],cP[i][2]); + surface->knot_u.insert(surface->knot_u.end(), kU, kU+(dU+nU+1)); + surface->knot_v.insert(surface->knot_v.end(), kV, kV+(dV+nV+1)); +} + +#define SETTRANSF \ + if(t&&!isid(t)) \ + face.transform.reset(new PRCGeneralTransformation3d(t)); \ + if(origin) surface->origin.Set(origin[0],origin[1],origin[2]); \ + if(x_axis) surface->x_axis.Set(x_axis[0],x_axis[1],x_axis[2]); \ + if(y_axis) surface->y_axis.Set(y_axis[0],y_axis[1],y_axis[2]); \ + surface->scale = scale; \ + surface->geometry_is_2D = false; \ + if(surface->origin!=PRCVector3d(0,0,0)) \ + surface->behaviour = surface->behaviour | PRC_TRANSFORMATION_Translate; \ + if(surface->x_axis!=PRCVector3d(1,0,0)||surface->y_axis!=PRCVector3d(0,1,0)) \ + surface->behaviour = surface->behaviour | PRC_TRANSFORMATION_Rotate; \ + if(surface->scale!=1) \ + surface->behaviour = surface->behaviour | PRC_TRANSFORMATION_Scale; \ + surface->has_transformation = (surface->behaviour != PRC_TRANSFORMATION_Identity); + +#define PRCFACETRANSFORM const double origin[3], const double x_axis[3], const double y_axis[3], double scale, const double t[][4] + +void oPRCFile::addTube(uint32_t n, const double cP[][3], const double oP[][3], bool straight, const PRCmaterial &m, PRCFACETRANSFORM) +{ + ADDFACE(PRCBlend01) + SETTRANSF + if(straight) + { + PRCPolyLine *center_curve = new PRCPolyLine; + center_curve->point.resize(n); + for(uint32_t i=0; i<n; i++) + center_curve->point[i].Set(cP[i][0],cP[i][1],cP[i][2]); + center_curve->interval.min = 0; + center_curve->interval.max = center_curve->point.size()-1; + surface->setCenterCurve(center_curve); + + PRCPolyLine *origin_curve = new PRCPolyLine; + origin_curve->point.resize(n); + for(uint32_t i=0; i<n; i++) + origin_curve->point[i].Set(oP[i][0],oP[i][1],oP[i][2]); + origin_curve->interval.min = 0; + origin_curve->interval.max = origin_curve->point.size()-1; + surface->setOriginCurve(origin_curve); + + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 2*pi; + surface->uv_domain.min.y = center_curve->interval.min; + surface->uv_domain.max.y = center_curve->interval.max; + } + else + { + PRCNURBSCurve *center_curve = new PRCNURBSCurve; + center_curve->is_rational = false; + center_curve->degree = 3; + const uint32_t CENTER_NUMBER_OF_POINTS = n; + center_curve->control_point.resize(CENTER_NUMBER_OF_POINTS); + for(uint32_t i = 0; i < CENTER_NUMBER_OF_POINTS; ++i) + center_curve->control_point[i].Set(cP[i][0],cP[i][1],cP[i][2]); + center_curve->knot.resize(3+CENTER_NUMBER_OF_POINTS+1); + center_curve->knot[0] = 1; + for(uint32_t i = 1; i < 3+CENTER_NUMBER_OF_POINTS; ++i) + center_curve->knot[i] = (i+2)/3; // integer division is intentional + center_curve->knot[3+CENTER_NUMBER_OF_POINTS] = (3+CENTER_NUMBER_OF_POINTS+1)/3; + surface->setCenterCurve(center_curve); + + PRCNURBSCurve *origin_curve = new PRCNURBSCurve; + origin_curve->is_rational = false; + origin_curve->degree = 3; + const uint32_t ORIGIN_NUMBER_OF_POINTS = n; + origin_curve->control_point.resize(ORIGIN_NUMBER_OF_POINTS); + for(uint32_t i = 0; i < ORIGIN_NUMBER_OF_POINTS; ++i) + origin_curve->control_point[i].Set(oP[i][0],oP[i][1],oP[i][2]); + origin_curve->knot.resize(3+ORIGIN_NUMBER_OF_POINTS+1); + origin_curve->knot[0] = 1; + for(size_t i = 1; i < 3+ORIGIN_NUMBER_OF_POINTS; ++i) + origin_curve->knot[i] = (i+2)/3; // integer division is intentional + origin_curve->knot[3+ORIGIN_NUMBER_OF_POINTS] = (3+ORIGIN_NUMBER_OF_POINTS+1)/3; + surface->setOriginCurve(origin_curve); + + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 2*pi; + surface->uv_domain.min.y = 1; // first knot + surface->uv_domain.max.y = (3+CENTER_NUMBER_OF_POINTS+1)/3; // last knot + } +} + +void oPRCFile::addHemisphere(double radius, const PRCmaterial &m, PRCFACETRANSFORM) +{ + ADDFACE(PRCSphere) + SETTRANSF + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 2*pi; + surface->uv_domain.min.y = 0; + surface->uv_domain.max.y = 0.5*pi; + surface->radius = radius; +} + +void oPRCFile::addSphere(double radius, const PRCmaterial &m, PRCFACETRANSFORM) +{ + ADDFACE(PRCSphere) + SETTRANSF + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 2*pi; + surface->uv_domain.min.y =-0.5*pi; + surface->uv_domain.max.y = 0.5*pi; + surface->radius = radius; +} + +void oPRCFile::addDisk(double radius, const PRCmaterial &m, PRCFACETRANSFORM) +{ + ADDFACE(PRCRuled) + SETTRANSF + PRCCircle *first_curve = new PRCCircle; + first_curve->radius = radius; + surface->setFirstCurve(first_curve); + PRCCircle *second_curve = new PRCCircle; + second_curve->radius = 0; + surface->setSecondCurve(second_curve); + + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 1; + surface->uv_domain.min.y = 0; + surface->uv_domain.max.y = 2*pi; + surface->parameterization_on_v_coeff_a = -1; + surface->parameterization_on_v_coeff_b = 2*pi; +} + +void oPRCFile::addCylinder(double radius, double height, const PRCmaterial &m, PRCFACETRANSFORM) +{ + ADDFACE(PRCCylinder) + SETTRANSF + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 2*pi; + surface->uv_domain.min.y = (height>0)?0:height; + surface->uv_domain.max.y = (height>0)?height:0; + surface->radius = radius; +} + +void oPRCFile::addTorus(double major_radius, double minor_radius, double angle1, double angle2, const PRCmaterial &m, PRCFACETRANSFORM) +{ + ADDFACE(PRCTorus) + SETTRANSF + surface->uv_domain.min.x = (angle1/180)*pi; + surface->uv_domain.max.x = (angle2/180)*pi; + surface->uv_domain.min.y = 0; + surface->uv_domain.max.y = 2*pi; + surface->major_radius = major_radius; + surface->minor_radius = minor_radius; +} + +#undef PRCFACETRANSFORM +#undef ADDFACE +#undef ADDWIRE +#undef SETTRANSF + +uint32_t PRCFileStructure::addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric) +{ + globals.materials.push_back(PRCpMaterial(pMaterialGeneric)); + return globals.materials.size()-1; +} + +uint32_t PRCFileStructure::addTextureApplication(PRCTextureApplication *pTextureApplication) +{ + globals.materials.push_back(PRCpMaterial(pTextureApplication)); + return globals.materials.size()-1; +} + +uint32_t PRCFileStructure::addStyle(PRCStyle *pStyle) +{ + globals.styles.push_back(PRCpStyle(pStyle)); + return globals.styles.size()-1; +} + +uint32_t PRCFileStructure::addPartDefinition(PRCPartDefinition *pPartDefinition) +{ + tree.part_definitions.push_back(PRCpPartDefinition(pPartDefinition)); + return tree.part_definitions.size()-1; +} + +uint32_t PRCFileStructure::addProductOccurrence(PRCProductOccurrence *pProductOccurrence) +{ + tree.product_occurrences.push_back(PRCpProductOccurrence(pProductOccurrence)); + return tree.product_occurrences.size()-1; +} + +uint32_t PRCFileStructure::addTopoContext(PRCTopoContext *pTopoContext) +{ + contexts.push_back(PRCpTopoContext(pTopoContext)); + return contexts.size()-1; +} + +uint32_t PRCFileStructure::add3DTess(PRC3DTess *p3DTess) +{ + tessellations.tessellations.push_back(PRCpTess(p3DTess)); + return tessellations.tessellations.size()-1; +} + +uint32_t PRCFileStructure::add3DWireTess(PRC3DWireTess *p3DWireTess) +{ + tessellations.tessellations.push_back(PRCpTess(p3DWireTess)); + return tessellations.tessellations.size()-1; +} +/* +uint32_t PRCFileStructure::addMarkupTess(PRCMarkupTess *pMarkupTess) +{ + tessellations.tessellations.push_back(PRCpTess(pMarkupTess)); + return tessellations.tessellations.size()-1; +} + +uint32_t PRCFileStructure::addMarkup(PRCMarkup *pMarkup) +{ + tree.markups.push_back(PRCpMarkup(pMarkup)); + return tree.markups.size()-1; +} + +uint32_t PRCFileStructure::addAnnotationItem(PRCAnnotationItem *pAnnotationItem) +{ + tree.annotation_entities.push_back(PRCpAnnotationItem(pAnnotationItem)); + return tree.annotation_entities.size()-1; +} +*/ +uint32_t PRCFileStructure::addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem) +{ + globals.reference_coordinate_systems.push_back(PRCpCoordinateSystem(pCoordinateSystem)); + return globals.reference_coordinate_systems.size()-1; +} + +uint32_t PRCFileStructure::addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem) +{ + for(uint32_t i = 0; i < globals.reference_coordinate_systems.size(); ++i) + { + if(*(globals.reference_coordinate_systems[i])==*pCoordinateSystem) + return i; + } + globals.reference_coordinate_systems.push_back(PRCpCoordinateSystem(pCoordinateSystem)); + return globals.reference_coordinate_systems.size()-1; } diff --git a/Build/source/utils/asymptote/prc/oPRCFile.h b/Build/source/utils/asymptote/prc/oPRCFile.h index 2ee01ddcba4..647f57c7d52 100644 --- a/Build/source/utils/asymptote/prc/oPRCFile.h +++ b/Build/source/utils/asymptote/prc/oPRCFile.h @@ -24,6 +24,9 @@ #include <iostream> #include <fstream> #include <vector> +#include <map> +#include <list> +#include <stack> #include <string> #ifdef HAVE_CONFIG_H @@ -35,6 +38,7 @@ #include "writePRC.h" class oPRCFile; +class PRCFileStructure; struct RGBAColour { @@ -46,145 +50,140 @@ struct RGBAColour { return (R==c.R && G==c.G && B==c.B && A==c.A); } + bool operator!=(const RGBAColour &c) const + { + return !(R==c.R && G==c.G && B==c.B && A==c.A); + } + bool operator<(const RGBAColour &c) const + { + if(R!=c.R) + return (R<c.R); + if(G!=c.G) + return (G<c.G); + if(B!=c.B) + return (B<c.B); + return (A<c.A); + } }; +typedef std::map<RGBAColour,uint32_t> PRCcolourMap; +typedef std::map<PRCRgbColor,uint32_t> PRCcolorMap; -struct PRCMaterial +struct PRCmaterial { - PRCMaterial() : alpha(1.0),shininess(1.0) {} - PRCMaterial(const RGBAColour &a, const RGBAColour &d, const RGBAColour &e, + PRCmaterial() : alpha(1.0),shininess(1.0) {} + PRCmaterial(const RGBAColour &a, const RGBAColour &d, const RGBAColour &e, const RGBAColour &s, double p, double h) : ambient(a), diffuse(d), emissive(e), specular(s), alpha(p), shininess(h) {} RGBAColour ambient,diffuse,emissive,specular; double alpha,shininess; - bool operator==(const PRCMaterial &m) const + bool operator==(const PRCmaterial &m) const { return (ambient==m.ambient && diffuse==m.diffuse && emissive==m.emissive - && specular==m.specular && shininess==m.shininess); + && specular==m.specular && alpha==m.alpha && shininess==m.shininess); + } + bool operator<(const PRCmaterial &m) const + { + if(ambient!=m.ambient) + return (ambient<m.ambient); + if(diffuse!=m.diffuse) + return (diffuse<m.diffuse); + if(emissive!=m.emissive) + return (emissive<m.emissive); + if(specular!=m.specular) + return (specular<m.specular); + if(alpha!=m.alpha) + return (alpha<m.alpha); + return (shininess<m.shininess); } }; +typedef std::map<PRCmaterial,uint32_t> PRCmaterialMap; -class PRCentity +struct PRCtessrectangle // rectangle { - public: - PRCentity(oPRCFile *p,const RGBAColour &c, double scale = 1.0, - std::string name = "") : - colour(c), useMaterial(false), scale(scale), name(name), parent(p) {} - PRCentity(oPRCFile *p,const PRCMaterial &m, double scale = 1.0, - std::string name = "") : - material(m), useMaterial(true), scale(scale), name(name), parent(p) {} - uint32_t getGraphicsIndex(); - virtual void writeRepresentationItem(PRCbitStream&,uint32_t) = 0; - virtual void writeTopologicalContext(PRCbitStream&) = 0; - virtual void writeExtraGeometryContext(PRCbitStream&) = 0; - RGBAColour colour; - PRCMaterial material; - bool useMaterial; - double scale; - std::string name; - virtual ~PRCentity() {} - protected: - oPRCFile *parent; + PRCVector3d vertices[4]; + uint32_t style; }; +typedef std::vector<PRCtessrectangle> PRCtessrectangleList; -class PRCsurface : public PRCentity +struct PRCtessline // polyline { - public: - // contructor with colour - PRCsurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV, - double cP[][3], double *kU, double *kV, const RGBAColour &c, - double scale = 1.0, bool iR = false, double w[] = 0, - double g = 0, std::string name = "") : - PRCentity(p,c,scale,name), degreeU(dU), degreeV(dV), - numberOfControlPointsU(nU), numberOfControlPointsV(nV), - knotsU(kU), knotsV(kV), controlPoints(cP), - isRational(iR), weights(w), granularity(g) {} - // contructor with material - PRCsurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV, - double cP[][3], double *kU, double *kV, const PRCMaterial &m, - double scale = 1.0, bool iR = false, double w[] = 0, - double g = 0, std::string name = "") : - PRCentity(p,m,scale,name), degreeU(dU), degreeV(dV), - numberOfControlPointsU(nU), numberOfControlPointsV(nV), - knotsU(kU), knotsV(kV), controlPoints(cP), - isRational(iR), weights(w), granularity(g) {} - virtual void writeRepresentationItem(PRCbitStream&,uint32_t); - virtual void writeTopologicalContext(PRCbitStream&); - virtual void writeExtraGeometryContext(PRCbitStream&); - protected: - virtual void writeKnots(PRCbitStream &out) - { - for(uint32_t i = 0; i < degreeU+numberOfControlPointsU+1; ++i) - out << knotsU[i]; - for(uint32_t i = 0; i < degreeV+numberOfControlPointsV+1; ++i) - out << knotsV[i]; - } - private: - uint32_t degreeU, degreeV, numberOfControlPointsU, numberOfControlPointsV; - double *knotsU, *knotsV; - double (*controlPoints)[3]; - bool isRational; - double *weights; - double granularity; + std::vector<PRCVector3d> point; + PRCRgbColor color; }; +typedef std::list<PRCtessline> PRCtesslineList; -class PRCline : public PRCentity +struct PRCface { - public: - // constructor with colour - PRCline(oPRCFile *p, uint32_t n, double P[][3], const RGBAColour &c, - double scale = 1.0, std::string name="") : - PRCentity(p,c,scale,name), numberOfPoints(n), points(P) {} - // constructor with material - PRCline(oPRCFile *p, uint32_t n, double P[][3], const PRCMaterial &m, - double scale = 1.0, std::string name = "") : - PRCentity(p,m,scale,name), numberOfPoints(n), points(P) {} - virtual void writeRepresentationItem(PRCbitStream&,uint32_t); - virtual void writeTopologicalContext(PRCbitStream&); - virtual void writeExtraGeometryContext(PRCbitStream&); - private: - uint32_t numberOfPoints; - double (*points)[3]; + uint32_t style; + bool transparent; + PRCpGeneralTransformation3d transform; + PRCpFace face; }; +typedef std::tr1::shared_ptr <PRCface> PRCpface; +typedef std::vector <PRCface> PRCfaceList; -class PRCcurve : public PRCentity +struct PRCcompface { - public: - // constructor with colour - PRCcurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3], double *k, - const RGBAColour &c, double scale = 1.0, bool iR = false, - double w[] = 0, std::string name="") : - PRCentity(p,c,scale,name), degree(d), - numberOfControlPoints(n), knots(k), controlPoints(cP), isRational(iR), - weights(w) {} - // constructor with material - PRCcurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3], double *k, - const PRCMaterial &m, double scale = 1.0, bool iR = false, - double w[] = 0, std::string name = "") : - PRCentity(p,m,scale,name), degree(d), - numberOfControlPoints(n), knots(k), controlPoints(cP), isRational(iR), - weights(w) {} - virtual void writeRepresentationItem(PRCbitStream&,uint32_t); - virtual void writeTopologicalContext(PRCbitStream&); - virtual void writeExtraGeometryContext(PRCbitStream&); - protected: - virtual void writeKnots(PRCbitStream &out) - { - for(uint32_t i = 0; i < degree+numberOfControlPoints+1; ++i) - out << knots[i]; - } - private: - uint32_t degree, numberOfControlPoints; - double *knots; - double (*controlPoints)[3]; - bool isRational; - double *weights; + uint32_t style; + bool transparent; + PRCpCompressedFace face; +}; +typedef std::tr1::shared_ptr <PRCcompface> PRCpcompface; +typedef std::vector <PRCcompface> PRCcompfaceList; + +struct PRCwire +{ + uint32_t style; + PRCpGeneralTransformation3d transform; + PRCpCurve curve; }; +typedef std::tr1::shared_ptr <PRCwire> PRCpwire; +typedef std::vector <PRCwire> PRCwireList; + +typedef std::map <uint32_t,std::vector<PRCVector3d> > PRCpointsetMap; + +class PRCoptions +{ +public: + double compression; + double granularity; + + bool closed; // render the surface as one-sided; may yield faster rendering + bool tess; // use tessellated mesh to store straight patches + bool do_break; // + bool no_break; // do not render transparent patches as one-faced nodes + + PRCoptions(double compression=0.0, double granularity=0.0, bool closed=false, + bool tess=false, bool do_break=true, bool no_break=false) + : compression(compression), granularity(granularity), closed(closed), + tess(tess), do_break(do_break), no_break(no_break) {} +}; + +class PRCgroup +{ + public: + PRCgroup() {} + PRCgroup(const std::string &name) : name(name) {} + PRCfaceList faces; + PRCcompfaceList compfaces; + PRCtessrectangleList rectangles; + PRCtesslineList lines; + PRCwireList wires; + PRCpointsetMap points; + std::string name; + std::list<PRCgroup> groupList; + PRCpGeneralTransformation3d transform; + PRCoptions options; +}; +typedef std::list<PRCgroup> PRCgroupList; class PRCCompressedSection { public: - PRCCompressedSection(oPRCFile *p) : data(0),prepared(false),parent(p), + PRCCompressedSection(oPRCFile *p) : data(0),prepared(false),parent(p),fileStructure(NULL), + out(data,0) {} + PRCCompressedSection(PRCFileStructure *fs) : data(0),prepared(false),parent(NULL),fileStructure(fs), out(data,0) {} virtual ~PRCCompressedSection() { @@ -204,25 +203,31 @@ class PRCCompressedSection } bool prepared; oPRCFile *parent; + PRCFileStructure *fileStructure; PRCbitStream out; // order matters: PRCbitStream must be initialized last }; class PRCGlobalsSection : public PRCCompressedSection { public: - PRCGlobalsSection(oPRCFile *p, uint32_t i) : - PRCCompressedSection(p),numberOfReferencedFileStructures(0), + PRCGlobalsSection(PRCFileStructure *fs, uint32_t i) : + PRCCompressedSection(fs),numberOfReferencedFileStructures(0), tessellationChordHeightRatio(2000.0),tessellationAngleDegrees(40.0), - defaultFontFamilyName(""),numberOfFonts(0),numberOfPictures(0), - numberOfTextureDefinitions(0),numberOfFillPatterns(0), - numberOfReferenceCoordinateSystems(0),userData(0,0),index(i) {} + defaultFontFamilyName(""), + numberOfFillPatterns(0), + userData(0,0),index(i) {} uint32_t numberOfReferencedFileStructures; double tessellationChordHeightRatio; double tessellationAngleDegrees; std::string defaultFontFamilyName; - uint32_t numberOfFonts,numberOfPictures,numberOfTextureDefinitions; + std::vector<PRCRgbColor> colors; + std::vector<PRCPicture> pictures; + PRCTextureDefinitionList texture_definitions; + PRCMaterialList materials; + PRCStyleList styles; uint32_t numberOfFillPatterns; - uint32_t numberOfReferenceCoordinateSystems; + PRCCoordinateSystemList reference_coordinate_systems; + std::vector<PRCFontKeysSameFont> font_keys_of_font; UserData userData; private: uint32_t index; @@ -232,8 +237,15 @@ class PRCGlobalsSection : public PRCCompressedSection class PRCTreeSection : public PRCCompressedSection { public: - PRCTreeSection(oPRCFile *p, uint32_t i) : - PRCCompressedSection(p),index(i) {} + PRCTreeSection(PRCFileStructure *fs, uint32_t i) : + PRCCompressedSection(fs),unit(1),index(i) {} + PRCPartDefinitionList part_definitions; + PRCProductOccurrenceList product_occurrences; +/* + PRCMarkupList markups; + PRCAnnotationItemList annotation_entities; + */ + double unit; private: uint32_t index; virtual void writeData(); @@ -242,8 +254,9 @@ class PRCTreeSection : public PRCCompressedSection class PRCTessellationSection : public PRCCompressedSection { public: - PRCTessellationSection(oPRCFile *p, uint32_t i) : - PRCCompressedSection(p),index(i) {} + PRCTessellationSection(PRCFileStructure *fs, uint32_t i) : + PRCCompressedSection(fs),index(i) {} + PRCTessList tessellations; private: uint32_t index; virtual void writeData(); @@ -252,8 +265,8 @@ class PRCTessellationSection : public PRCCompressedSection class PRCGeometrySection : public PRCCompressedSection { public: - PRCGeometrySection(oPRCFile *p, uint32_t i) : - PRCCompressedSection(p),index(i) {} + PRCGeometrySection(PRCFileStructure *fs, uint32_t i) : + PRCCompressedSection(fs),index(i) {} private: uint32_t index; virtual void writeData(); @@ -262,8 +275,8 @@ class PRCGeometrySection : public PRCCompressedSection class PRCExtraGeometrySection : public PRCCompressedSection { public: - PRCExtraGeometrySection(oPRCFile *p, uint32_t i) : - PRCCompressedSection(p),index(i) {} + PRCExtraGeometrySection(PRCFileStructure *fs, uint32_t i) : + PRCCompressedSection(fs),index(i) {} private: uint32_t index; virtual void writeData(); @@ -272,7 +285,8 @@ class PRCExtraGeometrySection : public PRCCompressedSection class PRCModelFile : public PRCCompressedSection { public: - PRCModelFile(oPRCFile *p) : PRCCompressedSection(p) {} + PRCModelFile(oPRCFile *p) : PRCCompressedSection(p), unit(1) {} + double unit; private: virtual void writeData(); }; @@ -283,8 +297,13 @@ void makeAppUUID(uint32_t*); class PRCUncompressedFile { public: + PRCUncompressedFile() : file_size(0), data(NULL) {} + PRCUncompressedFile(uint32_t fs, uint8_t *d) : file_size(fs), data(d) {} +// PRCUncompressedFile(uint32_t fs, const std::string &fn) : file_size(fs), data(NULL), file_name(fn) {} + ~PRCUncompressedFile() { if(data != NULL) delete[] data; } uint32_t file_size; uint8_t *data; +// std::string file_name; void write(std::ostream&); @@ -311,8 +330,8 @@ class PRCFileStructure uint32_t index; public: PRCStartHeader header; - uint32_t number_of_uncompressed_files; - PRCUncompressedFile *uncompressedFiles; + std::list<PRCUncompressedFile> uncompressedFiles; + PRCTopoContextList contexts; PRCGlobalsSection globals; PRCTreeSection tree; @@ -321,11 +340,30 @@ class PRCFileStructure PRCExtraGeometrySection extraGeometry; PRCFileStructure(oPRCFile *p, uint32_t i) : parent(p),index(i), - globals(p,i),tree(p,i),tessellations(p,i),geometry(p,i), - extraGeometry(p,i) {} + globals(this,i),tree(this,i),tessellations(this,i),geometry(this,i), + extraGeometry(this,i) {} void write(std::ostream&); void prepare(); uint32_t getSize(); + uint32_t addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *picture, uint32_t width=0, uint32_t height=0, std::string name=""); + uint32_t addTextureDefinition(PRCTextureDefinition *pTextureDefinition); + uint32_t addRgbColor(const PRCRgbColor &color); + uint32_t addRgbColorUnique(const PRCRgbColor &color); + uint32_t addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric); + uint32_t addTextureApplication(PRCTextureApplication *pTextureApplication); + uint32_t addStyle(PRCStyle *pStyle); + uint32_t addPartDefinition(PRCPartDefinition *pPartDefinition); + uint32_t addProductOccurrence(PRCProductOccurrence *pProductOccurrence); + uint32_t addTopoContext(PRCTopoContext *pTopoContext); + uint32_t add3DTess(PRC3DTess *p3DTess); + uint32_t add3DWireTess(PRC3DWireTess *p3DWireTess); +/* + uint32_t addMarkupTess(PRCMarkupTess *pMarkupTess); + uint32_t addMarkup(PRCMarkup *pMarkup); + uint32_t addAnnotationItem(PRCAnnotationItem *pAnnotationItem); + */ + uint32_t addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem); + uint32_t addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem); }; class PRCFileStructureInformation @@ -349,27 +387,52 @@ class PRCHeader PRCFileStructureInformation *fileStructureInformation; uint32_t model_file_offset; uint32_t file_size; // not documented - uint32_t number_of_uncompressed_files; - PRCUncompressedFile *uncompressedFiles; + std::list<PRCUncompressedFile> uncompressedFiles; void write(std::ostream&); uint32_t getSize(); }; +typedef std::map <PRCGeneralTransformation3d,uint32_t> PRCtransformMap; + class oPRCFile { public: - oPRCFile(std::ostream &os, uint32_t n=1) : + oPRCFile(std::ostream &os, double unit=1, uint32_t n=1) : number_of_file_structures(n), fileStructures(new PRCFileStructure*[n]),modelFile(this), - fout(NULL),output(os) {} - - oPRCFile(const std::string &name, uint32_t n=1) : + fout(NULL),output(os) + { + for(uint32_t i = 0; i < number_of_file_structures; ++i) + { + fileStructures[i] = new PRCFileStructure(this,i); + fileStructures[i]->header.minimal_version_for_read = PRCVersion; + fileStructures[i]->header.authoring_version = PRCVersion; + makeFileUUID(fileStructures[i]->header.fileStructureUUID); + makeAppUUID(fileStructures[i]->header.applicationUUID); + fileStructures[i]->tree.unit = unit; + } + modelFile.unit = unit; + } + + oPRCFile(const std::string &name, double unit=1, uint32_t n=1) : number_of_file_structures(n), fileStructures(new PRCFileStructure*[n]),modelFile(this), fout(new std::ofstream(name.c_str(), std::ios::out|std::ios::binary|std::ios::trunc)), - output(*fout) {} + output(*fout) + { + for(uint32_t i = 0; i < number_of_file_structures; ++i) + { + fileStructures[i] = new PRCFileStructure(this,i); + fileStructures[i]->header.minimal_version_for_read = PRCVersion; + fileStructures[i]->header.authoring_version = PRCVersion; + makeFileUUID(fileStructures[i]->header.fileStructureUUID); + makeAppUUID(fileStructures[i]->header.applicationUUID); + fileStructures[i]->tree.unit = unit; + } + modelFile.unit = unit; + } ~oPRCFile() { @@ -380,23 +443,120 @@ class oPRCFile delete fout; } - void begingroup(std::string name) {} - void endgroup() {} + void begingroup(const char *name, PRCoptions *options=NULL, + const double t[][4]=NULL); + void endgroup(); - bool add(PRCentity*); bool finish(); - uint32_t getColourIndex(const RGBAColour&); - uint32_t getMaterialIndex(const PRCMaterial&); uint32_t getSize(); const uint32_t number_of_file_structures; PRCFileStructure **fileStructures; PRCHeader header; PRCModelFile modelFile; - std::vector<PRCentity*> fileEntities; - std::vector<RGBAColour> colourMap; - std::vector<PRCMaterial> materialMap; - + PRCcolorMap colorMap; + PRCcolourMap colourMap; + PRCmaterialMap materialMap; + PRCgroup rootGroup; + PRCtransformMap transformMap; + std::stack<PRCgroupList::iterator> currentGroups; + PRCgroup& findGroup(); + void doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence); + uint32_t addColor(const PRCRgbColor &color); + uint32_t addColour(const RGBAColour &colour); + uint32_t addMaterial(const PRCmaterial &material); + uint32_t addTransform(const PRCpGeneralTransformation3d &transform); + void addPoint(const double P[3], const RGBAColour &c); + void addLine(uint32_t n, const double P[][3], const RGBAColour &c); + void addBezierCurve(uint32_t n, const double cP[][3], const RGBAColour &c); + void addCurve(uint32_t d, uint32_t n, const double cP[][3], const double *k, const RGBAColour &c, const double w[]); + void addRectangle(const double P[][3], const PRCmaterial &m); + void addPatch(const double cP[][3], const PRCmaterial &m); + void addSurface(uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV, + const double cP[][3], const double *kU, const double *kV, const PRCmaterial &m, + const double w[]); +#define PRCFACETRANSFORM const double origin[3]=NULL, const double x_axis[3]=NULL, const double y_axis[3]=NULL, double scale=1, const double t[][4]=NULL + void addTube(uint32_t n, const double cP[][3], const double oP[][3], bool straight, const PRCmaterial &m, PRCFACETRANSFORM); + void addHemisphere(double radius, const PRCmaterial &m, PRCFACETRANSFORM); + void addSphere(double radius, const PRCmaterial &m, PRCFACETRANSFORM); + void addDisk(double radius, const PRCmaterial &m, PRCFACETRANSFORM); + void addCylinder(double radius, double height, const PRCmaterial &m, PRCFACETRANSFORM); + void addTorus(double major_radius, double minor_radius, double angle1, double angle2, const PRCmaterial &m, PRCFACETRANSFORM); +#undef PRCFACETRANSFORM + + + uint32_t addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *picture, uint32_t width=0, uint32_t height=0, + std::string name="", uint32_t fileStructure=0) + { return fileStructures[fileStructure]->addPicture(format, size, picture, width, height, name); } + uint32_t addTextureDefinition(PRCTextureDefinition *pTextureDefinition, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addTextureDefinition(pTextureDefinition); + } + uint32_t addTextureApplication(PRCTextureApplication *pTextureApplication, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addTextureApplication(pTextureApplication); + } + uint32_t addRgbColor(const PRCRgbColor &color, + uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addRgbColor(color); + } + uint32_t addRgbColorUnique(const PRCRgbColor &color, + uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addRgbColorUnique(color); + } + uint32_t addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric, + uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addMaterialGeneric(pMaterialGeneric); + } + uint32_t addStyle(PRCStyle *pStyle, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addStyle(pStyle); + } + uint32_t addPartDefinition(PRCPartDefinition *pPartDefinition, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addPartDefinition(pPartDefinition); + } + uint32_t addProductOccurrence(PRCProductOccurrence *pProductOccurrence, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addProductOccurrence(pProductOccurrence); + } + uint32_t addTopoContext(PRCTopoContext *pTopoContext, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addTopoContext(pTopoContext); + } + uint32_t add3DTess(PRC3DTess *p3DTess, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->add3DTess(p3DTess); + } + uint32_t add3DWireTess(PRC3DWireTess *p3DWireTess, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->add3DWireTess(p3DWireTess); + } +/* + uint32_t addMarkupTess(PRCMarkupTess *pMarkupTess, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addMarkupTess(pMarkupTess); + } + uint32_t addMarkup(PRCMarkup *pMarkup, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addMarkup(pMarkup); + } + uint32_t addAnnotationItem(PRCAnnotationItem *pAnnotationItem, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addAnnotationItem(pAnnotationItem); + } + */ + uint32_t addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addCoordinateSystem(pCoordinateSystem); + } + uint32_t addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addCoordinateSystemUnique(pCoordinateSystem); + } private: std::ofstream *fout; std::ostream &output; diff --git a/Build/source/utils/asymptote/prc/test.asy b/Build/source/utils/asymptote/prc/test.asy new file mode 100644 index 00000000000..21463f2eefa --- /dev/null +++ b/Build/source/utils/asymptote/prc/test.asy @@ -0,0 +1,5 @@ +settings.outformat="pdf"; + +import embed; + +label(embed("test.prc","poster,3Droo=25",1500,500)); diff --git a/Build/source/utils/asymptote/prc/test.cc b/Build/source/utils/asymptote/prc/test.cc index e450f3acd01..4b0cadfc8a8 100644 --- a/Build/source/utils/asymptote/prc/test.cc +++ b/Build/source/utils/asymptote/prc/test.cc @@ -22,16 +22,52 @@ #include <iomanip> #include <fstream> #include <cmath> +#include <string> #include "oPRCFile.h" using namespace std; int main() { -// ofstream outf("test.prc",ios::binary); + oPRCFile file("test.prc"); + + const size_t N_COLOURS = 32; + RGBAColour colours[N_COLOURS]; + for(size_t i = 0; i < N_COLOURS; ++i) + { + colours[i%N_COLOURS].R = 0.0; + colours[i%N_COLOURS].G = (i%N_COLOURS)/static_cast<double>(N_COLOURS); + colours[i%N_COLOURS].B = 0.95; + colours[i%N_COLOURS].A = 0.75; + } + + PRCmaterial materials[N_COLOURS]; + for(size_t i = 0; i < N_COLOURS; ++i) + { + materials[i%N_COLOURS].diffuse.R = 0.0; + materials[i%N_COLOURS].diffuse.G = (i%N_COLOURS)/static_cast<double>(N_COLOURS); + materials[i%N_COLOURS].diffuse.B = 0.95; + materials[i%N_COLOURS].diffuse.A = 0.75; + materials[i%N_COLOURS].specular.R = 0.01*0.0; + materials[i%N_COLOURS].specular.G = 0.01*(i%N_COLOURS)/static_cast<double>(N_COLOURS); + materials[i%N_COLOURS].specular.B = 0.01*0.95; + materials[i%N_COLOURS].specular.A = 0.01*0.75; + materials[i%N_COLOURS].emissive.R = 0.20*0.0; + materials[i%N_COLOURS].emissive.G = 0.20*(i%N_COLOURS)/static_cast<double>(N_COLOURS); + materials[i%N_COLOURS].emissive.B = 0.20*0.95; + materials[i%N_COLOURS].emissive.A = 0.20*0.75; + materials[i%N_COLOURS].ambient.R = 0.05*0.0; + materials[i%N_COLOURS].ambient.G = 0.05*(i%N_COLOURS)/static_cast<double>(N_COLOURS); + materials[i%N_COLOURS].ambient.B = 0.05*0.95; + materials[i%N_COLOURS].ambient.A = 0.05*0.75; + materials[i%N_COLOURS].alpha = 0.75; + materials[i%N_COLOURS].shininess = 0.1; + } + + if(1) { double knotsU[] = {1,1,1,1,2,2,2,2}; double knotsV[] = {1,1,1,1,2,2,2,2}; - const int NUMBER_OF_PATCHES = 32; + const size_t NUMBER_OF_PATCHES = 32; double controlPoints[NUMBER_OF_PATCHES][16][3] = { { // Patch 0 @@ -227,51 +263,500 @@ int main() {0,-1.5,0.15},{0.84,-1.5,0.15},{1.5,-0.84,0.15},{1.5,0,0.15}, }, }; - oPRCFile file("test.prc"); - PRCsurface *psn[NUMBER_OF_PATCHES]; - const int N_COLOURS = 32; - RGBAColour colours[N_COLOURS]; - for(int i = 0; i < N_COLOURS; ++i) - { - colours[i%N_COLOURS].R = 0.0; - colours[i%N_COLOURS].G = (i%N_COLOURS)/static_cast<double>(N_COLOURS); - colours[i%N_COLOURS].B = 0.95; - colours[i%N_COLOURS].A = 0.75; + const size_t NUMBER_OF_TEAPOTS = 2; + double shifted_controlPoints[NUMBER_OF_TEAPOTS][NUMBER_OF_PATCHES][16][3]; + for(size_t teapot = 0; teapot < NUMBER_OF_TEAPOTS; ++teapot) + for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch) + for(size_t i = 0; i < 16; ++i) + { + shifted_controlPoints[teapot][patch][i][0] = controlPoints[patch][i][0]+6*teapot; + shifted_controlPoints[teapot][patch][i][1] = controlPoints[patch][i][1]; + shifted_controlPoints[teapot][patch][i][2] = controlPoints[patch][i][2]; + } + for(size_t i = 0; i < NUMBER_OF_PATCHES; ++i) + { + // was so in old API + // psn[i] = new PRCsurface(&file,3,3,4,4,controlPoints[i],knotsU,knotsV,colours[i%N_COLOURS]); + // file.add(psn[i]); + file.begingroup("Teapot"); + if (1) file.addPatch(controlPoints[i],materials[i%N_COLOURS]); + file.endgroup(); + if (0) file.addSurface(3,3,4,4,controlPoints[i],knotsU,knotsV,materials[i%N_COLOURS],NULL); // use (too) general API for the same result as above + } +// file.begingroup("Teapot rendered in the way of opaque surfacesPRCNOBREAKPRCCOMPRESSLOW"); +// for(size_t i = 0; i < NUMBER_OF_PATCHES; ++i) +// { +// file.addPatch(shifted_controlPoints[1][i],materials[i%N_COLOURS]); // force joining together of patches, damaging transparency +// } +// file.endgroup(); } - for(int i = 0; i < NUMBER_OF_PATCHES; ++i) - { - psn[i] = new PRCsurface(&file,3,3,4,4,controlPoints[i],knotsU,knotsV,colours[i%N_COLOURS]); - file.add(psn[i]); - } - - const int NUMBER_OF_POINTS = 31; + +if(1) { + const size_t NUMBER_OF_POINTS = 31; double points[NUMBER_OF_POINTS][3]; - for(int i = 0; i < NUMBER_OF_POINTS; ++i) + for(size_t i = 0; i < NUMBER_OF_POINTS; ++i) { points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*M_PI); points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*M_PI); points[i][2] = 5.0*i/NUMBER_OF_POINTS-1.0; } + const size_t NUMBER_OF_WIRES = 2; + double shifted_points[NUMBER_OF_WIRES][NUMBER_OF_POINTS][3]; + for(size_t wire = 0; wire < NUMBER_OF_WIRES; ++wire) + for(size_t point = 0; point < NUMBER_OF_POINTS; ++point) + { + shifted_points[wire][point][0] = points[point][0]; + shifted_points[wire][point][1] = points[point][1]; + shifted_points[wire][point][2] = points[point][2]+0.1*wire+0.1; + } double knots[3+NUMBER_OF_POINTS+1]; knots[0] = 1; - for(int i = 1; i < 3+NUMBER_OF_POINTS; ++i) + for(size_t i = 1; i < 3+NUMBER_OF_POINTS; ++i) { knots[i] = (i+2)/3; // integer division is intentional } knots[3+NUMBER_OF_POINTS] = (3+NUMBER_OF_POINTS+1)/3; - RGBAColour white(1.0,1.0,1.0); - PRCcurve pc(&file,3,NUMBER_OF_POINTS,points,knots,white); - file.add(&pc); + double point[3] = {11,0,0}; + file.begingroup("point"); + file.addPoint(point, RGBAColour(1.0,0.0,0.0)); + file.endgroup(); + +// RGBAColour red(1.0,0.0,0.0); +// PRCline pl(&file,NUMBER_OF_POINTS,points,red); +// file.add(&pl); + file.begingroup("polyline"); + file.addLine(NUMBER_OF_POINTS, points, RGBAColour(1.0,0.0,0.0)); + file.endgroup(); + + file.begingroup("polylines"); + file.addLine(NUMBER_OF_POINTS, shifted_points[0], RGBAColour(0.0,1.0,0.0)); + file.addLine(NUMBER_OF_POINTS, shifted_points[1], RGBAColour(1.0,1.0,0.0)); + file.endgroup(); + +// RGBAColour white(1.0,1.0,1.0); +// PRCcurve pc(&file,3,NUMBER_OF_POINTS,points,knots,white); +// file.add(&pc); + if(1) + { + file.begingroup("bezier_wire"); + file.addBezierCurve(NUMBER_OF_POINTS,points,RGBAColour(1.0,1.0,1.0)); + file.endgroup(); + } + if(0) + { + file.begingroup("NURBS_wire"); + file.addCurve(3, NUMBER_OF_POINTS, points, knots, RGBAColour(1.0,1.0,1.0), NULL); // genarl API for the above + file.endgroup(); + } + + } + +// following box examples show a) different ways to represent a surface consisting of flat rectangles +// b) that the only way to have almost working transparency is a set of NURBS bodies. +// (Or may be other topology types like plane also work +// demonstration how non-transparent materials work the same for all kinds of objects + + if (1) { // demonstration how non-transparent materials work the same for all kinds of objects + const size_t NUMBER_OF_PATCHES = 6; + double vertices[NUMBER_OF_PATCHES][4][3] = + { + { // Patch 0 + {-1,-1,-1}, + { 1,-1,-1}, + {-1, 1,-1}, + { 1, 1,-1} + }, + { // Patch 1 + {-1,-1, 1}, + { 1,-1, 1}, + {-1, 1, 1}, + { 1, 1, 1} + }, + { // Patch 2 + {-1,-1,-1}, + { 1,-1,-1}, + {-1,-1, 1}, + { 1,-1, 1} + }, + { // Patch 3 + {-1, 1,-1}, + { 1, 1,-1}, + {-1, 1, 1}, + { 1, 1, 1} + }, + { // Patch 4 + {-1,-1,-1}, + {-1, 1,-1}, + {-1,-1, 1}, + {-1, 1, 1} + }, + { // Patch 5 + { 1,-1,-1}, + { 1, 1,-1}, + { 1,-1, 1}, + { 1, 1, 1} + } + }; + const size_t NUMBER_OF_BOXES = 6; + double shifted_vertices[NUMBER_OF_BOXES][NUMBER_OF_PATCHES][4][3]; + for(size_t box = 0; box < NUMBER_OF_BOXES; ++box) + for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch) + for(size_t i = 0; i < 4; ++i) + { + shifted_vertices[box][patch][i][0] = vertices[patch][i][0]+3*box; + shifted_vertices[box][patch][i][1] = vertices[patch][i][1]; + shifted_vertices[box][patch][i][2] = vertices[patch][i][2]-2; + } + PRCmaterial materialGreen( + RGBAColour(0.0,0.18,0.0), + RGBAColour(0.0,0.878431,0.0), + RGBAColour(0.0,0.32,0.0), + RGBAColour(0.0,0.072,0.0), + 1.0,0.1); + + file.begingroup("TransparentBox"); + file.begingroup("SetOfNURBSBodies"); + for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch) + { + file.addRectangle(shifted_vertices[0][patch], materials[(patch*5)%N_COLOURS]); + } + file.endgroup(); + file.begingroup("NURBSFacesPRCNOBREAK"); + for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch) + { + file.addRectangle(shifted_vertices[1][patch], materials[(patch*5)%N_COLOURS]); + } + file.endgroup(); + file.begingroup("TessellatedPRCTESS"); + for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch) + { + file.addRectangle(shifted_vertices[2][patch], materials[(patch*5)%N_COLOURS]); + } + file.endgroup(); + file.endgroup(); + + file.begingroup("Box"); + file.begingroup("TessellatedPRCTESS"); + for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch) + { + file.addRectangle(shifted_vertices[3][patch], materialGreen); + } + file.endgroup(); + file.begingroup("NURBSFaces"); + for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch) + { + file.addRectangle(shifted_vertices[4][patch], materialGreen); + } + file.endgroup(); + file.begingroup("SetOfNURBSBodiesPRCDOBREAK"); + for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch) + { + file.addRectangle(shifted_vertices[5][patch], materialGreen); + } + file.endgroup(); + file.endgroup(); + } + + if(0) { // test disk + PRCTopoContext *diskContext = new PRCTopoContext; + uint32_t context_index = file.addTopoContext(diskContext); + + PRCBrepData *body = new PRCBrepData; + uint32_t body_index = diskContext->addBrepData(body); + PRCConnex *connex = new PRCConnex; + body->addConnex(connex); + PRCShell *shell = new PRCShell; + // shell->shell_is_closed = true; + connex->addShell(shell); + PRCFace *face = new PRCFace; + shell->addFace(face,2); + PRCRuled *surface = new PRCRuled; + face->setSurface(surface); + + PRCCircle *first_curve = new PRCCircle; + first_curve->radius = 1; + surface->setFirstCurve(first_curve); + PRCCircle *second_curve = new PRCCircle; + second_curve->radius = 0; + surface->setSecondCurve(second_curve); + + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 1; + surface->uv_domain.min.y = 0; + surface->uv_domain.max.y = 2*M_PI; + surface->parameterization_on_v_coeff_a = -1; + surface->parameterization_on_v_coeff_b = 2*M_PI; + + surface->has_transformation = true; + surface->geometry_is_2D = false; + surface->behaviour = PRC_TRANSFORMATION_Translate|PRC_TRANSFORMATION_Rotate; + surface->origin.Set(0,0,0); + surface->x_axis.Set(1,0,0); + surface->y_axis.Set(0,1,0); + + PRCBrepModel *brepmodel = new PRCBrepModel("disk"); + brepmodel->context_id = context_index; + brepmodel->body_id = body_index; + brepmodel->is_closed = true; // we do not need to see the tube from inside + brepmodel->index_of_line_style = 0; +// file.addBrepModel(brepmodel); + + PRCSingleWireBody *firstCurveBody = new PRCSingleWireBody; + uint32_t first_curve_body_index = diskContext->addSingleWireBody(firstCurveBody); + PRCWireEdge *firstCurveEdge = new PRCWireEdge; + firstCurveBody->setWireEdge(firstCurveEdge); + firstCurveEdge->curve_3d = surface->first_curve; + PRCWire *firstCurveWire = new PRCWire("firstCurveWire"); + firstCurveWire->index_of_line_style = 0; + firstCurveWire->context_id = context_index; + firstCurveWire->body_id = first_curve_body_index; +// file.addWire(firstCurveWire); + } + + if(1) { + PRCmaterial materialGreen( + RGBAColour(0.0,0.18,0.0), + RGBAColour(0.0,0.878431,0.0), + RGBAColour(0.0,0.32,0.0), + RGBAColour(0.0,0.072,0.0), + 1.0,0.1); + + const double disk_origin[3] = {11,0,2}; + const double disk_x_axis[3] = {1,0,0}; + const double disk_y_axis[3] = {0,-1,0}; + const double disk_scale = 2; + file.begingroup("diskPRCCLOSED"); + file.addDisk(1,materialGreen,disk_origin,disk_x_axis,disk_y_axis,disk_scale); + file.endgroup(); + const double hs_origin[3] = {11,0,2}; + const double hs_x_axis[3] = {1,0,0}; + const double hs_y_axis[3] = {0,1,0}; + const double hs_scale = 2; + file.begingroup("hemispherePRCCLOSED"); + file.addHemisphere(1,materialGreen,hs_origin,hs_x_axis,hs_y_axis,hs_scale); + file.endgroup(); + const double cyl_origin[3] = {11,0,1}; + const double cyl_x_axis[3] = {1,0,0}; + const double cyl_y_axis[3] = {0,1,0}; + const double cyl_scale = 1; + file.begingroup("cylinderPRCCLOSED"); + file.addCylinder(1,1,materialGreen,cyl_origin,cyl_x_axis,cyl_y_axis,cyl_scale); + file.endgroup(); + const double sp_origin[3] = {11,0,1}; + const double sp_x_axis[3] = {1,0,0}; + const double sp_y_axis[3] = {0,1,0}; + const double sp_scale = 1; + file.begingroup("spherePRCCLOSED"); + file.addSphere(0.5,materialGreen,sp_origin,sp_x_axis,sp_y_axis,sp_scale); + file.endgroup(); + const double tor_origin[3] = {11,0,0}; + const double tor_x_axis[3] = {1,0,0}; + const double tor_y_axis[3] = {0,1,0}; + const double tor_scale = 1; + file.begingroup("torusPRCCLOSED"); + file.addTorus(0.5,0.1,0,360,materialGreen,tor_origin,tor_x_axis,tor_y_axis,tor_scale); + file.endgroup(); + } + + if(0) { // Blend01 tube around a Composite curve - no good at corners + const size_t NUMBER_OF_POINTS = 4; + double points[NUMBER_OF_POINTS][3]; + points[0][0] = 1; points[0][1] = 0; points[0][2] = 0; + points[1][0] = 1; points[1][1] = 0.552284749830793; points[1][2] = 0; + points[2][0] = 0.552284749830793; points[2][1] = 1; points[2][2] = 0; + points[3][0] = 0; points[3][1] = 1; points[3][2] = 0; + double qoints[NUMBER_OF_POINTS][3]; + qoints[0][0] = 0; qoints[0][1] = 1; qoints[0][2] = 0; + qoints[1][0] = 0; qoints[1][1] = 1; qoints[1][2] = 0.552284749830793; + qoints[2][0] = 0; qoints[2][1] = 0.552284749830793; qoints[2][2] = 1; + qoints[3][0] = 0; qoints[3][1] = 0; qoints[3][2] = 1; +// for(size_t i = 0; i < NUMBER_OF_POINTS; ++i) +// { +// points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*M_PI); +// points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*M_PI); +// points[i][2] = 5.0*i/NUMBER_OF_POINTS-1.0; +// } + + double knots[3+NUMBER_OF_POINTS+1]; + knots[0] = 1; + for(size_t i = 1; i < 3+NUMBER_OF_POINTS; ++i) + { + knots[i] = (i+2)/3; // integer division is intentional + } + knots[3+NUMBER_OF_POINTS] = (3+NUMBER_OF_POINTS+1)/3; + + PRCTopoContext *tubeContext = new PRCTopoContext; + uint32_t context_index = file.addTopoContext(tubeContext); + + PRCBrepData *body = new PRCBrepData; + uint32_t body_index = tubeContext->addBrepData(body); + PRCConnex *connex = new PRCConnex; + body->addConnex(connex); + PRCShell *shell = new PRCShell; + connex->addShell(shell); + PRCFace *face = new PRCFace; + shell->addFace(face); + PRCBlend01 *surface = new PRCBlend01; + face->setSurface(surface); + + PRCNURBSCurve *center_curve = new PRCNURBSCurve; + center_curve->is_rational = false; + center_curve->degree = 3; + for(size_t i = 0; i < NUMBER_OF_POINTS; ++i) + center_curve->control_point.push_back(PRCControlPoint(points[i][0]+0.0,points[i][1],points[i][2])); + for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i) + center_curve->knot.push_back(knots[i]); + surface->setCenterCurve(center_curve); + + PRCNURBSCurve *origin_curve = new PRCNURBSCurve; + origin_curve->is_rational = false; + origin_curve->degree = 3; + for(size_t i = 0; i < NUMBER_OF_POINTS; ++i) + origin_curve->control_point.push_back(PRCControlPoint(points[i][0]*1.01+0.0,points[i][1]*1.01,points[i][2])); + for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i) + origin_curve->knot.push_back(knots[i]); + surface->setOriginCurve(origin_curve); + + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 2*M_PI; + surface->uv_domain.min.y = 1; // first knot + surface->uv_domain.max.y = 2; // last knot + PRCBrepModel *brepmodel = new PRCBrepModel("Tube"); + brepmodel->context_id = context_index; + brepmodel->body_id = body_index; + brepmodel->is_closed = true; // we do not need to see the tube from inside + brepmodel->index_of_line_style = 0; +// file.addBrepModel(brepmodel); + + PRCSingleWireBody *originCurveBody = new PRCSingleWireBody; + uint32_t origin_curve_body_index = tubeContext->addSingleWireBody(originCurveBody); + PRCWireEdge *originCurveEdge = new PRCWireEdge; + originCurveBody->setWireEdge(originCurveEdge); + originCurveEdge->curve_3d = surface->origin_curve; + PRCWire *originCurveWire = new PRCWire("originCurveWire"); + originCurveWire->index_of_line_style = 0; + originCurveWire->context_id = context_index; + originCurveWire->body_id = origin_curve_body_index; +// file.addWire(originCurveWire); + + PRCSingleWireBody *centerCurveBody = new PRCSingleWireBody; + uint32_t center_curve_body_index = tubeContext->addSingleWireBody(centerCurveBody); + PRCWireEdge *centerCurveEdge = new PRCWireEdge; + centerCurveBody->setWireEdge(centerCurveEdge); + centerCurveEdge->curve_3d = surface->center_curve; + PRCWire *centerCurveWire = new PRCWire("centerCurveWire"); + centerCurveWire->index_of_line_style = 0; + centerCurveWire->context_id = context_index; + centerCurveWire->body_id = center_curve_body_index; +// file.addWire(centerCurveWire); + + PRCNURBSCurve *Center_curve = new PRCNURBSCurve; + Center_curve->is_rational = false; + Center_curve->degree = 3; + for(size_t i = 0; i < NUMBER_OF_POINTS; ++i) + Center_curve->control_point.push_back(PRCControlPoint(qoints[i][0],qoints[i][1],qoints[i][2])); + for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i) + Center_curve->knot.push_back(knots[i]); + + PRCNURBSCurve *Origin_curve = new PRCNURBSCurve; + Origin_curve->is_rational = false; + Origin_curve->degree = 3; + for(size_t i = 0; i < NUMBER_OF_POINTS; ++i) + Origin_curve->control_point.push_back(PRCControlPoint(qoints[i][0],qoints[i][1]*1.01,qoints[i][2]*1.01)); + for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i) + Origin_curve->knot.push_back(knots[i]); + + PRCSingleWireBody *OriginCurveBody = new PRCSingleWireBody; + uint32_t Origin_curve_body_index = tubeContext->addSingleWireBody(OriginCurveBody); + PRCWireEdge *OriginCurveEdge = new PRCWireEdge; + OriginCurveBody->setWireEdge(OriginCurveEdge); + OriginCurveEdge->setCurve(Origin_curve); + PRCWire *OriginCurveWire = new PRCWire("OriginCurveWire"); + OriginCurveWire->index_of_line_style = 0; + OriginCurveWire->context_id = context_index; + OriginCurveWire->body_id = Origin_curve_body_index; +// file.addWire(OriginCurveWire); + + PRCSingleWireBody *CenterCurveBody = new PRCSingleWireBody; + uint32_t Center_curve_body_index = tubeContext->addSingleWireBody(CenterCurveBody); + PRCWireEdge *CenterCurveEdge = new PRCWireEdge; + CenterCurveBody->setWireEdge(CenterCurveEdge); + CenterCurveEdge->setCurve(Center_curve); + PRCWire *CenterCurveWire = new PRCWire("CenterCurveWire"); + CenterCurveWire->index_of_line_style = 0; + CenterCurveWire->context_id = context_index; + CenterCurveWire->body_id = Center_curve_body_index; +// file.addWire(CenterCurveWire); + + PRCComposite *compositeCenter_curve = new PRCComposite; + compositeCenter_curve->base_curve.push_back(centerCurveEdge->curve_3d); + compositeCenter_curve->base_sense.push_back(true); + compositeCenter_curve->base_curve.push_back(CenterCurveEdge->curve_3d); + compositeCenter_curve->base_sense.push_back(true); + compositeCenter_curve->is_closed = false; + compositeCenter_curve->interval.min = 0; + compositeCenter_curve->interval.max = 2; + + PRCSingleWireBody *compositeCenterCurveBody = new PRCSingleWireBody; + uint32_t compositeCenter_curve_body_index = tubeContext->addSingleWireBody(compositeCenterCurveBody); + PRCWireEdge *compositeCenterCurveEdge = new PRCWireEdge; + compositeCenterCurveBody->setWireEdge(compositeCenterCurveEdge); + compositeCenterCurveEdge->setCurve(compositeCenter_curve); + PRCWire *compositeCenterCurveWire = new PRCWire("compositeCenterCurveWire"); + compositeCenterCurveWire->index_of_line_style = 0; + compositeCenterCurveWire->context_id = context_index; + compositeCenterCurveWire->body_id = compositeCenter_curve_body_index; +// file.addWire(compositeCenterCurveWire); + + PRCComposite *compositeOrigin_curve = new PRCComposite; + compositeOrigin_curve->base_curve.push_back(originCurveEdge->curve_3d); + compositeOrigin_curve->base_sense.push_back(true); + compositeOrigin_curve->base_curve.push_back(OriginCurveEdge->curve_3d); + compositeOrigin_curve->base_sense.push_back(true); + compositeOrigin_curve->is_closed = false; + compositeOrigin_curve->interval.min = 0; + compositeOrigin_curve->interval.max = 2; - RGBAColour red(1.0,0.0,0.0); - PRCline pl(&file,NUMBER_OF_POINTS,points,red); - file.add(&pl); + PRCSingleWireBody *compositeOriginCurveBody = new PRCSingleWireBody; + uint32_t compositeOrigin_curve_body_index = tubeContext->addSingleWireBody(compositeOriginCurveBody); + PRCWireEdge *compositeOriginCurveEdge = new PRCWireEdge; + compositeOriginCurveBody->setWireEdge(compositeOriginCurveEdge); + compositeOriginCurveEdge->setCurve(compositeOrigin_curve); + PRCWire *compositeOriginCurveWire = new PRCWire("compositeOriginCurveWire"); + compositeOriginCurveWire->index_of_line_style = 0; + compositeOriginCurveWire->context_id = context_index; + compositeOriginCurveWire->body_id = compositeOrigin_curve_body_index; +// file.addWire(compositeOriginCurveWire); + + PRCBrepData *cbody = new PRCBrepData; + uint32_t cbody_index = tubeContext->addBrepData(cbody); + PRCConnex *cconnex = new PRCConnex; + cbody->addConnex(cconnex); + PRCShell *cshell = new PRCShell; + cconnex->addShell(cshell); + PRCFace *cface = new PRCFace; + cshell->addFace(cface); + PRCBlend01 *csurface = new PRCBlend01; + cface->setSurface(csurface); - file.finish(); + csurface->uv_domain.min.x = 0; + csurface->uv_domain.max.x = 2*M_PI; + csurface->uv_domain.min.y = 0; // first knot + csurface->uv_domain.max.y = 2; // last knot + csurface->center_curve = compositeCenterCurveEdge->curve_3d; + csurface->origin_curve = compositeOriginCurveEdge->curve_3d; + PRCBrepModel *cbrepmodel = new PRCBrepModel("cTube"); + cbrepmodel->context_id = context_index; + cbrepmodel->body_id = cbody_index; + cbrepmodel->is_closed = true; // we do not need to see the tube from inside + cbrepmodel->index_of_line_style = 0; +// file.addBrepModel(cbrepmodel); + + + } - for(int i = 0; i < NUMBER_OF_PATCHES; ++i) - delete psn[i]; + file.finish(); return 0; } diff --git a/Build/source/utils/asymptote/prc/writePRC.cc b/Build/source/utils/asymptote/prc/writePRC.cc index eb476dc7494..eb7141d3315 100644 --- a/Build/source/utils/asymptote/prc/writePRC.cc +++ b/Build/source/utils/asymptote/prc/writePRC.cc @@ -2,6 +2,7 @@ * * This file is part of a tool for producing 3D content in the PRC format. * Copyright (C) 2008 Orest Shardt <shardtor (at) gmail dot com> +* with enhancements contributed by Michail Vidiassov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -19,24 +20,43 @@ *************/ #include "writePRC.h" +#include <climits> +#include <cassert> + +// debug print includes +#include <iostream> +#include <iomanip> +#include <fstream> +#include <sstream> + +using namespace std; + +double PRCVector3d::Length() +{ + return sqrt(x*x+y*y+z*z); +} + +bool PRCVector3d::Normalize() +{ + double fLength=Length(); + if(fLength < FLT_EPSILON) return false; + double factor=1.0/fLength; + x *= factor; + y *= factor; + z *= factor; + return true; +} void UserData::write(PRCbitStream &pbs) { pbs << size; - if(size > 0) - { - uint32_t i = 0; - for(; i < size/8; ++i) - { + if(size > 0) { + uint32_t quot=size/8; + uint32_t rem=size-8*quot; + for(uint32_t i = 0; i < quot; ++i) pbs << data[i]; - } - if(size % 8 != 0) - { - for(uint32_t j = 0; j < size%8; ++j) // 0-based, big endian bit counting - { - pbs << (bool)(data[i] & (0x80 >> j)); - } - } + for(uint32_t j = 0; j < rem; ++j) // 0-based, big endian bit counting + pbs << (bool)(data[quot] & (0x80 >> j)); } } @@ -101,6 +121,226 @@ void ContentPRCBase::write(PRCbitStream &pbs) } } +#define WriteUnsignedInteger( value ) pbs << (uint32_t)(value); +#define WriteInteger( value ) pbs << (int32_t)(value); +#define WriteCharacter( value ) pbs << (uint8_t)(value); +#define WriteDouble( value ) pbs << (double)(value); +#define WriteBit( value ) pbs << (bool)(value); +#define WriteBoolean( value ) pbs << (bool)(value); +#define WriteString( value ) pbs << (value); +#define SerializeContentPRCBase write(pbs); +#define SerializeGraphics serializeGraphics(pbs); +#define SerializePRCBaseWithGraphics { write(pbs); serializeGraphics(pbs); } +#define SerializeRepresentationItemContent serializeRepresentationItemContent(pbs); +#define SerializeRepresentationItem( value ) (value)->serializeRepresentationItem(pbs); +#define SerializeMarkup( value ) (value).serializeMarkup(pbs); +#define SerializeReferenceUniqueIdentifier( value ) (value).serializeReferenceUniqueIdentifier(pbs); +#define SerializeContentBaseTessData serializeContentBaseTessData(pbs); +#define SerializeTessFace( value ) (value)->serializeTessFace(pbs); +#define SerializeUserData UserData(0,0).write(pbs); +#define SerializeLineAttr( value ) pbs << (uint32_t)((value)+1); +#define SerializeVector3d( value ) (value).serializeVector3d(pbs); +#define SerializeVector2d( value ) (value).serializeVector2d(pbs); +#define SerializeName( value ) writeName(pbs, (value)); +#define SerializeInterval( value ) (value).serializeInterval(pbs); +// #define SerializeBoundingBox( value ) (value).serializeBoundingBox(pbs); +#define SerializeDomain( value ) (value).serializeDomain(pbs); +#define SerializeParameterization serializeParameterization(pbs); +#define SerializeUVParameterization serializeUVParameterization(pbs); +#define SerializeTransformation serializeTransformation(pbs); +#define SerializeAttributeData if(attributes) attributes->write(pbs); else WriteUnsignedInteger (0) +#define SerializeBaseTopology serializeBaseTopology(pbs); +#define SerializeBaseGeometry serializeBaseGeometry(pbs); +#define SerializePtrCurve( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeCurve(pbs);} +#define SerializePtrSurface( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeSurface(pbs);} +#define SerializePtrTopology( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeTopoItem(pbs);} +#define SerializeContentCurve serializeContentCurve(pbs); +#define SerializeContentWireEdge serializeContentWireEdge(pbs); +#define SerializeContentBody serializeContentBody(pbs); +#define SerializeTopoContext serializeTopoContext(pbs); +#define SerializeContextAndBodies( value ) (value).serializeContextAndBodies(pbs); +#define SerializeBody( value ) (value)->serializeBody(pbs); +#define ResetCurrentGraphics resetGraphics(); +#define SerializeContentSurface serializeContentSurface(pbs); +#define SerializeCompressedUniqueId( value ) (value).serializeCompressedUniqueId(pbs); +#define SerializeUnit( value ) (value).serializeUnit(pbs); +#define SerializeBoundingBox serializeBoundingBox(pbs); + +bool IsCompressedType(uint32_t type) +{ + return (type == PRC_TYPE_TOPO_BrepDataCompress || type == PRC_TYPE_TOPO_SingleWireBodyCompress || type == PRC_TYPE_TESS_3D_Compressed); +} + +void PRCReferenceUniqueIdentifier::serializeReferenceUniqueIdentifier(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_MISC_ReferenceOnPRCBase) + WriteUnsignedInteger (type) + const bool reference_in_same_file_structure = true; + WriteBoolean (reference_in_same_file_structure) +// if (!reference_in_same_file_structure) +// SerializeCompressedUniqueId (target_file_structure) + WriteUnsignedInteger (unique_identifier) +} + +void PRCRgbColor::serializeRgbColor(PRCbitStream &pbs) +{ + WriteDouble (red) + WriteDouble (green) + WriteDouble (blue) +} + +void PRCPicture::serializePicture(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_GRAPH_Picture) + SerializeContentPRCBase + WriteInteger (format) //see Types for picture files + WriteUnsignedInteger (uncompressed_file_index+1) + WriteUnsignedInteger (pixel_width) + WriteUnsignedInteger (pixel_height) +} + +void PRCTextureDefinition::serializeTextureDefinition(PRCbitStream &pbs) +{ + uint32_t i=0; // universal index for PRC standart compatibility + const uint8_t texture_dimension = 2; + const uint32_t texture_mapping_attributes = texture_mapping_attribute; + const uint32_t size_texture_mapping_attributes_intensities = 1; + const double *texture_mapping_attributes_intensities = &texture_mapping_attribute_intensity; + const uint32_t size_texture_mapping_attributes_components = 1; + const uint8_t *texture_mapping_attributes_components = &texture_mapping_attribute_components; + const EPRCTextureMappingType eMappingType = KEPRCTextureMappingType_Stored; + + const double red = 1.0; + const double green = 1.0; + const double blue = 1.0; + const double alpha = 1.0; + const EPRCTextureBlendParameter blend_src_rgb = KEPRCTextureBlendParameter_Unknown; + const EPRCTextureBlendParameter blend_dst_rgb = KEPRCTextureBlendParameter_Unknown; + const EPRCTextureBlendParameter blend_src_alpha = KEPRCTextureBlendParameter_Unknown; + const EPRCTextureBlendParameter blend_dst_alpha = KEPRCTextureBlendParameter_Unknown; + const EPRCTextureAlphaTest alpha_test = KEPRCTextureAlphaTest_Unknown; + const double alpha_test_reference = 1.0; + const EPRCTextureWrappingMode texture_wrapping_mode_R = KEPRCTextureWrappingMode_ClampToBorder; + const bool texture_transformation = false; + + WriteUnsignedInteger (PRC_TYPE_GRAPH_TextureDefinition) + + SerializeContentPRCBase + + WriteUnsignedInteger (picture_index+1) + WriteCharacter (texture_dimension) + + // SerializeTextureMappingType + WriteInteger (eMappingType) // Texture mapping type + // if (eMappingType == TEXTURE_MAPPING_OPERATOR) + // { + // WriteInteger (eMappingOperator) // Texture mapping operator + // WriteInteger (transformation) + // if (transformation) + // SerializeCartesianTransformation3d (transformation) + // } + + WriteUnsignedInteger (texture_mapping_attributes) // Texture mapping attributes + WriteUnsignedInteger (size_texture_mapping_attributes_intensities) + for (i=0;i<size_texture_mapping_attributes_intensities;i++) + WriteDouble (texture_mapping_attributes_intensities[i]) + WriteUnsignedInteger (size_texture_mapping_attributes_components) + for (i=0;i<size_texture_mapping_attributes_components;i++) + WriteCharacter (texture_mapping_attributes_components[i]) + + WriteInteger (texture_function) + // reserved for future use; see Texture function + if (texture_function == KEPRCTextureFunction_Blend) + { + WriteDouble (red) // blend color component in the range [0.0,1.0] + WriteDouble (green) // blend color component in the range [0.0,1.0] + WriteDouble (blue) // blend color component in the range [0.0,1.0] + WriteDouble (alpha) // blend color component in the range [0.0,1.0] + } + + WriteInteger (blend_src_rgb) // Texture blend parameter + // reserved for future use; see Texture blend parameter + if (blend_src_rgb != KEPRCTextureBlendParameter_Unknown) + WriteInteger (blend_dst_rgb) // Texture blend parameter + + WriteInteger (blend_src_alpha) // Texture blend parameter + // reserved for future use; see Texture blend parameter + if (blend_src_alpha != KEPRCTextureBlendParameter_Unknown) + WriteInteger (blend_dst_alpha) // Texture blend parameter + + WriteCharacter (texture_applying_mode) // Texture applying mode + if (texture_applying_mode & PRC_TEXTURE_APPLYING_MODE_ALPHATEST) + { + WriteInteger (alpha_test) // Texture alpha test + WriteDouble (alpha_test_reference) + } + + WriteInteger (texture_wrapping_mode_S) // Texture wrapping mode + if (texture_dimension > 1) + WriteInteger (texture_wrapping_mode_T) // Texture wrapping mode + if (texture_dimension > 2 ) + WriteInteger (texture_wrapping_mode_R) // Texture wrapping mode + + WriteBit (texture_transformation) +// if (texture_transformation) +// SerializeTextureTransformation (texture_transformation) +} + +void PRCMaterialGeneric::serializeMaterialGeneric(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_GRAPH_Material) + SerializeContentPRCBase + WriteUnsignedInteger (ambient + 1) + WriteUnsignedInteger (diffuse + 1) + WriteUnsignedInteger (emissive + 1) + WriteUnsignedInteger (specular + 1) + WriteDouble (shininess) + WriteDouble (ambient_alpha) + WriteDouble (diffuse_alpha) + WriteDouble (emissive_alpha) + WriteDouble (specular_alpha) +} + +void PRCTextureApplication::serializeTextureApplication(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_GRAPH_TextureApplication) + SerializeContentPRCBase + + WriteUnsignedInteger (material_generic_index+1) + WriteUnsignedInteger (texture_definition_index+1) + WriteUnsignedInteger (next_texture_index+1) + WriteUnsignedInteger (UV_coordinates_index+1) +} + +void PRCStyle::serializeCategory1LineStyle(PRCbitStream &pbs) +{ + const bool is_additional_1_defined = (additional!=0); + const uint8_t additional_1 = additional; + const bool is_additional_2_defined = false; + const uint8_t additional_2 = 0; + const bool is_additional_3_defined = false; + const uint8_t additional_3 = 0; + WriteUnsignedInteger (PRC_TYPE_GRAPH_Style) + SerializeContentPRCBase + WriteDouble (line_width) + WriteBoolean (is_vpicture) + WriteUnsignedInteger (line_pattern_vpicture_index + 1) + WriteBoolean (is_material) + WriteUnsignedInteger (color_material_index + 1) + WriteBoolean (is_transparency_defined) + if (is_transparency_defined) + WriteCharacter (transparency) + WriteBoolean (is_additional_1_defined) + if (is_additional_1_defined) + WriteCharacter (additional_1) + WriteBoolean (is_additional_2_defined) + if (is_additional_2_defined) + WriteCharacter (additional_2) + WriteBoolean (is_additional_3_defined) + if (is_additional_3_defined) + WriteCharacter (additional_3) +} + AttributeTitle EMPTY_ATTRIBUTE_TITLE = {(char*)""}; Attribute EMPTY_ATTRIBUTE(false,EMPTY_ATTRIBUTE_TITLE,0,NULL); Attributes EMPTY_ATTRIBUTES(0,0); @@ -122,29 +362,75 @@ void resetName() currentName = ""; } -uint32_t layer_index = m1; -uint32_t index_of_line_style = m1; -uint32_t behaviour_bit_field = 1; +uint32_t current_layer_index = m1; +uint32_t current_index_of_line_style = m1; +uint16_t current_behaviour_bit_field = 1; void writeGraphics(PRCbitStream &pbs,uint32_t l,uint32_t i,uint32_t b,bool force) { - if(force || layer_index != l || index_of_line_style != i || behaviour_bit_field != b) + if(force || current_layer_index != l || current_index_of_line_style != i || current_behaviour_bit_field != b) { pbs << false << (uint32_t)(l+1) << (uint32_t)(i+1) << (uint8_t)(b&0xFF) << (uint8_t)((b>>8)&0xFF); - layer_index = l; - index_of_line_style = i; - behaviour_bit_field = b; + current_layer_index = l; + current_index_of_line_style = i; + current_behaviour_bit_field = b; } else pbs << true; } +void writeGraphics(PRCbitStream &pbs,const PRCGraphics &graphics,bool force) +{ + if(force || current_layer_index != graphics.layer_index || current_index_of_line_style != graphics.index_of_line_style || current_behaviour_bit_field != graphics.behaviour_bit_field) + { + pbs << false + << (uint32_t)(graphics.layer_index+1) + << (uint32_t)(graphics.index_of_line_style+1) + << (uint8_t)(graphics.behaviour_bit_field&0xFF) + << (uint8_t)((graphics.behaviour_bit_field>>8)&0xFF); + current_layer_index = graphics.layer_index; + current_index_of_line_style = graphics.index_of_line_style; + current_behaviour_bit_field = graphics.behaviour_bit_field; + } + else + pbs << true; +} + +void PRCGraphics::serializeGraphics(PRCbitStream &pbs) +{ + if(current_layer_index != this->layer_index || current_index_of_line_style != this->index_of_line_style || current_behaviour_bit_field != this->behaviour_bit_field) + { + pbs << false + << (uint32_t)(this->layer_index+1) + << (uint32_t)(this->index_of_line_style+1) + << (uint8_t)(this->behaviour_bit_field&0xFF) + << (uint8_t)((this->behaviour_bit_field>>8)&0xFF); + current_layer_index = this->layer_index; + current_index_of_line_style = this->index_of_line_style; + current_behaviour_bit_field = this->behaviour_bit_field; + } + else + pbs << true; +} + +void PRCGraphics::serializeGraphicsForced(PRCbitStream &pbs) +{ + pbs << false + << (uint32_t)(this->layer_index+1) + << (uint32_t)(this->index_of_line_style+1) + << (uint8_t)(this->behaviour_bit_field&0xFF) + << (uint8_t)((this->behaviour_bit_field>>8)&0xFF); + current_layer_index = this->layer_index; + current_index_of_line_style = this->index_of_line_style; + current_behaviour_bit_field = this->behaviour_bit_field; +} + void resetGraphics() { - layer_index = m1; - index_of_line_style = m1; - behaviour_bit_field = 1; + current_layer_index = m1; + current_index_of_line_style = m1; + current_behaviour_bit_field = 1; } void resetGraphicsAndName() @@ -152,6 +438,480 @@ void resetGraphicsAndName() resetGraphics(); resetName(); } +void PRCMarkup::serializeMarkup(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_MKP_Markup) + SerializeContentPRCBase + SerializeGraphics + WriteUnsignedInteger (type) + WriteUnsignedInteger (sub_type) + const uint32_t number_of_linked_items = 0; + WriteUnsignedInteger (number_of_linked_items) +// for (i=0;i<number_of_linked_items;i++) +// SerializeReferenceUniqueIdentifier (linked_items[i]) + const uint32_t number_of_leaders = 0; + WriteUnsignedInteger (number_of_leaders) +// for (i=0;i<number_of_leaders;i++) +// SerializeReferenceUniqueIdentifier (leaders[i]) + WriteUnsignedInteger (index_tessellation + 1) + SerializeUserData +} + +void PRCAnnotationItem::serializeAnnotationItem(PRCbitStream &pbs) +{ +// group___tf_annotation_item_____serialize2.html +// group___tf_annotation_item_____serialize_content2.html +// group___tf_annotation_entity_____serialize_content2.html + WriteUnsignedInteger (PRC_TYPE_MKP_AnnotationItem) + SerializeContentPRCBase + SerializeGraphics + SerializeReferenceUniqueIdentifier (markup) + SerializeUserData +} + +void PRCRepresentationItemContent::serializeRepresentationItemContent(PRCbitStream &pbs) +{ + SerializeContentPRCBase + SerializeGraphics + WriteUnsignedInteger (index_local_coordinate_system + 1) + WriteUnsignedInteger (index_tessellation + 1) +} + +void PRCBrepModel::serializeBrepModel(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_RI_BrepModel) + + SerializeRepresentationItemContent + WriteBit (has_brep_data) + if (has_brep_data) + { + WriteUnsignedInteger (context_id+1) + WriteUnsignedInteger (body_id+1) + } + WriteBoolean (is_closed) + SerializeUserData +} + +void PRCPolyBrepModel::serializePolyBrepModel(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_RI_PolyBrepModel) + + SerializeRepresentationItemContent + WriteBoolean (is_closed) + SerializeUserData +} + +void PRCPointSet::serializePointSet(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_RI_PointSet) + + SerializeRepresentationItemContent + + const uint32_t number_of_points = point.size(); + WriteUnsignedInteger (number_of_points) + for (uint32_t i=0;i<number_of_points;i++) + { + SerializeVector3d (point[i]) + } + SerializeUserData +} + +void PRCSet::serializeSet(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_RI_Set) + + SerializeRepresentationItemContent + + const uint32_t number_of_elements = elements.size(); + WriteUnsignedInteger (number_of_elements) + for (uint32_t i=0;i<number_of_elements;i++) + { + SerializeRepresentationItem (elements[i]) + } + SerializeUserData +} + +uint32_t PRCSet::addBrepModel(PRCBrepModel *pBrepModel) +{ + elements.push_back(PRCpRepresentationItem(pBrepModel)); + return elements.size()-1; +} + +uint32_t PRCSet::addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel) +{ + elements.push_back(PRCpRepresentationItem(pPolyBrepModel)); + return elements.size()-1; +} + +uint32_t PRCSet::addPointSet(PRCPointSet *pPointSet) +{ + elements.push_back(PRCpRepresentationItem(pPointSet)); + return elements.size()-1; +} + +uint32_t PRCSet::addSet(PRCSet *pSet) +{ + elements.push_back(PRCpRepresentationItem(pSet)); + return elements.size()-1; +} + +uint32_t PRCSet::addWire(PRCWire *pWire) +{ + elements.push_back(PRCpRepresentationItem(pWire)); + return elements.size()-1; +} + +uint32_t PRCSet::addPolyWire(PRCPolyWire *pPolyWire) +{ + elements.push_back(PRCpRepresentationItem(pPolyWire)); + return elements.size()-1; +} + +uint32_t PRCSet::addRepresentationItem(PRCRepresentationItem *pRepresentationItem) +{ + elements.push_back(PRCpRepresentationItem(pRepresentationItem)); + return elements.size()-1; +} + +uint32_t PRCSet::addRepresentationItem(PRCpRepresentationItem pRepresentationItem) +{ + elements.push_back(pRepresentationItem); + return elements.size()-1; +} + +void PRCWire::serializeWire(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_RI_Curve) + + SerializeRepresentationItemContent + WriteBit (has_wire_body) + if (has_wire_body) + { + WriteUnsignedInteger (context_id+1) + WriteUnsignedInteger (body_id+1) + } + + SerializeUserData +} + +void PRCPolyWire::serializePolyWire(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_RI_PolyWire) + + SerializeRepresentationItemContent + SerializeUserData +} + +void PRCGeneralTransformation3d::serializeGeneralTransformation3d(PRCbitStream &pbs) const +{ + WriteUnsignedInteger (PRC_TYPE_MISC_GeneralTransformation) + for (int j=0;j<4;j++) + for (int i=0;i<4;i++) + WriteDouble(mat[i][j]); +} + +void PRCCartesianTransformation3d::serializeCartesianTransformation3d(PRCbitStream &pbs) const +{ + WriteUnsignedInteger (PRC_TYPE_MISC_CartesianTransformation) + WriteCharacter ( behaviour ) + if (behaviour & PRC_TRANSFORMATION_Translate) + SerializeVector3d ( origin ) + if (behaviour & PRC_TRANSFORMATION_NonOrtho) + { + SerializeVector3d ( X ) + SerializeVector3d ( Y ) + SerializeVector3d ( Z ) + } + else if (behaviour & PRC_TRANSFORMATION_Rotate) + { + SerializeVector3d ( X ) + SerializeVector3d ( Y ) + } + + if (behaviour & PRC_TRANSFORMATION_NonUniformScale) + { + SerializeVector3d ( scale ) + } + else if (behaviour & PRC_TRANSFORMATION_Scale) + { + WriteDouble ( uniform_scale ) + } + + if (behaviour & PRC_TRANSFORMATION_Homogeneous) + { + WriteDouble ( X_homogeneous_coord ) + WriteDouble ( Y_homogeneous_coord ) + WriteDouble ( Z_homogeneous_coord ) + WriteDouble ( origin_homogeneous_coord ) + } +} + +void PRCTransformation::serializeTransformation(PRCbitStream &pbs) +{ + WriteBit ( has_transformation ) + if (has_transformation) + { + WriteCharacter ( behaviour ) + if ( geometry_is_2D ) + { + if (behaviour & PRC_TRANSFORMATION_Translate) + SerializeVector2d ( origin ) + if (behaviour & PRC_TRANSFORMATION_Rotate) + { + SerializeVector2d ( x_axis ) + SerializeVector2d ( y_axis ) + } + if (behaviour & PRC_TRANSFORMATION_Scale) + WriteDouble ( scale ) + } + else + { + if (behaviour & PRC_TRANSFORMATION_Translate) + SerializeVector3d ( origin ) + if (behaviour & PRC_TRANSFORMATION_Rotate) + { + SerializeVector3d ( x_axis ) + SerializeVector3d ( y_axis ) + } + if (behaviour & PRC_TRANSFORMATION_Scale) + WriteDouble ( scale ) + } + } +} +void PRCCoordinateSystem::serializeCoordinateSystem(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_RI_CoordinateSystem) + + SerializeRepresentationItemContent + axis_set->serializeTransformation3d(pbs); + SerializeUserData +} + +void PRCFontKeysSameFont::serializeFontKeysSameFont(PRCbitStream &pbs) +{ + uint32_t i=0; // universal index for PRC standart compatibility + WriteString (font_name) + WriteUnsignedInteger (char_set) + const uint32_t number_of_font_keys = font_keys.size(); + WriteUnsignedInteger (number_of_font_keys) + for (i=0;i<number_of_font_keys;i++) + { + WriteUnsignedInteger (font_keys[i].font_size + 1) + WriteCharacter (font_keys[i].attributes) + } +} + +void SerializeArrayRGBA (const std::vector<uint8_t> &rgba_vertices,const bool is_rgba, PRCbitStream &pbs) +{ + uint32_t i = 0; + uint32_t j = 0; +// number_by_vector can be assigned a value of 3 (RGB) or 4 (RGBA). +// number_of_vectors is equal to number_of_colors / number_by_vector. + const uint32_t number_by_vector=is_rgba?4:3; + const std::vector<uint8_t> &vector_color = rgba_vertices; + const uint32_t number_of_colors=vector_color.size(); + const uint32_t number_of_vectors=number_of_colors / number_by_vector; + // first one + for (i=0;i<number_by_vector;i++) + WriteCharacter (vector_color[i]) + + for (i=1;i<number_of_vectors;i++) + { + bool b_same = true; + for (j=0;j<number_by_vector;j++) + { + if ((vector_color[i*number_by_vector+j] - vector_color[(i-1)*number_by_vector+j]) != 0) + { + b_same = false; + break; + } + } + WriteBoolean (b_same) + if (!b_same) + { + for (j=0;j<number_by_vector;j++) + WriteCharacter (vector_color[i*number_by_vector+j]) + } + } +} + +void PRCTessFace::serializeTessFace(PRCbitStream &pbs) +{ + uint32_t i=0; // universal index for PRC standart compatibility + WriteUnsignedInteger (PRC_TYPE_TESS_Face) + + const uint32_t size_of_line_attributes=line_attributes.size(); + WriteUnsignedInteger (size_of_line_attributes) + for (i=0;i<size_of_line_attributes;i++) + SerializeLineAttr (line_attributes[i]) + + WriteUnsignedInteger (start_wire) + const uint32_t size_of_sizes_wire=sizes_wire.size(); + WriteUnsignedInteger (size_of_sizes_wire) + for (i=0;i<size_of_sizes_wire;i++) + WriteUnsignedInteger (sizes_wire[i]) + + WriteUnsignedInteger (used_entities_flag) + + WriteUnsignedInteger (start_triangulated) + const uint32_t size_of_sizes_triangulated=sizes_triangulated.size(); + WriteUnsignedInteger (size_of_sizes_triangulated) + for (i=0;i<size_of_sizes_triangulated;i++) + WriteUnsignedInteger (sizes_triangulated[i]) + + if(number_of_texture_coordinate_indexes==0 && + used_entities_flag & + ( + PRC_FACETESSDATA_PolyfaceTextured| + PRC_FACETESSDATA_TriangleTextured| + PRC_FACETESSDATA_TriangleFanTextured| + PRC_FACETESSDATA_TriangleStripeTextured| + PRC_FACETESSDATA_PolyfaceOneNormalTextured| + PRC_FACETESSDATA_TriangleOneNormalTextured| + PRC_FACETESSDATA_TriangleFanOneNormalTextured| + PRC_FACETESSDATA_TriangleStripeOneNormalTextured + )) + WriteUnsignedInteger (1) // workaround for error of not setting number_of_texture_coordinate_indexes + else + WriteUnsignedInteger (number_of_texture_coordinate_indexes) + + const bool has_vertex_colors = !rgba_vertices.empty(); + WriteBoolean (has_vertex_colors) + if (has_vertex_colors) + { + WriteBoolean (is_rgba) + const bool b_optimised=false; + WriteBoolean (b_optimised) + if (!b_optimised) + { + SerializeArrayRGBA (rgba_vertices, is_rgba, pbs); + } + else + { + // not described + } + } + if (size_of_line_attributes) + WriteUnsignedInteger (behaviour) +} + +void PRCContentBaseTessData::serializeContentBaseTessData(PRCbitStream &pbs) +{ + uint32_t i=0; // universal index for PRC standart compatibility + WriteBoolean (is_calculated) + const uint32_t number_of_coordinates = coordinates.size(); + WriteUnsignedInteger (number_of_coordinates) + for (i=0;i<number_of_coordinates;i++) + WriteDouble (coordinates[i]) +} + +void PRC3DTess::serialize3DTess(PRCbitStream &pbs) +{ + uint32_t i=0; // universal index for PRC standart compatibility + WriteUnsignedInteger (PRC_TYPE_TESS_3D) + SerializeContentBaseTessData + WriteBoolean (has_faces) + WriteBoolean (has_loops) + const bool must_recalculate_normals=normal_coordinate.empty(); + WriteBoolean (must_recalculate_normals) + if (must_recalculate_normals) + { + const uint8_t normals_recalculation_flags=0; + // not used; should be zero + WriteCharacter (normals_recalculation_flags) + // definition similar to VRML + WriteDouble (crease_angle) + } + + const uint32_t number_of_normal_coordinates=normal_coordinate.size(); + WriteUnsignedInteger (number_of_normal_coordinates) + for (i=0;i<number_of_normal_coordinates;i++) + WriteDouble (normal_coordinate[i]) + + const uint32_t number_of_wire_indices=wire_index.size(); + WriteUnsignedInteger (number_of_wire_indices) + for (i=0;i<number_of_wire_indices;i++) + WriteUnsignedInteger (wire_index[i]) + + // note : those can be single triangles, triangle fans or stripes + const uint32_t number_of_triangulated_indices=triangulated_index.size(); + WriteUnsignedInteger (number_of_triangulated_indices) + for (i=0;i<number_of_triangulated_indices;i++) + WriteUnsignedInteger (triangulated_index[i]) + + const uint32_t number_of_face_tessellation=face_tessellation.size(); + WriteUnsignedInteger (number_of_face_tessellation) + for (i=0;i<number_of_face_tessellation;i++) + SerializeTessFace (face_tessellation[i]) + + const uint32_t number_of_texture_coordinates=texture_coordinate.size(); + WriteUnsignedInteger (number_of_texture_coordinates) + for (i=0;i<number_of_texture_coordinates;i++) + WriteDouble (texture_coordinate[i]) +} + +void PRC3DTess::addTessFace(PRCTessFace *pTessFace) +{ + face_tessellation.push_back(PRCpTessFace(pTessFace)); +} + +void PRC3DWireTess::serialize3DWireTess(PRCbitStream &pbs) +{ +// group___tf3_d_wire_tess_data_____serialize2.html +// group___tf3_d_wire_tess_data_____serialize_content2.html + uint32_t i=0; // universal index for PRC standart compatibility + WriteUnsignedInteger (PRC_TYPE_TESS_3D_Wire) + SerializeContentBaseTessData + const uint32_t number_of_wire_indexes=wire_indexes.size(); + WriteUnsignedInteger (number_of_wire_indexes) + for (i=0;i<number_of_wire_indexes;i++) + WriteUnsignedInteger (wire_indexes[i]) + + const bool has_vertex_colors = !rgba_vertices.empty(); + WriteBoolean (has_vertex_colors) + if (has_vertex_colors) + { + WriteBoolean (is_rgba) + WriteBoolean (is_segment_color) + const bool b_optimised=false; + WriteBoolean (b_optimised) + if (!b_optimised) + { + SerializeArrayRGBA (rgba_vertices, is_rgba, pbs); + } + else + { + // not described + } + } +} + +void PRCMarkupTess::serializeMarkupTess(PRCbitStream &pbs) +{ +// group___tf_markup_tess_data_____serialize2.html +// group___tf_markup_tess_data_____serialize_content2.html + uint32_t i=0; // universal index for PRC standart compatibility + WriteUnsignedInteger (PRC_TYPE_TESS_Markup) + SerializeContentBaseTessData + + const uint32_t number_of_codes=codes.size(); + WriteUnsignedInteger (number_of_codes) + for (i=0;i<number_of_codes;i++) + WriteUnsignedInteger (codes[i]) + const uint32_t number_of_texts=texts.size(); + WriteUnsignedInteger (number_of_texts) + for (i=0;i<number_of_texts;i++) + WriteString (texts[i]) + WriteString (label) // label of tessellation + WriteCharacter (behaviour) +} + +void PRCVector2d::serializeVector2d(PRCbitStream &pbs) +{ + WriteDouble (x) + WriteDouble (y) +} + uint32_t makeCADID() { static uint32_t ID = 1; @@ -176,3 +936,982 @@ void writeEmptyMarkups(PRCbitStream &out) << (uint32_t)0 // # of markups << (uint32_t)0; // # of annotation entities } + +void PRCBaseTopology::serializeBaseTopology(PRCbitStream &pbs) +{ + WriteBoolean (base_information) + if (base_information) + { + SerializeAttributeData + SerializeName (name) + WriteUnsignedInteger (identifier) + } +} + +void PRCBaseGeometry::serializeBaseGeometry(PRCbitStream &pbs) +{ + WriteBoolean (base_information) + if (base_information) + { + SerializeAttributeData + SerializeName (name) + WriteUnsignedInteger (identifier) + } +} + +void PRCContentBody::serializeContentBody(PRCbitStream &pbs) +{ + SerializeBaseTopology + WriteCharacter ( behavior ) +} + +void PRCBoundingBox::serializeBoundingBox(PRCbitStream &pbs) +{ + SerializeVector3d ( min ) + SerializeVector3d ( max ) +} + +void PRCDomain::serializeDomain(PRCbitStream &pbs) +{ + SerializeVector2d ( min ) + SerializeVector2d ( max ) +} + +void PRCInterval::serializeInterval(PRCbitStream &pbs) +{ + WriteDouble ( min ) + WriteDouble ( max ) +} + +void PRCParameterization::serializeParameterization(PRCbitStream &pbs) +{ + SerializeInterval ( interval ) + WriteDouble ( parameterization_coeff_a ) + WriteDouble ( parameterization_coeff_b ) +} + +void PRCUVParameterization::serializeUVParameterization(PRCbitStream &pbs) +{ + WriteBoolean ( swap_uv ) + SerializeDomain ( uv_domain ) + WriteDouble ( parameterization_on_u_coeff_a ) + WriteDouble ( parameterization_on_v_coeff_a ) + WriteDouble ( parameterization_on_u_coeff_b ) + WriteDouble ( parameterization_on_v_coeff_b ) +} + +void PRCContentSurface::serializeContentSurface(PRCbitStream &pbs) +{ + SerializeBaseGeometry + WriteUnsignedInteger ( extend_info ) +} + +void PRCNURBSSurface::serializeNURBSSurface(PRCbitStream &pbs) +{ + uint32_t i=0; +// uint32_t i=0, j=0; + WriteUnsignedInteger (PRC_TYPE_SURF_NURBS) + + SerializeContentSurface + WriteBoolean ( is_rational ) + WriteUnsignedInteger ( degree_in_u ) + WriteUnsignedInteger ( degree_in_v ) + const uint32_t highest_index_of_knots_in_u = knot_u.size()-1; + const uint32_t highest_index_of_knots_in_v = knot_v.size()-1; + const uint32_t highest_index_of_control_point_in_u = highest_index_of_knots_in_u - degree_in_u - 1; + const uint32_t highest_index_of_control_point_in_v = highest_index_of_knots_in_v - degree_in_v - 1; + WriteUnsignedInteger ( highest_index_of_control_point_in_u ) + WriteUnsignedInteger ( highest_index_of_control_point_in_v ) + WriteUnsignedInteger ( highest_index_of_knots_in_u ) + WriteUnsignedInteger ( highest_index_of_knots_in_v ) + for (i=0; i < (highest_index_of_control_point_in_u+1)*(highest_index_of_control_point_in_v+1); i++) + { + WriteDouble ( control_point[i].x ) + WriteDouble ( control_point[i].y ) + WriteDouble ( control_point[i].z ) + if (is_rational) + WriteDouble ( control_point[i].w ) + } +// for (i=0; i<=highest_index_of_control_point_in_u; i++) +// { +// for (j=0; j<=highest_index_of_control_point_in_v; j++) +// { +// WriteDouble ( control_point[i*(highest_index_of_control_point_in_u+1)+j].x ) +// WriteDouble ( control_point[i*(highest_index_of_control_point_in_u+1)+j].y ) +// WriteDouble ( control_point[i*(highest_index_of_control_point_in_u+1)+j].z ) +// if (is_rational) +// WriteDouble ( control_point[i*(highest_index_of_control_point_in_u+1)+j].w ) +// } +// } + for (i=0; i<=highest_index_of_knots_in_u; i++) + WriteDouble ( knot_u[i] ) + for (i=0; i<=highest_index_of_knots_in_v; i++) + WriteDouble ( knot_v[i] ) + WriteUnsignedInteger ( knot_type ) + WriteUnsignedInteger ( surface_form ) +} + +void writeUnsignedIntegerWithVariableBitNumber(PRCbitStream &pbs, uint32_t value, uint32_t bit_number) +{ + uint32_t i; + for(i=0; i<bit_number; i++) + { + if( value >= 1u<<(bit_number - 1 - i) ) + { + WriteBoolean (true) + + value -= 1u<<(bit_number - 1 - i); + } + else + { + WriteBoolean (false) + } + } +} +#define WriteUnsignedIntegerWithVariableBitNumber( value, bit_number ) writeUnsignedIntegerWithVariableBitNumber( pbs, (value), (bit_number) ); + +void writeIntegerWithVariableBitNumber(PRCbitStream &pbs, int32_t iValue, uint32_t uBitNumber) +{ + WriteBoolean(iValue<0); + WriteUnsignedIntegerWithVariableBitNumber(abs(iValue), uBitNumber - 1); +} +#define WriteIntegerWithVariableBitNumber( value, bit_number ) writeIntegerWithVariableBitNumber( pbs, (value), (bit_number) ); + +void writeDoubleWithVariableBitNumber(PRCbitStream &pbs, double dValue,double dTolerance, unsigned uBitNumber) +{ +// calling functions must ensure no overflow + int32_t iTempValue = (int32_t) ( dValue / dTolerance ); + WriteIntegerWithVariableBitNumber(iTempValue, uBitNumber); +} +#define WriteDoubleWithVariableBitNumber( value, bit_number ) writeDoubleWithVariableBitNumber( pbs, (value), (bit_number) ); + +uint32_t GetNumberOfBitsUsedToStoreUnsignedInteger(uint32_t uValue) +{ + uint32_t uNbBit=2; + uint32_t uTemp = 2; + while(uValue >= uTemp) + { + uTemp*=2; + uNbBit++; + } + return uNbBit-1; +} + +void writeNumberOfBitsThenUnsignedInteger(PRCbitStream &pbs, uint32_t unsigned_integer) +{ + uint32_t number_of_bits = GetNumberOfBitsUsedToStoreUnsignedInteger( unsigned_integer ); + WriteUnsignedIntegerWithVariableBitNumber ( number_of_bits, 5 ) + WriteUnsignedIntegerWithVariableBitNumber ( unsigned_integer, number_of_bits ) +} +#define WriteNumberOfBitsThenUnsignedInteger( value ) writeNumberOfBitsThenUnsignedInteger( pbs, value ); + +uint32_t GetNumberOfBitsUsedToStoreInteger(int32_t iValue) +{ + return GetNumberOfBitsUsedToStoreUnsignedInteger(abs(iValue))+1; +} + +int32_t intdiv(double dValue, double dTolerance) +{ + double ratio=fabs(dValue)/dTolerance; + assert(ratio <= INT_MAX); + int32_t iTempValue=(int32_t) ratio; + if(ratio - iTempValue >= 0.5) iTempValue++; + if(dValue < 0) + return -iTempValue; + else + return iTempValue; +} + +// round dValue to nearest multiple of dTolerance +double roundto(double dValue, double dTolerance) +{ + return intdiv(dValue, dTolerance) * dTolerance; +} + +PRCVector3d roundto(PRCVector3d vec, double dTolerance) +{ + PRCVector3d res; + res.x = roundto(vec.x,dTolerance); + res.y = roundto(vec.y,dTolerance); + res.z = roundto(vec.z,dTolerance); + return res; +} + +uint32_t GetNumberOfBitsUsedToStoreDouble(double dValue, double dTolerance ) +{ + return GetNumberOfBitsUsedToStoreInteger(intdiv(dValue,dTolerance)); +} + +struct itriple +{ + int32_t x; + int32_t y; + int32_t z; +}; + +uint32_t GetNumberOfBitsUsedToStoreTripleInteger(const itriple &iTriple) +{ + const uint32_t x_bits = GetNumberOfBitsUsedToStoreInteger(iTriple.x); + const uint32_t y_bits = GetNumberOfBitsUsedToStoreInteger(iTriple.y); + const uint32_t z_bits = GetNumberOfBitsUsedToStoreInteger(iTriple.z); + uint32_t bits = x_bits; + if(y_bits > bits) + bits = y_bits; + if(z_bits > bits) + bits = z_bits; + return bits; +} + +itriple iroundto(PRCVector3d vec, double dTolerance) +{ + itriple res; + res.x = intdiv(vec.x, dTolerance); + res.y = intdiv(vec.y, dTolerance); + res.z = intdiv(vec.z, dTolerance); + return res; +} + +void PRCCompressedFace::serializeCompressedFace(PRCbitStream &pbs, double brep_data_compressed_tolerance) +{ + serializeCompressedAnaNurbs( pbs, brep_data_compressed_tolerance ); +} +#define SerializeCompressedFace( value ) (value)->serializeCompressedFace( pbs, brep_data_compressed_tolerance ); + +void PRCCompressedFace::serializeContentCompressedFace(PRCbitStream &pbs) +{ + WriteBoolean ( orientation_surface_with_shell ) + const bool surface_is_trimmed = false; + WriteBoolean ( surface_is_trimmed ) +} + +void PRCCompressedFace::serializeCompressedAnaNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance) +{ + // WriteCompressedEntityType ( PRC_HCG_AnaNurbs ) + const bool is_a_curve = false; + WriteBoolean ( is_a_curve ) + WriteUnsignedIntegerWithVariableBitNumber (13 , 4) + serializeContentCompressedFace( pbs ); + serializeCompressedNurbs( pbs, brep_data_compressed_tolerance ); +} + +void PRCCompressedFace::serializeCompressedNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance) +{ + const double nurbs_tolerance = 0.2*brep_data_compressed_tolerance; + const uint32_t degree_in_u = degree; + const uint32_t degree_in_v = degree; + + WriteUnsignedIntegerWithVariableBitNumber ( degree_in_u, 5) + WriteUnsignedIntegerWithVariableBitNumber ( degree_in_v, 5) + + const uint32_t number_of_knots_in_u = 4; // 0011 or 00001111 knot vector - just 2 spans + WriteUnsignedIntegerWithVariableBitNumber (number_of_knots_in_u - 2, 16) + uint32_t number_bit = degree_in_u ? ceil( log2( degree_in_u + 2 ) ) : 2; + WriteBoolean (false) // Multiplicity_is_already_stored - no + WriteUnsignedIntegerWithVariableBitNumber( degree_in_u+1,number_bit) + WriteBoolean (true) // Multiplicity_is_already_stored - yes + const uint32_t number_of_knots_in_v = 4; // 0011 or 00001111 knot vector - just 2 spans + WriteUnsignedIntegerWithVariableBitNumber (number_of_knots_in_v - 2, 16) + number_bit = degree_in_v ? ceil( log2( degree_in_v + 2 ) ) : 2; + WriteBoolean (false) // Multiplicity_is_already_stored - no + WriteUnsignedIntegerWithVariableBitNumber( degree_in_v+1,number_bit) + WriteBoolean (true) // Multiplicity_is_already_stored - yes + + const bool is_closed_u = false; + WriteBoolean ( is_closed_u ) + const bool is_closed_v = false; + WriteBoolean ( is_closed_v ) + + const uint32_t number_of_control_point_in_u = degree_in_u + 1; + const uint32_t number_of_control_point_in_v = degree_in_v + 1; + PRCVector3d P[number_of_control_point_in_u][number_of_control_point_in_v]; + for(uint32_t i=0;i<number_of_control_point_in_u;i++) + for(uint32_t j=0;j<number_of_control_point_in_v;j++) + P[i][j] = control_point[i*number_of_control_point_in_v+j]; + itriple compressed_control_point[number_of_control_point_in_u][number_of_control_point_in_v]; + uint32_t control_point_type[number_of_control_point_in_u][number_of_control_point_in_v]; + + uint32_t number_of_bits_for_isomin = 1; + uint32_t number_of_bits_for_rest = 1; + + for(uint32_t j = 1; j < number_of_control_point_in_v; j++) + { + compressed_control_point[0][j] = iroundto(P[0][j]-P[0][j-1], nurbs_tolerance ); + P[0][j] = P[0][j-1] + roundto(P[0][j]-P[0][j-1], nurbs_tolerance); + uint32_t bit_size = GetNumberOfBitsUsedToStoreTripleInteger(compressed_control_point[0][j]); + if (bit_size > number_of_bits_for_isomin) + number_of_bits_for_isomin = bit_size; + } + + for(uint32_t i = 1; i < number_of_control_point_in_u; i++) + { + compressed_control_point[i][0] = iroundto(P[i][0]-P[i-1][0], nurbs_tolerance ); + P[i][0] = P[i-1][0] + roundto(P[i][0]-P[i-1][0], nurbs_tolerance); + uint32_t bit_size = GetNumberOfBitsUsedToStoreTripleInteger(compressed_control_point[i][0]); + if (bit_size > number_of_bits_for_isomin) + number_of_bits_for_isomin = bit_size; + } + + for(uint32_t i=1;i<number_of_control_point_in_u;i++) + for(uint32_t j=1;j<number_of_control_point_in_v;j++) + { + compressed_control_point[i][j].x = 0; + compressed_control_point[i][j].y = 0; + compressed_control_point[i][j].z = 0; + + PRCVector3d V = P[i-1][j] - P[i-1][j-1]; + PRCVector3d U = P[i][j-1] - P[i-1][j-1]; + PRCVector3d Pc = P[i][j] - (P[i-1][j-1] + U + V); + + if(Pc.Length() < nurbs_tolerance) + { + control_point_type[i][j] = 0; + P[i][j] = P[i-1][j-1] + U + V; + } + else + { + PRCVector3d N = U*V; + PRCVector3d Ue = U; + PRCVector3d Ne = N; + if( V.Length() < FLT_EPSILON || !Ue.Normalize() || !Ne.Normalize()) + { + control_point_type[i][j] = 3; + // Pc = roundto(Pc, nurbs_tolerance); // not sure if this rounding really happens, need to experiment, docs imply but do not state + compressed_control_point[i][j] = iroundto(Pc, nurbs_tolerance); + P[i][j] = P[i-1][j-1] + U + V + roundto(Pc, nurbs_tolerance); // see above + } + else + { + PRCVector3d NUe = Ne*Ue; + double x = Pc.Dot(Ue); + double y = Pc.Dot(NUe); + double z = Pc.Dot(Ne); + + if(x*x+y*y<nurbs_tolerance*nurbs_tolerance) + { + control_point_type[i][j] = 1; + compressed_control_point[i][j] = iroundto(PRCVector3d(0,0,z), nurbs_tolerance); + P[i][j] = P[i-1][j-1] + U + V + roundto(z, nurbs_tolerance)*Ne; // see above + } + else + { + if(fabs(z)<nurbs_tolerance/2) + { + control_point_type[i][j] = 2; + compressed_control_point[i][j] = iroundto(PRCVector3d(x,y,0), nurbs_tolerance); + P[i][j] = P[i-1][j-1] + U + V + roundto(x, nurbs_tolerance)*Ue + roundto(y, nurbs_tolerance)*NUe; // see above + } + else + { + control_point_type[i][j] = 3; + compressed_control_point[i][j] = iroundto(Pc, nurbs_tolerance); + P[i][j] = P[i-1][j-1] + U + V + roundto(Pc, nurbs_tolerance); // see above + } + } + } + } + uint32_t bit_size = GetNumberOfBitsUsedToStoreTripleInteger(compressed_control_point[i][j]); + if (bit_size > number_of_bits_for_rest) + number_of_bits_for_rest = bit_size; + } + + if( number_of_bits_for_rest == 2 ) number_of_bits_for_rest--; // really I think it must be unconditional, but so it seems to be done in Adobe Acrobat (9.3) + WriteUnsignedIntegerWithVariableBitNumber ( number_of_bits_for_isomin, 20 ) + WriteUnsignedIntegerWithVariableBitNumber ( number_of_bits_for_rest, 20 ) + WriteDouble ( P[0][0].x ) + WriteDouble ( P[0][0].y ) + WriteDouble ( P[0][0].z ) + + for(uint32_t j = 1; j < number_of_control_point_in_v; j++) + { + WriteIntegerWithVariableBitNumber(compressed_control_point[0][j].x, number_of_bits_for_isomin+1) + WriteIntegerWithVariableBitNumber(compressed_control_point[0][j].y, number_of_bits_for_isomin+1) + WriteIntegerWithVariableBitNumber(compressed_control_point[0][j].z, number_of_bits_for_isomin+1) + } + + for(uint32_t i = 1; i < number_of_control_point_in_u; i++) + { + WriteIntegerWithVariableBitNumber(compressed_control_point[i][0].x, number_of_bits_for_isomin+1) + WriteIntegerWithVariableBitNumber(compressed_control_point[i][0].y, number_of_bits_for_isomin+1) + WriteIntegerWithVariableBitNumber(compressed_control_point[i][0].z, number_of_bits_for_isomin+1) + } + + for(uint32_t i = 1; i < number_of_control_point_in_u; i++) + { + for(uint32_t j = 1; j < number_of_control_point_in_v; j++) + { + WriteUnsignedIntegerWithVariableBitNumber ( control_point_type[i][j], 2 ) + + if(control_point_type[i][j] == 1) + { + WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].z, number_of_bits_for_rest+1 ) + } + else if(control_point_type[i][j] == 2) + { + WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].x, number_of_bits_for_rest+1 ) + WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].y, number_of_bits_for_rest+1 ) + } + else if(control_point_type[i][j] == 3) + { + WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].x, number_of_bits_for_rest+1 ) + WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].y, number_of_bits_for_rest+1 ) + WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].z, number_of_bits_for_rest+1 ) + } + } + } + + const uint32_t type_param_u = 0; + WriteBoolean( type_param_u == 0 ) + const uint32_t type_param_v = 0; + WriteBoolean( type_param_v == 0 ) + const bool is_rational = false; + WriteBoolean( is_rational ) +} + +void PRCCompressedBrepData::serializeCompressedShell(PRCbitStream &pbs) +{ + uint32_t i; + const uint32_t number_of_face = face.size(); + WriteBoolean ( number_of_face == 1 ) + + if( number_of_face != 1 ) + WriteNumberOfBitsThenUnsignedInteger (number_of_face) + + for( i=0; i < number_of_face; i++) + SerializeCompressedFace ( face[i] ) + + const bool is_an_iso_face = false; + for( i=0; i < number_of_face; i++) + WriteBoolean ( is_an_iso_face ) +} + +void PRCCompressedBrepData::serializeCompressedBrepData(PRCbitStream &pbs) +{ + WriteUnsignedInteger ( PRC_TYPE_TOPO_BrepDataCompress ) + SerializeContentBody + + WriteDouble ( brep_data_compressed_tolerance ) + const uint32_t number_of_bits_to_store_reference = 1; + WriteNumberOfBitsThenUnsignedInteger ( number_of_bits_to_store_reference ) + const uint32_t number_vertex_iso = 0; + WriteUnsignedIntegerWithVariableBitNumber ( number_vertex_iso, number_of_bits_to_store_reference ) + const uint32_t number_edge_iso = 0; + WriteUnsignedIntegerWithVariableBitNumber ( number_edge_iso, number_of_bits_to_store_reference ) + + const uint32_t number_of_shell = 1; + const uint32_t number_of_connex = 1; + WriteBoolean ( number_of_shell == 1 && number_of_connex == 1 ) + serializeCompressedShell( pbs ); + + uint32_t i; + const uint32_t number_of_faces = face.size(); + for(i=0; i< number_of_faces; i++) + face[i]->serializeBaseTopology( pbs ); +} + +void PRCBlend01::serializeBlend01(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_SURF_Blend01) + + SerializeContentSurface + SerializeTransformation + SerializeUVParameterization + SerializePtrCurve ( center_curve ) + SerializePtrCurve ( origin_curve ) + SerializePtrCurve ( tangent_curve ) +} + +void PRCRuled::serializeRuled(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_SURF_Ruled) + + SerializeContentSurface + SerializeTransformation + SerializeUVParameterization + SerializePtrCurve ( first_curve ) + SerializePtrCurve ( second_curve ) +} + +void PRCSphere::serializeSphere(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_SURF_Sphere) + + SerializeContentSurface + SerializeTransformation + SerializeUVParameterization + WriteDouble ( radius ) +} + +void PRCCylinder::serializeCylinder(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_SURF_Cylinder) + + SerializeContentSurface + SerializeTransformation + SerializeUVParameterization + WriteDouble ( radius ) +} + +void PRCTorus::serializeTorus(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_SURF_Torus) + + SerializeContentSurface + SerializeTransformation + SerializeUVParameterization + WriteDouble ( major_radius ) + WriteDouble ( minor_radius ) +} + +void PRCFace::serializeFace(PRCbitStream &pbs) +{ + uint32_t i = 0; + WriteUnsignedInteger (PRC_TYPE_TOPO_Face) + + SerializeBaseTopology + SerializePtrSurface ( base_surface ) + WriteBit ( have_surface_trim_domain ) + if ( have_surface_trim_domain ) + SerializeDomain ( surface_trim_domain ) + WriteBit ( have_tolerance ) + if ( have_tolerance ) + WriteDouble ( tolerance ) + WriteUnsignedInteger ( number_of_loop ) + WriteInteger ( outer_loop_index ) + for (i=0;i<number_of_loop;i++) + { +// SerializePtrTopology ( loop[i] ) + } +} + +void PRCShell::serializeShell(PRCbitStream &pbs) +{ + uint32_t i = 0; + WriteUnsignedInteger (PRC_TYPE_TOPO_Shell) + + SerializeBaseTopology + WriteBoolean ( shell_is_closed ) + uint32_t number_of_face = face.size(); + WriteUnsignedInteger ( number_of_face ) + for (i=0;i<number_of_face;i++) + { + SerializePtrTopology ( face[i] ) + WriteCharacter ( orientation_surface_with_shell[i] ) + } +} + +void PRCShell::addFace(PRCFace *pFace, uint8_t orientation) +{ + face.push_back(PRCpFace(pFace)); + orientation_surface_with_shell.push_back(orientation); +} + +void PRCShell::addFace(const PRCpFace &pFace, uint8_t orientation) +{ + face.push_back(pFace); + orientation_surface_with_shell.push_back(orientation); +} + +void PRCConnex::serializeConnex(PRCbitStream &pbs) +{ + uint32_t i = 0; + WriteUnsignedInteger (PRC_TYPE_TOPO_Connex) + + SerializeBaseTopology + uint32_t number_of_shell = shell.size(); + WriteUnsignedInteger ( number_of_shell ) + for (i=0;i<number_of_shell;i++) + { + SerializePtrTopology ( shell[i] ) + } +} + +void PRCConnex::addShell(PRCShell *pShell) +{ + shell.push_back(PRCpShell(pShell)); +} + +#define have_bbox( behavior ) (behavior!=0) +void PRCBrepData::serializeBrepData(PRCbitStream &pbs) +{ + uint32_t i = 0; + WriteUnsignedInteger ( PRC_TYPE_TOPO_BrepData) + + SerializeContentBody + uint32_t number_of_connex = connex.size(); + WriteUnsignedInteger ( number_of_connex ) + for ( i=0; i<number_of_connex; i++) + { + SerializePtrTopology ( connex[i] ) + } + if ( have_bbox(behavior) ) + SerializeBoundingBox +} +#undef have_bbox + +void PRCBrepData::addConnex(PRCConnex *pConnex) +{ + connex.push_back(PRCpConnex(pConnex)); +} + +void PRCContentWireEdge::serializeContentWireEdge(PRCbitStream &pbs) +{ + SerializeBaseTopology + SerializePtrCurve ( curve_3d ) + WriteBit ( has_curve_trim_interval ) + if ( has_curve_trim_interval ) + SerializeInterval ( curve_trim_interval ) +} + +void PRCWireEdge::serializeWireEdge(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_TOPO_WireEdge) + SerializeContentWireEdge +} + +void PRCContentCurve::serializeContentCurve(PRCbitStream &pbs) +{ + SerializeBaseGeometry + WriteUnsignedInteger ( extend_info ) + WriteBoolean ( is_3d ) +} + +void PRCNURBSCurve::serializeNURBSCurve(PRCbitStream &pbs) +{ + uint32_t i=0; + WriteUnsignedInteger (PRC_TYPE_CRV_NURBS) + + SerializeContentCurve + WriteBoolean ( is_rational ) + WriteUnsignedInteger ( degree ) + uint32_t highest_index_of_control_point = control_point.size()-1; + uint32_t highest_index_of_knots = knot.size()-1; + WriteUnsignedInteger ( highest_index_of_control_point ) + WriteUnsignedInteger ( highest_index_of_knots ) + for (i=0; i<=highest_index_of_control_point; i++) + { + WriteDouble ( control_point[i].x ) + WriteDouble ( control_point[i].y ) + if (is_3d) + WriteDouble ( control_point[i].z ) + if (is_rational) + WriteDouble ( control_point[i].w ) + } + for (i=0; i<=highest_index_of_knots; i++) + WriteDouble ( knot[i] ) + WriteUnsignedInteger ( knot_type ) + WriteUnsignedInteger ( curve_form ) +} + +void PRCPolyLine::serializePolyLine(PRCbitStream &pbs) +{ + uint32_t i=0; + WriteUnsignedInteger (PRC_TYPE_CRV_PolyLine) + + SerializeContentCurve + SerializeTransformation + SerializeParameterization + uint32_t number_of_point = point.size(); + WriteUnsignedInteger ( number_of_point ) + for (i=0; i<number_of_point; i++) + { + if (is_3d) + SerializeVector3d ( point[i] ) + else + SerializeVector2d ( point[i] ) + } +} + +void PRCCircle::serializeCircle(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_CRV_Circle) + + SerializeContentCurve + SerializeTransformation + SerializeParameterization + WriteDouble ( radius ) +} + +void PRCComposite::serializeComposite(PRCbitStream &pbs) +{ + uint32_t i=0; + WriteUnsignedInteger (PRC_TYPE_CRV_Composite) + + SerializeContentCurve + SerializeTransformation + SerializeParameterization + uint32_t number_of_curves = base_curve.size(); + WriteUnsignedInteger ( number_of_curves ) + for (i=0; i<number_of_curves; i++) + { + SerializePtrCurve ( base_curve[i] ) + WriteBoolean ( base_sense[i] ) + } + WriteBoolean ( is_closed ) +} + +void PRCTopoContext::serializeTopoContext(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_TOPO_Context) + + SerializeContentPRCBase + WriteCharacter ( behaviour ) + WriteDouble ( granularity ) + WriteDouble ( tolerance ) + WriteBoolean ( have_smallest_face_thickness ) + if ( have_smallest_face_thickness ) + WriteDouble ( smallest_thickness ) + WriteBoolean ( have_scale ) + if ( have_scale ) + WriteDouble ( scale ) +} + +void PRCTopoContext::serializeContextAndBodies(PRCbitStream &pbs) +{ + uint32_t i=0; + SerializeTopoContext + uint32_t number_of_bodies = body.size(); + WriteUnsignedInteger (number_of_bodies) + for (i=0;i<number_of_bodies;i++) + SerializeBody (body[i]) +} + +void PRCTopoContext::serializeGeometrySummary(PRCbitStream &pbs) +{ + uint32_t i=0; + uint32_t number_of_bodies = body.size(); + WriteUnsignedInteger (number_of_bodies) + for (i=0;i<number_of_bodies;i++) + { + WriteUnsignedInteger ( body[i]->serialType() ) + if ( IsCompressedType(body[i]->serialType()) ) + { + WriteDouble ( body[i]->serialTolerance() ) + } + } +} + +void PRCTopoContext::serializeContextGraphics(PRCbitStream &pbs) +{ + uint32_t i=0, j=0, k=0, l=0; + ResetCurrentGraphics + uint32_t number_of_body = body.size(); + PRCGraphicsList element; + bool has_graphics = false; + for (i=0;i<number_of_body;i++) + { + if ( body[i]->topo_item_type == PRC_TYPE_TOPO_BrepData && dynamic_cast<PRCBrepData*>(body[i].get())) + { + PRCBrepData *body_i = dynamic_cast<PRCBrepData*>(body[i].get()); + for (j=0;j<body_i->connex.size();j++) + { + for(k=0;k<body_i->connex[j]->shell.size();k++) + { + for( l=0;l<body_i->connex[j]->shell[k]->face.size();l++) + { + element.push_back( body_i->connex[j]->shell[k]->face[l] ); + has_graphics = has_graphics || body_i->connex[j]->shell[k]->face[l]->has_graphics(); + } + } + } + } + else if ( body[i]->topo_item_type == PRC_TYPE_TOPO_BrepDataCompress && dynamic_cast<PRCCompressedBrepData*>(body[i].get())) + { + PRCCompressedBrepData *body_i = dynamic_cast<PRCCompressedBrepData*>(body[i].get()); + for( l=0;l<body_i->face.size();l++) + { + element.push_back( body_i->face[l] ); + has_graphics = has_graphics || body_i->face[l]->has_graphics(); + } + } + } + uint32_t number_of_treat_type = 0; + if (has_graphics && !element.empty()) + number_of_treat_type = 1; + WriteUnsignedInteger (number_of_treat_type) + for (i=0;i<number_of_treat_type;i++) + { + const uint32_t element_type = PRC_TYPE_TOPO_Face; + WriteUnsignedInteger (element_type) + const uint32_t number_of_element = element.size(); + WriteUnsignedInteger (number_of_element) + for (j=0;j<number_of_element;j++) + { + WriteBoolean ( element[j]->has_graphics() ) + if (element[j]->has_graphics()) + { + element[j]->serializeGraphics(pbs); + } + } + } +} + +uint32_t PRCTopoContext::addSingleWireBody(PRCSingleWireBody *pSingleWireBody) +{ + body.push_back(PRCpBody(pSingleWireBody)); + return body.size()-1; +} + +uint32_t PRCTopoContext::addBrepData(PRCBrepData *pBrepData) +{ + body.push_back(PRCpBody(pBrepData)); + return body.size()-1; +} + +uint32_t PRCTopoContext::addCompressedBrepData(PRCCompressedBrepData *pCompressedBrepData) +{ + body.push_back(PRCpBody(pCompressedBrepData)); + return body.size()-1; +} + +void PRCSingleWireBody::setWireEdge(PRCWireEdge *wireEdge) +{ + wire_edge.reset(wireEdge); +} + +void PRCSingleWireBody::serializeSingleWireBody(PRCbitStream &pbs) +{ + WriteUnsignedInteger ( PRC_TYPE_TOPO_SingleWireBody) + + SerializeContentBody + SerializePtrTopology ( wire_edge ) +} + +void PRCUniqueId::serializeCompressedUniqueId(PRCbitStream &pbs) +{ + WriteUnsignedInteger (unique_id0) + WriteUnsignedInteger (unique_id1) + WriteUnsignedInteger (unique_id2) + WriteUnsignedInteger (unique_id3) +} + +void PRCUnit::serializeUnit(PRCbitStream &pbs) +{ + WriteBoolean (unit_from_CAD_file) + WriteDouble (unit) +} + +void PRCProductOccurrence::serializeProductOccurrence(PRCbitStream &pbs) +{ + WriteUnsignedInteger ( PRC_TYPE_ASM_ProductOccurence ) + + SerializePRCBaseWithGraphics + +// SerializeReferencesOfProductOccurrence + WriteUnsignedInteger (index_part+1) + WriteUnsignedInteger (index_prototype+1) + if (index_prototype != m1) + { + WriteBoolean (prototype_in_same_file_structure) + if (!prototype_in_same_file_structure) + SerializeCompressedUniqueId (prototype_file_structure) + } + WriteUnsignedInteger(index_external_data+1) + if (index_external_data != m1) + { + WriteBoolean (external_data_in_same_file_structure) + if (!external_data_in_same_file_structure) + SerializeCompressedUniqueId (external_data_file_structure) + } + const uint32_t number_of_son_product_occurrences = index_son_occurrence.size(); + WriteUnsignedInteger (number_of_son_product_occurrences) + for (uint32_t i=0;i<number_of_son_product_occurrences;i++) + WriteUnsignedInteger (index_son_occurrence[i]) + + WriteCharacter (product_behaviour) + +// SerializeProductInformation (product_information) + SerializeUnit (unit_information) + WriteCharacter (product_information_flags) + WriteInteger (product_load_status) + + WriteBit (has_location) + if (has_location) + location->serializeTransformation3d (pbs); + + WriteUnsignedInteger (0) // number_of_references + +// SerializeMarkups (markups) + WriteUnsignedInteger (0) // number_of_linked_items + WriteUnsignedInteger (0) // number_of_leaders + WriteUnsignedInteger (0) // number_of_markups + WriteUnsignedInteger (0) // number_of_annotation_entities + + + WriteUnsignedInteger (0) // number_of_views + WriteBit (false) // has_entity_filter + WriteUnsignedInteger (0) // number_of_display_filters + WriteUnsignedInteger (0) // number_of_scene_display_parameters + + SerializeUserData +} + +uint32_t PRCPartDefinition::addBrepModel(PRCBrepModel *pBrepModel) +{ + representation_item.push_back(PRCpRepresentationItem(pBrepModel)); + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel) +{ + representation_item.push_back(PRCpRepresentationItem(pPolyBrepModel)); + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addPointSet(PRCPointSet *pPointSet) +{ + representation_item.push_back(PRCpRepresentationItem(pPointSet)); + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addSet(PRCSet *pSet) +{ + representation_item.push_back(PRCpRepresentationItem(pSet)); + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addWire(PRCWire *pWire) +{ + representation_item.push_back(PRCpRepresentationItem(pWire)); + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addPolyWire(PRCPolyWire *pPolyWire) +{ + representation_item.push_back(PRCpRepresentationItem(pPolyWire)); + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addRepresentationItem(PRCRepresentationItem *pRepresentationItem) +{ + representation_item.push_back(PRCpRepresentationItem(pRepresentationItem)); + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addRepresentationItem(PRCpRepresentationItem pRepresentationItem) +{ + representation_item.push_back(pRepresentationItem); + return representation_item.size()-1; +} + + +void PRCPartDefinition::serializePartDefinition(PRCbitStream &pbs) +{ + WriteUnsignedInteger ( PRC_TYPE_ASM_PartDefinition ) + + SerializePRCBaseWithGraphics + SerializeBoundingBox + + uint32_t number_of_representation_items = representation_item.size(); + WriteUnsignedInteger (number_of_representation_items) + for (uint32_t i=0;i<number_of_representation_items;i++) + SerializeRepresentationItem (representation_item[i]) + + // SerializeMarkups (markups) + WriteUnsignedInteger (0) // number_of_linked_items + WriteUnsignedInteger (0) // number_of_leaders + WriteUnsignedInteger (0) // number_of_markups + WriteUnsignedInteger (0) // number_of_annotation_entities + + WriteUnsignedInteger (0) // number_of_views + SerializeUserData +} diff --git a/Build/source/utils/asymptote/prc/writePRC.h b/Build/source/utils/asymptote/prc/writePRC.h index 6a4da7a70ba..18c616ccfac 100644 --- a/Build/source/utils/asymptote/prc/writePRC.h +++ b/Build/source/utils/asymptote/prc/writePRC.h @@ -21,33 +21,86 @@ #ifndef __WRITE_PRC_H #define __WRITE_PRC_H #include <string> +#include <vector> +#include <map> +#include <iostream> +#if defined(_MSC_VER) +#include <memory> +#else +#include <tr1/memory> +#endif #include "PRCbitStream.h" #include "PRC.h" +#include <float.h> +#include <math.h> -struct Point3d -{ - double x,y,z; - Point3d(double a, double b, double c) : x(a),y(b),z(c) {} - void write(PRCbitStream &out) - { - out << x << y << z; - } -}; +static const uint32_t m1=(uint32_t)-1; +static const double pi=acos(-1); -struct Extent3d +class PRCVector3d { - Point3d min,max; - Extent3d(const Point3d &m1, const Point3d& m2) : min(m1),max(m2) {} - void write(PRCbitStream &out) - { - // flip the order? Following the documentation, in a real file, min>max. - // Considering the file to be right, min and max can be flipped in both places (here and in description) - // resulting in no practical difference. - // But in other places (Extent3D and Extent1D), min is really before max, so for consistency - // this is left alone. - min.write(out); - max.write(out); - } +public : + double x; + double y; + double z; + PRCVector3d() {} + PRCVector3d(double fx, double fy, double fz) : + x(fx), y(fy), z(fz) {} + PRCVector3d(const double c[]) : + x(c?c[0]:0), y(c?c[1]:0), z(c?c[2]:0) {} + PRCVector3d(const PRCVector3d& sVector3d) : + x(sVector3d.x), y(sVector3d.y), z(sVector3d.z) {} + + void Set(double fx, double fy, double fz) + { x = fx; y = fy; z = fz; } + double Dot(const PRCVector3d & sPt) const + { return(x*sPt.x)+(y*sPt.y)+(z*sPt.z); } + double LengthSquared() + { return(x*x+y*y+z*z); } + + friend PRCVector3d operator + (const PRCVector3d& a, const PRCVector3d& b) + { return PRCVector3d(a.x+b.x,a.y+b.y,a.z+b.z); } + friend PRCVector3d operator - (const PRCVector3d& a) + { return PRCVector3d(-a.x,-a.y,-a.z); } + friend PRCVector3d operator - (const PRCVector3d& a, const PRCVector3d& b) + { return PRCVector3d(a.x-b.x,a.y-b.y,a.z-b.z); } + friend PRCVector3d operator * (const PRCVector3d& a, const double d) + { return PRCVector3d(a.x*d,a.y*d,a.z*d); } + friend PRCVector3d operator * (const double d, const PRCVector3d& a) + { return PRCVector3d(a.x*d,a.y*d,a.z*d); } + friend PRCVector3d operator / (const PRCVector3d& a, const double d) + { return PRCVector3d(a.x/d,a.y/d,a.z/d); } + friend PRCVector3d operator * (const PRCVector3d& a, const PRCVector3d& b) + { return PRCVector3d((a.y*b.z)-(a.z*b.y), (a.z*b.x)-(a.x*b.z), (a.x*b.y)-(a.y*b.x)); } + + void write(PRCbitStream &out) { out << x << y << z; } + void serializeVector3d(PRCbitStream &pbs) const { pbs << x << y << z; } + void serializeVector2d(PRCbitStream &pbs) const { pbs << x << y; } + + double Length(); + bool Normalize(); + + bool operator==(const PRCVector3d &v) const + { + return x==v.x && y==v.y && z==v.z; + } + bool operator!=(const PRCVector3d &v) const + { + return !(x==v.x && y==v.y && z==v.z); + } + bool operator<(const PRCVector3d &v) const + { + if(x!=v.x) + return (x<v.x); + if(y!=v.y) + return (y<v.y); + return (z<v.z); + } + friend std::ostream& operator << (std::ostream& out, const PRCVector3d& v) + { + out << "(" << v.x << "," << v.y << "," << v.z << ")"; + return out; + } }; class UUID @@ -140,13 +193,25 @@ class ContentPRCBase attributes(a),name(n),eligibleForReference(efr),CADID(ci), CADPersistentID(cpi),PRCID(pi) {} void write(PRCbitStream&); - private: + uint32_t getPRCID() { return PRCID; } Attributes *attributes; std::string name; bool eligibleForReference; uint32_t CADID, CADPersistentID, PRCID; }; +class PRCReferenceUniqueIdentifier +{ +public: + PRCReferenceUniqueIdentifier() : + type(0), unique_identifier(m1) {} + void serializeReferenceUniqueIdentifier(PRCbitStream&); + uint32_t type; +// bool reference_in_same_file_structure; +// PRCUniqueId target_file_structure; + uint32_t unique_identifier; +}; + extern AttributeTitle EMPTY_ATTRIBUTE_TITLE; extern Attribute EMPTY_ATTRIBUTE; extern Attributes EMPTY_ATTRIBUTES; @@ -157,16 +222,1144 @@ extern std::string currentName; void writeName(PRCbitStream&,const std::string&); void resetName(); -extern uint32_t layer_index; -extern uint32_t index_of_line_style; -extern uint32_t behaviour_bit_field; -static const uint32_t m1=(uint32_t)-1; +extern uint32_t current_layer_index; +extern uint32_t current_index_of_line_style; +extern uint16_t current_behaviour_bit_field; void writeGraphics(PRCbitStream&,uint32_t=m1,uint32_t=m1,uint32_t=1,bool=false); void resetGraphics(); void resetGraphicsAndName(); +struct PRCRgbColor +{ + PRCRgbColor(double r=0.0, double g=0.0, double b=0.0) : + red(r), green(g), blue(b) {} + double red,green,blue; + void serializeRgbColor(PRCbitStream&); + + bool operator==(const PRCRgbColor &c) const + { + return (red==c.red && green==c.green && blue==c.blue); + } + bool operator!=(const PRCRgbColor &c) const + { + return !(red==c.red && green==c.green && blue==c.blue); + } + bool operator<(const PRCRgbColor &c) const + { + if(red!=c.red) + return (red<c.red); + if(green!=c.green) + return (green<c.green); + return (blue<c.blue); + } +}; + +class PRCPicture : public ContentPRCBase +{ +public: + PRCPicture(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n), format(KEPRCPicture_PNG), uncompressed_file_index(m1), pixel_width(0), pixel_height(0) {} + void serializePicture(PRCbitStream&); + EPRCPictureDataFormat format; + uint32_t uncompressed_file_index; + uint32_t pixel_width; + uint32_t pixel_height; +}; + +struct PRCVector2d +{ + PRCVector2d() : + x(0.0), y(0.0) {} + PRCVector2d(double X, double Y) : + x(X), y(Y) {} + void serializeVector2d(PRCbitStream&); + double x; + double y; +}; + +class PRCTextureDefinition : public ContentPRCBase +{ +public: + PRCTextureDefinition(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), picture_index(m1), texture_mapping_attribute(PRC_TEXTURE_MAPPING_DIFFUSE), + texture_mapping_attribute_intensity(1.0), texture_mapping_attribute_components(PRC_TEXTURE_MAPPING_COMPONENTS_RGBA), + texture_function(KEPRCTextureFunction_Modulate), texture_applying_mode(PRC_TEXTURE_APPLYING_MODE_NONE), + texture_wrapping_mode_S(KEPRCTextureWrappingMode_Unknown), texture_wrapping_mode_T(KEPRCTextureWrappingMode_Unknown) // , + // texture_transformation(false), texture_flip_S(false), texture_flip_T(false), + // behaviour(PRC_TRANSFORMATION_Identity), scale(1.0,1.0), uniform_scale(1.0) + {} + void serializeTextureDefinition(PRCbitStream&); + uint32_t picture_index; + uint32_t texture_mapping_attribute; + double texture_mapping_attribute_intensity; + uint8_t texture_mapping_attribute_components; + EPRCTextureFunction texture_function; + uint8_t texture_applying_mode; + EPRCTextureWrappingMode texture_wrapping_mode_S; + EPRCTextureWrappingMode texture_wrapping_mode_T; + // bool texture_transformation; + // bool texture_flip_S; + // bool texture_flip_T; + // uint8_t behaviour; + // PRCVector2d origin; + // PRCVector2d X; + // PRCVector2d Y; + // PRCVector2d scale; + // double uniform_scale; + // double X_homegeneous_coord; + // double Y_homegeneous_coord; + // double origin_homegeneous_coord; +}; +typedef std::tr1::shared_ptr <PRCTextureDefinition> PRCpTextureDefinition; +typedef std::vector <PRCpTextureDefinition> PRCTextureDefinitionList; + +class PRCMaterial +{ +public: + virtual void serializeMaterial(PRCbitStream&) = 0; +}; +typedef std::tr1::shared_ptr <PRCMaterial> PRCpMaterial; +typedef std::vector <PRCpMaterial> PRCMaterialList; + +class PRCMaterialGeneric : public ContentPRCBase, public PRCMaterial +{ +public: + PRCMaterialGeneric(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), + ambient(m1), diffuse(m1), emissive(m1), specular(m1), + shininess(0.0), + ambient_alpha(1.0), diffuse_alpha(1.0), emissive_alpha(1.0), specular_alpha(1.0) + {} + void serializeMaterialGeneric(PRCbitStream&); + void serializeMaterial(PRCbitStream &pbs) { serializeMaterialGeneric(pbs); } + uint32_t picture_index; + uint32_t ambient; + uint32_t diffuse; + uint32_t emissive; + uint32_t specular; + double shininess; + double ambient_alpha; + double diffuse_alpha; + double emissive_alpha; + double specular_alpha; + + bool operator==(const PRCMaterialGeneric &m) const + { + return (ambient==m.ambient && diffuse==m.diffuse && emissive==m.emissive && specular==m.specular && shininess==m.shininess && + ambient_alpha==m.ambient_alpha && diffuse_alpha==m.diffuse_alpha && emissive_alpha==m.emissive_alpha && specular_alpha==m.specular_alpha); + } +}; + +class PRCTextureApplication : public ContentPRCBase, public PRCMaterial +{ +public: + PRCTextureApplication(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), + material_generic_index(m1), texture_definition_index(m1), + next_texture_index(m1), UV_coordinates_index(0) + {} + void serializeTextureApplication(PRCbitStream&); + void serializeMaterial(PRCbitStream &pbs) { serializeTextureApplication(pbs); } + uint32_t material_generic_index; + uint32_t texture_definition_index; + uint32_t next_texture_index; + uint32_t UV_coordinates_index; +}; + +class PRCStyle : public ContentPRCBase +{ +public: + PRCStyle(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), line_width(0.0), is_vpicture(false), line_pattern_vpicture_index(m1), + is_material(false), color_material_index(m1), is_transparency_defined(false), transparency(255), additional(0) + {} + void serializeCategory1LineStyle(PRCbitStream&); + double line_width; + bool is_vpicture; + uint32_t line_pattern_vpicture_index; + bool is_material; + uint32_t color_material_index; + bool is_transparency_defined; + uint8_t transparency; + uint8_t additional; +}; +typedef std::tr1::shared_ptr <PRCStyle> PRCpStyle; +typedef std::vector <PRCpStyle> PRCStyleList; + +class PRCTessFace +{ +public: + PRCTessFace() : + start_wire(0), used_entities_flag(0), + start_triangulated(0), number_of_texture_coordinate_indexes(0), + is_rgba(false), behaviour(PRC_GRAPHICS_Show) + {} + void serializeTessFace(PRCbitStream&); + std::vector<uint32_t> line_attributes; + uint32_t start_wire; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2 + std::vector<uint32_t> sizes_wire; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2 + uint32_t used_entities_flag; + uint32_t start_triangulated; + std::vector<uint32_t> sizes_triangulated; + uint32_t number_of_texture_coordinate_indexes; + bool is_rgba; + std::vector<uint8_t> rgba_vertices; + uint32_t behaviour; +}; +typedef std::tr1::shared_ptr <PRCTessFace> PRCpTessFace; +typedef std::vector <PRCpTessFace> PRCTessFaceList; + +class PRCContentBaseTessData +{ +public: + PRCContentBaseTessData() : + is_calculated(false) {} + void serializeContentBaseTessData(PRCbitStream&); + bool is_calculated; + std::vector<double> coordinates; +}; + +class PRCTess : public PRCContentBaseTessData +{ +public: + virtual void serializeBaseTessData(PRCbitStream &pbs) = 0; +}; +typedef std::tr1::shared_ptr <PRCTess> PRCpTess; +typedef std::vector <PRCpTess> PRCTessList; + +class PRC3DTess : public PRCTess +{ +public: + PRC3DTess() : + has_faces(false), has_loops(false), + crease_angle(25.8419) + {} + void serialize3DTess(PRCbitStream&); + void serializeBaseTessData(PRCbitStream &pbs) { serialize3DTess(pbs); } + void addTessFace(PRCTessFace *pTessFace); + + bool has_faces; + bool has_loops; + double crease_angle; + std::vector<double> normal_coordinate; + std::vector<uint32_t> wire_index; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2 + std::vector<uint32_t> triangulated_index; + PRCTessFaceList face_tessellation; + std::vector<double> texture_coordinate; +}; + +class PRC3DWireTess : public PRCTess +{ +public: + PRC3DWireTess() : + is_rgba(false), is_segment_color(false) {} + void serialize3DWireTess(PRCbitStream&); + void serializeBaseTessData(PRCbitStream &pbs) { serialize3DWireTess(pbs); } + + bool is_rgba; + bool is_segment_color; + std::vector<uint32_t> wire_indexes; + std::vector<uint8_t> rgba_vertices; +}; + +class PRCMarkupTess : public PRCTess +{ +public: + PRCMarkupTess() : + behaviour(0) + {} + void serializeMarkupTess(PRCbitStream&); + void serializeBaseTessData(PRCbitStream &pbs) { serializeMarkupTess(pbs); } + + std::vector<uint32_t> codes; + std::vector<std::string> texts; + std::string label; + uint8_t behaviour; +}; + +class PRCGraphics +{ +public: + PRCGraphics() : layer_index(m1), index_of_line_style(m1), behaviour_bit_field(PRC_GRAPHICS_Show) {} + void serializeGraphics(PRCbitStream&); + void serializeGraphicsForced(PRCbitStream&); + bool has_graphics() { return (index_of_line_style!=m1 || layer_index!=m1 || behaviour_bit_field!=PRC_GRAPHICS_Show) ; } + uint32_t layer_index; + uint32_t index_of_line_style; + uint16_t behaviour_bit_field; +}; +typedef std::tr1::shared_ptr <PRCGraphics> PRCpGraphics; +typedef std::vector <PRCpGraphics> PRCGraphicsList; + +void writeGraphics(PRCbitStream&,const PRCGraphics&,bool=false); + +class PRCMarkup: public PRCGraphics, public ContentPRCBase +{ +public: + PRCMarkup(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), + type(KEPRCMarkupType_Unknown), sub_type(KEPRCMarkupSubType_Unknown), index_tessellation(m1) {} + void serializeMarkup(PRCbitStream&); + EPRCMarkupType type; + EPRCMarkupSubType sub_type; +// vector<PRCReferenceUniqueIdentifier> linked_items; +// vector<PRCReferenceUniqueIdentifier> leaders; + uint32_t index_tessellation; +}; +typedef std::tr1::shared_ptr <PRCMarkup> PRCpMarkup; +typedef std::vector <PRCpMarkup> PRCMarkupList; + +class PRCAnnotationItem: public PRCGraphics, public ContentPRCBase +{ +public: + PRCAnnotationItem(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()) {} + void serializeAnnotationItem(PRCbitStream&); + void serializeAnnotationEntity(PRCbitStream &pbs) { serializeAnnotationItem(pbs); } + PRCReferenceUniqueIdentifier markup; +}; +typedef std::tr1::shared_ptr <PRCAnnotationItem> PRCpAnnotationItem; +typedef std::vector <PRCpAnnotationItem> PRCAnnotationItemList; + +class PRCRepresentationItemContent: public PRCGraphics, public ContentPRCBase +{ +public: + PRCRepresentationItemContent(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), + index_local_coordinate_system(m1), index_tessellation(m1) {} + void serializeRepresentationItemContent(PRCbitStream&); + uint32_t index_local_coordinate_system; + uint32_t index_tessellation; +}; + +class PRCRepresentationItem : public PRCRepresentationItemContent +{ +public: + PRCRepresentationItem(std::string n="") : + PRCRepresentationItemContent(n) {} + virtual void serializeRepresentationItem(PRCbitStream &pbs) = 0; +}; +typedef std::tr1::shared_ptr <PRCRepresentationItem> PRCpRepresentationItem; +typedef std::vector <PRCpRepresentationItem> PRCRepresentationItemList; + +class PRCBrepModel : public PRCRepresentationItem +{ +public: + PRCBrepModel(std::string n="") : + PRCRepresentationItem(n), has_brep_data(true), context_id(m1), body_id(m1), is_closed(false) {} + void serializeBrepModel(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializeBrepModel(pbs); } + bool has_brep_data; + uint32_t context_id; + uint32_t body_id; + bool is_closed; +}; + +class PRCPolyBrepModel : public PRCRepresentationItem +{ +public: + PRCPolyBrepModel(std::string n="") : + PRCRepresentationItem(n), is_closed(false) {} + void serializePolyBrepModel(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyBrepModel(pbs); } + bool is_closed; +}; + +class PRCPointSet : public PRCRepresentationItem +{ +public: + PRCPointSet(std::string n="") : + PRCRepresentationItem(n) {} + void serializePointSet(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializePointSet(pbs); } + std::vector<PRCVector3d> point; +}; +typedef std::tr1::shared_ptr <PRCPointSet> PRCpPointSet; + +class PRCWire : public PRCRepresentationItem +{ +public: + PRCWire(std::string n="") : + PRCRepresentationItem(n), has_wire_body(true), context_id(m1), body_id(m1) {} + void serializeWire(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializeWire(pbs); } + bool has_wire_body; + uint32_t context_id; + uint32_t body_id; +}; + +class PRCPolyWire : public PRCRepresentationItem +{ +public: + PRCPolyWire(std::string n="") : + PRCRepresentationItem(n) {} + void serializePolyWire(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyWire(pbs); } +}; + +class PRCSet : public PRCRepresentationItem +{ +public: + PRCSet(std::string n="") : + PRCRepresentationItem(n) {} + void serializeSet(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializeSet(pbs); } + uint32_t addBrepModel(PRCBrepModel *pBrepModel); + uint32_t addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel); + uint32_t addPointSet(PRCPointSet *pPointSet); + uint32_t addSet(PRCSet *pSet); + uint32_t addWire(PRCWire *pWire); + uint32_t addPolyWire(PRCPolyWire *pPolyWire); + uint32_t addRepresentationItem(PRCRepresentationItem *pRepresentationItem); + uint32_t addRepresentationItem(PRCpRepresentationItem pRepresentationItem); + PRCRepresentationItemList elements; +}; + +class PRCTransformation3d +{ +public: + virtual void serializeTransformation3d(PRCbitStream&) const =0; +}; +typedef std::tr1::shared_ptr <PRCTransformation3d> PRCpTransformation3d; +typedef std::vector <PRCpTransformation3d> PRCTransformation3dList; + +class PRCGeneralTransformation3d : public PRCTransformation3d +{ +public: + PRCGeneralTransformation3d() + { + mat[0][0] = mat[1][1] = mat[2][2] = mat[3][3] = 1.0; + mat[0][1] = mat[0][2] = mat[0][3] = 0.0; + mat[1][0] = mat[1][2] = mat[1][3] = 0.0; + mat[2][0] = mat[2][1] = mat[2][3] = 0.0; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0; + } + PRCGeneralTransformation3d(const double t[][4]) + { + if(t!=NULL) + for (size_t i=0;i<4;i++) + for (size_t j=0;j<4;j++) + mat[i][j]=t[i][j]; + else + { + mat[0][0] = mat[1][1] = mat[2][2] = mat[3][3] = 1.0; + mat[0][1] = mat[0][2] = mat[0][3] = 0.0; + mat[1][0] = mat[1][2] = mat[1][3] = 0.0; + mat[2][0] = mat[2][1] = mat[2][3] = 0.0; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0; + } + } + PRCGeneralTransformation3d(const double t[][4], double scale) + { + if(t!=NULL) + { + for (size_t i=0;i<3;i++) + for (size_t j=0;j<4;j++) + mat[i][j]=scale*t[i][j]; + for(size_t j= 0;j<4; j++) + mat[3][j] = scale*t[3][j]; + } + else + { + mat[0][0] = mat[1][1] = mat[2][2] = mat[3][3] = 1.0; + mat[0][1] = mat[0][2] = mat[0][3] = 0.0; + mat[1][0] = mat[1][2] = mat[1][3] = 0.0; + mat[2][0] = mat[2][1] = mat[2][3] = 0.0; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0; + } + } + + void serializeGeneralTransformation3d(PRCbitStream&) const; + void serializeTransformation3d(PRCbitStream& pbs) const { serializeGeneralTransformation3d(pbs); } + double mat[4][4]; + bool operator==(const PRCGeneralTransformation3d &t) const + { + for (size_t i=0;i<4;i++) + for (size_t j=0;j<4;j++) + if(mat[i][j]!=t.mat[i][j]) + return false; + return true; + } + bool operator<(const PRCGeneralTransformation3d &t) const + { + for (size_t i=0;i<4;i++) + for (size_t j=0;j<4;j++) + if(mat[i][j]!=t.mat[i][j]) + { + return (mat[i][j]<t.mat[i][j]); + } + return false; + } + void set(const double t[][4]) + { + if(t!=NULL) + for (size_t i=0;i<4;i++) + for (size_t j=0;j<4;j++) + mat[i][j]=t[i][j]; + } + bool isnotidtransform() const { + return( + mat[0][0]!=1 || mat[0][1]!=0 || mat[0][2]!=0 || mat[0][3]!=0 || + mat[1][0]!=0 || mat[1][1]!=1 || mat[1][2]!=0 || mat[1][3]!=0 || + mat[2][0]!=0 || mat[2][1]!=0 || mat[2][2]!=1 || mat[2][3]!=0 || + mat[3][0]!=0 || mat[3][1]!=0 || mat[3][2]!=0 || mat[3][3]!=1 ); + } + bool isidtransform() const { + return( + mat[0][0]==1 && mat[0][1]==0 && mat[0][2]==0 && mat[0][3]==0 && + mat[1][0]==0 && mat[1][1]==1 && mat[1][2]==0 && mat[1][3]==0 && + mat[2][0]==0 && mat[2][1]==0 && mat[2][2]==1 && mat[2][3]==0 && + mat[3][0]==0 && mat[3][1]==0 && mat[3][2]==0 && mat[3][3]==1 ); + } +}; +typedef std::tr1::shared_ptr <PRCGeneralTransformation3d> PRCpGeneralTransformation3d; +typedef std::vector <PRCpGeneralTransformation3d> PRCGeneralTransformation3dList; +class PRCCartesianTransformation3d : public PRCTransformation3d +{ +public: + PRCCartesianTransformation3d() : + behaviour(PRC_TRANSFORMATION_Identity), origin(0.0,0.0,0.0), X(1.0,0.0,0.0), Y(0.0,1.0,0.0), Z(0.0,0.0,1.0), + scale(1.0,1.0,1.0), uniform_scale(1.0), + X_homogeneous_coord(0.0), Y_homogeneous_coord(0.0), Z_homogeneous_coord(0.0), origin_homogeneous_coord(1.0) {} + void serializeCartesianTransformation3d(PRCbitStream& pbs) const; + void serializeTransformation3d(PRCbitStream& pbs) const { serializeCartesianTransformation3d(pbs); } + uint8_t behaviour; + PRCVector3d origin; + PRCVector3d X; + PRCVector3d Y; + PRCVector3d Z; + PRCVector3d scale; + double uniform_scale; + double X_homogeneous_coord; + double Y_homogeneous_coord; + double Z_homogeneous_coord; + double origin_homogeneous_coord; + bool operator==(const PRCCartesianTransformation3d &t) const + { + return behaviour==t.behaviour && origin==t.origin && X==t.X && Y==t.Y && Z==t.Z && scale==t.scale && uniform_scale==t.uniform_scale && + X_homogeneous_coord==t.X_homogeneous_coord && Y_homogeneous_coord==t.Y_homogeneous_coord && + Z_homogeneous_coord==t.Z_homogeneous_coord && origin_homogeneous_coord==t.origin_homogeneous_coord; + } +}; + +class PRCTransformation +{ +public: + PRCTransformation() : + has_transformation(false), geometry_is_2D(false), behaviour(PRC_TRANSFORMATION_Identity), + origin(0,0,0), x_axis(1,0,0), y_axis(0,1,0), scale(1) {} + void serializeTransformation(PRCbitStream&); + bool has_transformation; + bool geometry_is_2D; + uint8_t behaviour; + PRCVector3d origin; + PRCVector3d x_axis; + PRCVector3d y_axis; + double scale; +}; + +class PRCCoordinateSystem : public PRCRepresentationItem +{ +public: + PRCCoordinateSystem(std::string n="") : + PRCRepresentationItem(n) {} + void serializeCoordinateSystem(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializeCoordinateSystem(pbs); } + PRCpTransformation3d axis_set; + bool operator==(const PRCCoordinateSystem &t) const + { + if(index_local_coordinate_system!=t.index_local_coordinate_system) + return false; + PRCGeneralTransformation3d* axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(axis_set.get()); + PRCGeneralTransformation3d* t_axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(t.axis_set.get()); + PRCCartesianTransformation3d* axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(axis_set.get()); + PRCCartesianTransformation3d* t_axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(t.axis_set.get()); + if(axis_set_general!=NULL) + return (t_axis_set_general!=NULL?(*axis_set_general==*t_axis_set_general):false); + if(axis_set_cartesian!=NULL) + return (t_axis_set_cartesian!=NULL?(*axis_set_cartesian==*t_axis_set_cartesian):false); + return false; + } +}; +typedef std::tr1::shared_ptr <PRCCoordinateSystem> PRCpCoordinateSystem; +typedef std::vector <PRCpCoordinateSystem> PRCCoordinateSystemList; + +struct PRCFontKey +{ + uint32_t font_size; + uint8_t attributes; +}; + +class PRCFontKeysSameFont +{ +public: + void serializeFontKeysSameFont(PRCbitStream&); + std::string font_name; + uint32_t char_set; + std::vector<PRCFontKey> font_keys; + +}; + +// Topology +class PRCBaseGeometry +{ +public: + PRCBaseGeometry() : + base_information(false) {} + PRCBaseGeometry(Attributes *a, std::string n="", uint32_t id = 0) : + base_information(true),attributes(a),name(n),identifier(id) {} + void serializeBaseGeometry(PRCbitStream&); + bool base_information; + Attributes *attributes; + std::string name; + uint32_t identifier; +}; + +class PRCBoundingBox +{ +public: + PRCBoundingBox() : min(0,0,0), max(0,0,0) {} + PRCBoundingBox(const PRCVector3d &m1, const PRCVector3d& m2) : min(m1),max(m2) {} + void serializeBoundingBox(PRCbitStream &pbs); + PRCVector3d min; + PRCVector3d max; +}; + +class PRCDomain +{ +public: + void serializeDomain(PRCbitStream &pbs); + PRCVector2d min; + PRCVector2d max; +}; + +class PRCInterval +{ +public: + PRCInterval() : min(0), max(0) {} + PRCInterval(double m, double M) : min(m), max(M) {} + void serializeInterval(PRCbitStream &pbs); + double min; + double max; +}; + +class PRCParameterization +{ +public: + PRCParameterization() : parameterization_coeff_a(1), parameterization_coeff_b(0) {} + PRCParameterization(double min, double max) : interval(min, max), parameterization_coeff_a(1), parameterization_coeff_b(0) {} + void serializeParameterization(PRCbitStream &pbs); + PRCInterval interval; + double parameterization_coeff_a; + double parameterization_coeff_b; +}; + +class PRCUVParameterization +{ +public: + PRCUVParameterization() : swap_uv(false), + parameterization_on_u_coeff_a(1), parameterization_on_v_coeff_a(1), + parameterization_on_u_coeff_b(0), parameterization_on_v_coeff_b(0) {} + void serializeUVParameterization(PRCbitStream &pbs); + bool swap_uv; + PRCDomain uv_domain; + double parameterization_on_u_coeff_a; + double parameterization_on_v_coeff_a; + double parameterization_on_u_coeff_b; + double parameterization_on_v_coeff_b; +}; + +class PRCControlPoint +{ +public: + PRCControlPoint() : + x(0), y(0), z(0), w(1) {} + PRCControlPoint(double X, double Y, double Z=0, double W=1) : + x(X), y(Y), z(Z), w(W) {} + PRCControlPoint(const PRCVector3d &v) : + x(v.x), y(v.y), z(v.z), w(1) {} + void Set(double fx, double fy, double fz, double fw=1) + { x = fx; y = fy; z = fz; w = fw; } + double x; + double y; + double z; + double w; +}; + +class PRCContentSurface: public PRCBaseGeometry +{ +public: + PRCContentSurface() : + PRCBaseGeometry(), extend_info(KEPRCExtendTypeNone) {} + PRCContentSurface(std::string n) : + PRCBaseGeometry(&EMPTY_ATTRIBUTES,n,makeCADID()),extend_info(KEPRCExtendTypeNone) {} + void serializeContentSurface(PRCbitStream&); + EPRCExtendType extend_info; +}; + +class PRCSurface : public PRCContentSurface +{ +public: + PRCSurface() : + PRCContentSurface() {} + PRCSurface(std::string n) : + PRCContentSurface(n) {} + virtual void serializeSurface(PRCbitStream &pbs) = 0; +}; +typedef std::tr1::shared_ptr <PRCSurface> PRCpSurface; +typedef std::vector <PRCpSurface> PRCSurfaceList; + +class PRCNURBSSurface : public PRCSurface +{ +public: + PRCNURBSSurface() : + PRCSurface(), knot_type(KEPRCKnotTypeUnspecified), surface_form(KEPRCBSplineSurfaceFormUnspecified) {} + PRCNURBSSurface(std::string n) : + PRCSurface(n), knot_type(KEPRCKnotTypeUnspecified), surface_form(KEPRCBSplineSurfaceFormUnspecified) {} + void serializeNURBSSurface(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeNURBSSurface(pbs); } + bool is_rational; + uint32_t degree_in_u; + uint32_t degree_in_v; + std::vector<PRCControlPoint> control_point; + std::vector<double> knot_u; + std::vector<double> knot_v; + const EPRCKnotType knot_type; + const EPRCBSplineSurfaceForm surface_form; +}; + +class PRCContentCurve: public PRCBaseGeometry +{ +public: + PRCContentCurve() : + PRCBaseGeometry(), extend_info(KEPRCExtendTypeNone), is_3d(true) {} + PRCContentCurve(std::string n) : + PRCBaseGeometry(&EMPTY_ATTRIBUTES,n,makeCADID()),extend_info(KEPRCExtendTypeNone), is_3d(true) {} + void serializeContentCurve(PRCbitStream&); + EPRCExtendType extend_info; + bool is_3d; +}; + +class PRCCurve : public PRCContentCurve +{ +public: + PRCCurve() : + PRCContentCurve() {} + PRCCurve(std::string n) : + PRCContentCurve(n) {} + virtual void serializeCurve(PRCbitStream &pbs) = 0; +}; +typedef std::tr1::shared_ptr <PRCCurve> PRCpCurve; +typedef std::vector <PRCpCurve> PRCCurveList; + +class PRCNURBSCurve : public PRCCurve +{ +public: + PRCNURBSCurve() : + PRCCurve(), knot_type(KEPRCKnotTypeUnspecified), curve_form(KEPRCBSplineCurveFormUnspecified) {} + PRCNURBSCurve(std::string n) : + PRCCurve(n), knot_type(KEPRCKnotTypeUnspecified), curve_form(KEPRCBSplineCurveFormUnspecified) {} + void serializeNURBSCurve(PRCbitStream &pbs); + void serializeCurve(PRCbitStream &pbs) { serializeNURBSCurve(pbs); } + bool is_rational; + uint32_t degree; + std::vector<PRCControlPoint> control_point; + std::vector<double> knot; + const EPRCKnotType knot_type; + const EPRCBSplineCurveForm curve_form; +}; + +class PRCPolyLine : public PRCCurve, public PRCTransformation, public PRCParameterization +{ +public: + PRCPolyLine() : + PRCCurve() {} + PRCPolyLine(std::string n) : + PRCCurve(n) {} + void serializePolyLine(PRCbitStream &pbs); + void serializeCurve(PRCbitStream &pbs) { serializePolyLine(pbs); } + std::vector<PRCVector3d> point; +}; + +class PRCCircle : public PRCCurve, public PRCTransformation, public PRCParameterization +{ +public: + PRCCircle() : + PRCCurve(), PRCParameterization(0,2*pi) {} + PRCCircle(std::string n) : + PRCCurve(n), PRCParameterization(0,2*pi) {} + void serializeCircle(PRCbitStream &pbs); + void serializeCurve(PRCbitStream &pbs) { serializeCircle(pbs); } + double radius; +}; + +class PRCComposite : public PRCCurve, public PRCTransformation, public PRCParameterization +{ +public: + PRCComposite() : + PRCCurve() {} + PRCComposite(std::string n) : + PRCCurve(n) {} + void serializeComposite(PRCbitStream &pbs); + void serializeCurve(PRCbitStream &pbs) { serializeComposite(pbs); } + PRCCurveList base_curve; + std::vector<bool> base_sense; + bool is_closed; +}; + +class PRCBlend01 : public PRCSurface, public PRCTransformation, public PRCUVParameterization +{ +public: + PRCBlend01() : + PRCSurface() {} + PRCBlend01(std::string n) : + PRCSurface(n) {} + void serializeBlend01(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeBlend01(pbs); } + void setCenterCurve(PRCCurve *curve) { center_curve.reset(curve); } + void setOriginCurve(PRCCurve *curve) { origin_curve.reset(curve); } + void setTangentCurve(PRCCurve *curve) { tangent_curve.reset(curve); } + PRCpCurve center_curve; + PRCpCurve origin_curve; + PRCpCurve tangent_curve; +}; + +class PRCRuled : public PRCSurface, public PRCTransformation, public PRCUVParameterization +{ +public: + PRCRuled() : + PRCSurface() {} + PRCRuled(std::string n) : + PRCSurface(n) {} + void serializeRuled(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeRuled(pbs); } + void setFirstCurve(PRCCurve *curve) { first_curve.reset(curve); } + void setSecondCurve(PRCCurve *curve) { second_curve.reset(curve); } + PRCpCurve first_curve; + PRCpCurve second_curve; +}; + +class PRCSphere : public PRCSurface, public PRCTransformation, public PRCUVParameterization +{ +public: + PRCSphere() : + PRCSurface() {} + PRCSphere(std::string n) : + PRCSurface(n) {} + void serializeSphere(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeSphere(pbs); } + double radius; +}; + +class PRCCylinder : public PRCSurface, public PRCTransformation, public PRCUVParameterization +{ +public: + PRCCylinder() : + PRCSurface() {} + PRCCylinder(std::string n) : + PRCSurface(n) {} + void serializeCylinder(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeCylinder(pbs); } + double radius; +}; + +class PRCTorus : public PRCSurface, public PRCTransformation, public PRCUVParameterization +{ +public: + PRCTorus() : + PRCSurface() {} + PRCTorus(std::string n) : + PRCSurface(n) {} + void serializeTorus(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeTorus(pbs); } + double major_radius; + double minor_radius; +}; + +class PRCBaseTopology +{ +public: + PRCBaseTopology() : + base_information(false),attributes(NULL),identifier(0) {} + PRCBaseTopology(Attributes *a, std::string n="", uint32_t id = 0) : + base_information(true),attributes(a),name(n),identifier(id) {} + void serializeBaseTopology(PRCbitStream&); + bool base_information; + Attributes *attributes; + std::string name; + uint32_t identifier; +}; + +class PRCTopoItem +{ +public: + virtual void serializeTopoItem(PRCbitStream&)=0; +}; +typedef std::tr1::shared_ptr <PRCTopoItem> PRCpTopoItem; + +class PRCContentBody: public PRCBaseTopology +{ +public: + PRCContentBody() : + PRCBaseTopology(), behavior(0) {} + PRCContentBody(std::string n) : + PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), behavior(0) {} + void serializeContentBody(PRCbitStream&); + uint8_t behavior; +}; + +class PRCBody : public PRCContentBody, public PRCTopoItem +{ +public: + PRCBody() : + PRCContentBody(), topo_item_type(PRC_TYPE_ROOT) {} + PRCBody(uint32_t tit) : + PRCContentBody(), topo_item_type(tit) {} + PRCBody(uint32_t tit, std::string n) : + PRCContentBody(n), topo_item_type(tit) {} + virtual void serializeBody(PRCbitStream &pbs) = 0; + void serializeTopoItem(PRCbitStream &pbs) { serializeBody(pbs); } + uint32_t serialType() { return topo_item_type; } + virtual double serialTolerance() { return 0; } + const uint32_t topo_item_type; +}; +typedef std::tr1::shared_ptr <PRCBody> PRCpBody; +typedef std::vector <PRCpBody> PRCBodyList; + +class PRCContentWireEdge : public PRCBaseTopology +{ +public: + PRCContentWireEdge() : + PRCBaseTopology(), has_curve_trim_interval(false) {} + PRCContentWireEdge(std::string n) : + PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), has_curve_trim_interval(false) {} + void serializeContentWireEdge(PRCbitStream &pbs); + void setCurve(PRCCurve *pCurve) { curve_3d.reset(pCurve); } + void setCurve(PRCpCurve pCurve) { curve_3d = pCurve; } + PRCpCurve curve_3d; + bool has_curve_trim_interval; + PRCInterval curve_trim_interval; +}; + +class PRCWireEdge : public PRCContentWireEdge, public PRCTopoItem +{ +public: + void serializeWireEdge(PRCbitStream &pbs); + void serializeTopoItem(PRCbitStream &pbs) { serializeWireEdge(pbs); } +}; + +class PRCSingleWireBody : public PRCBody +{ +public: + PRCSingleWireBody() : + PRCBody(PRC_TYPE_TOPO_SingleWireBody) {} + PRCSingleWireBody(std::string n) : + PRCBody(PRC_TYPE_TOPO_SingleWireBody, n) {} + void serializeSingleWireBody(PRCbitStream &pbs); + void serializeBody(PRCbitStream &pbs) { serializeSingleWireBody(pbs); } + void setWireEdge(PRCWireEdge *wireEdge); +// void setEdge(const PRCEdge &edge); + PRCpTopoItem wire_edge; +}; + +class PRCFace : public PRCBaseTopology, public PRCTopoItem, public PRCGraphics +{ +public: + PRCFace() : + PRCBaseTopology(), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {} + PRCFace(std::string n) : + PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {} + void serializeFace(PRCbitStream &pbs); + void serializeTopoItem(PRCbitStream &pbs) { serializeFace(pbs); } + void setSurface(PRCSurface *pSurface) { base_surface.reset(pSurface); } + PRCpSurface base_surface; + const bool have_surface_trim_domain; + PRCDomain surface_trim_domain; + const bool have_tolerance; + const double tolerance; + const uint32_t number_of_loop; + const int32_t outer_loop_index; +// PRCLoopList loop; +}; +typedef std::tr1::shared_ptr <PRCFace> PRCpFace; +typedef std::vector <PRCpFace> PRCFaceList; + +class PRCShell : public PRCBaseTopology, public PRCTopoItem +{ +public: + PRCShell() : + PRCBaseTopology(), shell_is_closed(false) {} + PRCShell(std::string n) : + PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), shell_is_closed(false) {} + void serializeShell(PRCbitStream &pbs); + void serializeTopoItem(PRCbitStream &pbs) { serializeShell(pbs); } + void addFace(PRCFace *pFace, uint8_t orientation=2); + void addFace(const PRCpFace &pFace, uint8_t orientation=2); + bool shell_is_closed; + PRCFaceList face; + std::vector<uint8_t> orientation_surface_with_shell; +}; +typedef std::tr1::shared_ptr <PRCShell> PRCpShell; +typedef std::vector <PRCpShell> PRCShellList; + +class PRCConnex : public PRCBaseTopology, public PRCTopoItem +{ +public: + PRCConnex() : + PRCBaseTopology() {} + PRCConnex(std::string n) : + PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()) {} + void serializeConnex(PRCbitStream &pbs); + void serializeTopoItem(PRCbitStream &pbs) { serializeConnex(pbs); } + void addShell(PRCShell *pShell); + PRCShellList shell; +}; +typedef std::tr1::shared_ptr <PRCConnex> PRCpConnex; +typedef std::vector <PRCpConnex> PRCConnexList; + +class PRCBrepData : public PRCBody, public PRCBoundingBox +{ +public: + PRCBrepData() : + PRCBody(PRC_TYPE_TOPO_BrepData) {} + PRCBrepData(std::string n) : + PRCBody(PRC_TYPE_TOPO_BrepData, n) {} + void serializeBrepData(PRCbitStream &pbs); + void serializeBody(PRCbitStream &pbs) { serializeBrepData(pbs); } + void addConnex(PRCConnex *pConnex); + PRCConnexList connex; +}; + +// For now - treat just the case of Bezier surfaces cubic 4x4 or linear 2x2 +class PRCCompressedFace : public PRCBaseTopology, public PRCGraphics +{ +public: + PRCCompressedFace() : + PRCBaseTopology(), orientation_surface_with_shell(true), degree(0) {} + PRCCompressedFace(std::string n) : + PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), orientation_surface_with_shell(true), degree(0) {} + void serializeCompressedFace(PRCbitStream &pbs, double brep_data_compressed_tolerance); + void serializeContentCompressedFace(PRCbitStream &pbs); + void serializeCompressedAnaNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance); + void serializeCompressedNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance); + bool orientation_surface_with_shell; + uint32_t degree; + std::vector<PRCVector3d> control_point; +}; +typedef std::tr1::shared_ptr <PRCCompressedFace> PRCpCompressedFace; +typedef std::vector <PRCpCompressedFace> PRCCompressedFaceList; + +// For now - treat just the case of one connex/one shell +class PRCCompressedBrepData : public PRCBody +{ +public: + PRCCompressedBrepData() : + PRCBody(PRC_TYPE_TOPO_BrepDataCompress), serial_tolerance(0), brep_data_compressed_tolerance(0) {} + PRCCompressedBrepData(std::string n) : + PRCBody(PRC_TYPE_TOPO_BrepDataCompress, n), serial_tolerance(0), brep_data_compressed_tolerance(0) {} + void serializeCompressedBrepData(PRCbitStream &pbs); + void serializeBody(PRCbitStream &pbs) { serializeCompressedBrepData(pbs); } + void serializeCompressedShell(PRCbitStream &pbs); + double serialTolerance() { return serial_tolerance; } + double serial_tolerance; + double brep_data_compressed_tolerance; + PRCCompressedFaceList face; +}; + +class PRCTopoContext : public ContentPRCBase +{ +public: + PRCTopoContext(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n), behaviour(0), /* granularity(0), */ tolerance(0), + have_smallest_face_thickness(false), smallest_thickness(0), have_scale(false), scale(1) {} + void serializeTopoContext(PRCbitStream&); + void serializeContextAndBodies(PRCbitStream&); + void serializeGeometrySummary(PRCbitStream&); + void serializeContextGraphics(PRCbitStream&); + uint32_t addSingleWireBody(PRCSingleWireBody *body); + uint32_t addBrepData(PRCBrepData *body); + uint32_t addCompressedBrepData(PRCCompressedBrepData *body); + uint8_t behaviour; + double granularity; + double tolerance; + bool have_smallest_face_thickness; + double smallest_thickness; + bool have_scale; + double scale; + PRCBodyList body; +}; +typedef std::tr1::shared_ptr <PRCTopoContext> PRCpTopoContext; +typedef std::vector <PRCpTopoContext> PRCTopoContextList; + +class PRCUniqueId +{ +public: + PRCUniqueId() : unique_id0(0), unique_id1(0), unique_id2(0), unique_id3(0) {} + void serializeCompressedUniqueId(PRCbitStream&); + uint32_t unique_id0; + uint32_t unique_id1; + uint32_t unique_id2; + uint32_t unique_id3; +}; + +class PRCUnit +{ +public: + PRCUnit() : unit_from_CAD_file(false), unit(1) {} + void serializeUnit(PRCbitStream&); + bool unit_from_CAD_file; + double unit; +}; + +class PRCProductOccurrence: public PRCGraphics, public ContentPRCBase +{ +public: + PRCProductOccurrence(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), + index_part(m1), + index_prototype(m1), prototype_in_same_file_structure(true), + index_external_data(m1), external_data_in_same_file_structure(true), + product_behaviour(0), product_information_flags(0), product_load_status(KEPRCProductLoadStatus_Loaded), + has_location(false) {} + void serializeProductOccurrence(PRCbitStream&); + uint32_t index_part; + uint32_t index_prototype; + bool prototype_in_same_file_structure; + PRCUniqueId prototype_file_structure; + uint32_t index_external_data; + bool external_data_in_same_file_structure; + PRCUniqueId external_data_file_structure; + std::vector<uint32_t> index_son_occurrence; + uint8_t product_behaviour; + PRCUnit unit_information; + uint8_t product_information_flags; + EPRCProductLoadStatus product_load_status; + bool has_location; + PRCpGeneralTransformation3d location; +}; +typedef std::tr1::shared_ptr <PRCProductOccurrence> PRCpProductOccurrence; +typedef std::vector <PRCpProductOccurrence> PRCProductOccurrenceList; + +class PRCPartDefinition: public PRCGraphics, public ContentPRCBase, public PRCBoundingBox +{ +public: + PRCPartDefinition(std::string n="") : + ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()) {} + void serializePartDefinition(PRCbitStream&); + uint32_t addBrepModel(PRCBrepModel *pBrepModel); + uint32_t addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel); + uint32_t addPointSet(PRCPointSet *pPointSet); + uint32_t addSet(PRCSet *pSet); + uint32_t addWire(PRCWire *pWire); + uint32_t addPolyWire(PRCPolyWire *pPolyWire); + uint32_t addRepresentationItem(PRCRepresentationItem *pRepresentationItem); + uint32_t addRepresentationItem(PRCpRepresentationItem pRepresentationItem); + PRCRepresentationItemList representation_item; +}; +typedef std::tr1::shared_ptr <PRCPartDefinition> PRCpPartDefinition; +typedef std::vector <PRCpPartDefinition> PRCPartDefinitionList; #endif //__WRITE_PRC_H diff --git a/Build/source/utils/asymptote/prcfile.h b/Build/source/utils/asymptote/prcfile.h index 0dffdbb182a..168f1eb0bf4 100644 --- a/Build/source/utils/asymptote/prcfile.h +++ b/Build/source/utils/asymptote/prcfile.h @@ -6,8 +6,6 @@ namespace camp { -const double scale3D=1.0/settings::cm; - inline RGBAColour rgba(pen p) { p.convert(); p.torgb(); @@ -15,70 +13,8 @@ inline RGBAColour rgba(pen p) { } class prcfile : public oPRCFile { - std::list<PRCentity *> entities; public: prcfile(string name) : oPRCFile(name.c_str()) {} - ~prcfile() { - - for(std::list<PRCentity *>::iterator p=entities.begin(); - p != entities.end(); ++p) { - assert(*p); - delete *p; - } - } - - void add(PRCentity* e) { - entities.push_back(e); - oPRCFile::add(e); - } -}; - -inline void writeBezierKnots(PRCbitStream &out, uint32_t d, uint32_t n) -{ - out << (double) 1; - uint32_t stop=d+n; - for(uint32_t i=1; i < stop; ++i) - out << (double) ((i+2)/d); // integer division is intentional - out << (double) ((stop+1)/d); -} - -class PRCBezierCurve : public PRCcurve -{ - uint32_t d; - uint32_t n; -public: - PRCBezierCurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3], - const RGBAColour &c, string name="") : - PRCcurve(p,d,n,cP,NULL,c,scale3D,false,NULL,name.c_str()), d(d), n(n) {} - PRCBezierCurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3], - const PRCMaterial &m, string name="") : - PRCcurve(p,d,n,cP,NULL,m,scale3D,false,NULL,name.c_str()), d(d), n(n) {} -private: - void writeKnots(PRCbitStream &out) { - writeBezierKnots(out,d,n); - } -}; - -class PRCBezierSurface : public PRCsurface -{ - uint32_t dU,dV; - uint32_t nU,nV; -public: - PRCBezierSurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU, - uint32_t nV, double cP[][3], const RGBAColour &c, - double g=0.0, string name="") : - PRCsurface(p,dU,dV,nU,nV,cP,NULL,NULL,c,scale3D,false,NULL,g,name.c_str()), - dU(dU), dV(dV), nU(nU), nV(nV) {} - PRCBezierSurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU, - uint32_t nV, double cP[][3], const PRCMaterial &m, - double g=0.0, string name="") : - PRCsurface(p,dU,dV,nU,nV,cP,NULL,NULL,m,scale3D,false,NULL,g,name.c_str()), - dU(dU), dV(dV), nU(nU), nV(nV) {} -private: - void writeKnots(PRCbitStream &out) { - writeBezierKnots(out,dU,nU); - writeBezierKnots(out,dV,nV); - } }; } //namespace camp diff --git a/Build/source/utils/asymptote/primitives.h b/Build/source/utils/asymptote/primitives.h index 52b3ebcefa4..cbf37601c70 100644 --- a/Build/source/utils/asymptote/primitives.h +++ b/Build/source/utils/asymptote/primitives.h @@ -16,6 +16,7 @@ // contexts. PRIMITIVE(void,Void,void) +PRIMITIVE(inferred,Inferred,var) /* null is not a primitive type. */ #ifdef PRIMERROR PRIMITIVE(error,Error,<error>) diff --git a/Build/source/utils/asymptote/quaternion.cc b/Build/source/utils/asymptote/quaternion.cc index f492137c267..7f3eaf5f65b 100644 --- a/Build/source/utils/asymptote/quaternion.cc +++ b/Build/source/utils/asymptote/quaternion.cc @@ -200,9 +200,12 @@ void quat::set_angle(float f) { vec3 axis = get_axis(); - s = (float) cos( DEG2RAD( f ) / 2.0 ); + static const double halfradians=acos(-1.0)/360.0; + f *= halfradians; + + s = (float) cos( f ); - v = axis * (float) sin(DEG2RAD(f) / 2.0); + v = axis * (float) sin( f ); } /********************************************** scale_angle() ************/ @@ -218,7 +221,8 @@ void quat::scale_angle(float f) float quat::get_angle() const { - return (float) RAD2DEG( 2.0 * acos( s ) ); + static const double degrees2=360.0/acos(-1.0); + return (float) (acos( s ) * degrees2); } /********************************************* get_axis() **************/ diff --git a/Build/source/utils/asymptote/runarray.cc b/Build/source/utils/asymptote/runarray.cc index 257464d3bb9..0ae52bcf918 100644 --- a/Build/source/utils/asymptote/runarray.cc +++ b/Build/source/utils/asymptote/runarray.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -528,6 +529,8 @@ void integeroverflow(size_t i) +#include "runarray.symbols.h" + namespace run { // Create an empty array. #line 444 "runarray.in" @@ -1991,8 +1994,8 @@ void gen_runarray65(stack *Stack) #ifdef HAVE_LIBFFTW3 array *c=new array(n); if(n) { - Complex *f=ComplexAlign(n); - fft1d Forward(n,intcast(sign),f); + Complex *f=fftwpp::ComplexAlign(n); + fftwpp::fft1d Forward(n,intcast(sign),f); for(size_t i=0; i < n; i++) { pair z=read<pair>(a,i); @@ -2004,7 +2007,7 @@ void gen_runarray65(stack *Stack) Complex z=f[i]; (*c)[i]=pair(z.real(),z.imag()); } - deleteAlign(f); + fftwpp::deleteAlign(f); } #else unused(&n); @@ -2299,21 +2302,21 @@ void gen_runarray_venv(venv &ve) #line 717 "runarray.in" REGISTER_BLTIN(run::arrayIntArray,"arrayIntArray"); #line 735 "runarray.in" - addFunc(ve, run::gen_runarray31, IntArray(), "complement", formal(IntArray(), "a", false, false), formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runarray31, IntArray(), SYM(complement), formal(IntArray(), SYM(a), false, false), formal(primInt(), SYM(n), false, false)); #line 754 "runarray.in" REGISTER_BLTIN(run::arraySequence,"arraySequence"); #line 767 "runarray.in" - addFunc(ve, run::gen_runarray33, IntArray(), "sequence", formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runarray33, IntArray(), SYM(sequence), formal(primInt(), SYM(n), false, false)); #line 778 "runarray.in" REGISTER_BLTIN(run::arrayFunction,"arrayFunction"); #line 791 "runarray.in" REGISTER_BLTIN(run::arraySort,"arraySort"); #line 800 "runarray.in" - addFunc(ve, run::gen_runarray36, primBoolean(), "all", formal(booleanArray(), "a", false, false)); + addFunc(ve, run::gen_runarray36, primBoolean(), SYM(all), formal(booleanArray(), SYM(a), false, false)); #line 809 "runarray.in" - addFunc(ve, run::gen_runarray37, booleanArray(), "!", formal(booleanArray(), "a", false, false)); + addFunc(ve, run::gen_runarray37, booleanArray(), SYM_LOGNOT, formal(booleanArray(), SYM(a), false, false)); #line 818 "runarray.in" - addFunc(ve, run::gen_runarray38, primInt(), "sum", formal(booleanArray(), "a", false, false)); + addFunc(ve, run::gen_runarray38, primInt(), SYM(sum), formal(booleanArray(), SYM(a), false, false)); #line 827 "runarray.in" REGISTER_BLTIN(run::arrayCopy,"arrayCopy"); #line 832 "runarray.in" @@ -2327,67 +2330,67 @@ void gen_runarray_venv(venv &ve) #line 894 "runarray.in" REGISTER_BLTIN(run::array3Transpose,"array3Transpose"); #line 981 "runarray.in" - addFunc(ve, run::gen_runarray45, primInt(), "find", formal(booleanArray(), "a", false, false), formal(primInt(), "n", true, false)); + addFunc(ve, run::gen_runarray45, primInt(), SYM(find), formal(booleanArray(), SYM(a), false, false), formal(primInt(), SYM(n), true, false)); #line 1000 "runarray.in" REGISTER_BLTIN(run::arrayConditional,"arrayConditional"); #line 1026 "runarray.in" - addFunc(ve, run::gen_runarray47, realArray2(), "identity", formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runarray47, realArray2(), SYM(identity), formal(primInt(), SYM(n), false, false)); #line 1032 "runarray.in" - addFunc(ve, run::gen_runarray48, realArray2(), "inverse", formal(realArray2(), "a", false, false)); + addFunc(ve, run::gen_runarray48, realArray2(), SYM(inverse), formal(realArray2(), SYM(a), false, false)); #line 1124 "runarray.in" - addFunc(ve, run::gen_runarray49, realArray(), "solve", formal(realArray2(), "a", false, false), formal(realArray(), "b", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runarray49, realArray(), SYM(solve), formal(realArray2(), SYM(a), false, false), formal(realArray(), SYM(b), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 1177 "runarray.in" - addFunc(ve, run::gen_runarray50, realArray2(), "solve", formal(realArray2(), "a", false, false), formal(realArray2(), "b", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runarray50, realArray2(), SYM(solve), formal(realArray2(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 1242 "runarray.in" - addFunc(ve, run::gen_runarray51, primReal(), "determinant", formal(realArray2(), "a", false, false)); + addFunc(ve, run::gen_runarray51, primReal(), SYM(determinant), formal(realArray2(), SYM(a), false, false)); #line 1259 "runarray.in" - addFunc(ve, run::gen_runarray52, realArray(), "*", formal(realArray2(), "a", false, false), formal(realArray(), "b", false, false)); + addFunc(ve, run::gen_runarray52, realArray(), SYM_TIMES, formal(realArray2(), SYM(a), false, false), formal(realArray(), SYM(b), false, false)); #line 1278 "runarray.in" - addFunc(ve, run::gen_runarray53, realArray(), "*", formal(realArray(), "a", false, false), formal(realArray2(), "b", false, false)); + addFunc(ve, run::gen_runarray53, realArray(), SYM_TIMES, formal(realArray(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false)); #line 1307 "runarray.in" - addFunc(ve, run::gen_runarray54, IntArray2(), "*", formal(IntArray2(), "a", false, false), formal(IntArray2(), "b", false, false)); + addFunc(ve, run::gen_runarray54, IntArray2(), SYM_TIMES, formal(IntArray2(), SYM(a), false, false), formal(IntArray2(), SYM(b), false, false)); #line 1312 "runarray.in" - addFunc(ve, run::gen_runarray55, realArray2(), "*", formal(realArray2(), "a", false, false), formal(realArray2(), "b", false, false)); + addFunc(ve, run::gen_runarray55, realArray2(), SYM_TIMES, formal(realArray2(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false)); #line 1317 "runarray.in" - addFunc(ve, run::gen_runarray56, pairArray2(), "*", formal(pairArray2(), "a", false, false), formal(pairArray2(), "b", false, false)); + addFunc(ve, run::gen_runarray56, pairArray2(), SYM_TIMES, formal(pairArray2(), SYM(a), false, false), formal(pairArray2(), SYM(b), false, false)); #line 1322 "runarray.in" - addFunc(ve, run::gen_runarray57, primTriple(), "*", formal(realArray2(), "t", false, false), formal(primTriple(), "v", false, false)); + addFunc(ve, run::gen_runarray57, primTriple(), SYM_TIMES, formal(realArray2(), SYM(t), false, false), formal(primTriple(), SYM(v), false, false)); #line 1327 "runarray.in" - addFunc(ve, run::gen_runarray58, primPair(), "project", formal(primTriple(), "v", false, false), formal(realArray2(), "t", false, false)); + addFunc(ve, run::gen_runarray58, primPair(), SYM(project), formal(primTriple(), SYM(v), false, false), formal(realArray2(), SYM(t), false, false)); #line 1352 "runarray.in" - addFunc(ve, run::gen_runarray59, primReal(), "dot", formal(realArray(), "a", false, false), formal(realArray(), "b", false, false)); + addFunc(ve, run::gen_runarray59, primReal(), SYM(dot), formal(realArray(), SYM(a), false, false), formal(realArray(), SYM(b), false, false)); #line 1362 "runarray.in" - addFunc(ve, run::gen_runarray60, primPair(), "dot", formal(pairArray(), "a", false, false), formal(pairArray(), "b", false, false)); + addFunc(ve, run::gen_runarray60, primPair(), SYM(dot), formal(pairArray(), SYM(a), false, false), formal(pairArray(), SYM(b), false, false)); #line 1372 "runarray.in" - addFunc(ve, run::gen_runarray61, realArray(), "tridiagonal", formal(realArray(), "a", false, false), formal(realArray(), "b", false, false), formal(realArray(), "c", false, false), formal(realArray(), "f", false, false)); + addFunc(ve, run::gen_runarray61, realArray(), SYM(tridiagonal), formal(realArray(), SYM(a), false, false), formal(realArray(), SYM(b), false, false), formal(realArray(), SYM(c), false, false), formal(realArray(), SYM(f), false, false)); #line 1476 "runarray.in" - addFunc(ve, run::gen_runarray62, primReal(), "newton", formal(primInt(), "iterations", true, false), formal(realRealFunction(), "f", false, false), formal(realRealFunction(), "fprime", false, false), formal(primReal(), "x", false, false), formal(primBoolean(), "verbose", true, false)); + addFunc(ve, run::gen_runarray62, primReal(), SYM(newton), formal(primInt(), SYM(iterations), true, false), formal(realRealFunction(), SYM(f), false, false), formal(realRealFunction(), SYM(fprime), false, false), formal(primReal(), SYM(x), false, false), formal(primBoolean(), SYM(verbose), true, false)); #line 1523 "runarray.in" - addFunc(ve, run::gen_runarray63, primReal(), "newton", formal(primInt(), "iterations", true, false), formal(realRealFunction(), "f", false, false), formal(realRealFunction(), "fprime", false, false), formal(primReal(), "x1", false, false), formal(primReal(), "x2", false, false), formal(primBoolean(), "verbose", true, false)); + addFunc(ve, run::gen_runarray63, primReal(), SYM(newton), formal(primInt(), SYM(iterations), true, false), formal(realRealFunction(), SYM(f), false, false), formal(realRealFunction(), SYM(fprime), false, false), formal(primReal(), SYM(x1), false, false), formal(primReal(), SYM(x2), false, false), formal(primBoolean(), SYM(verbose), true, false)); #line 1605 "runarray.in" - addFunc(ve, run::gen_runarray64, primReal(), "simpson", formal(realRealFunction(), "f", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "acc", true, false), formal(primReal(), "dxmax", true, false)); + addFunc(ve, run::gen_runarray64, primReal(), SYM(simpson), formal(realRealFunction(), SYM(f), false, false), formal(primReal(), SYM(a), false, false), formal(primReal(), SYM(b), false, false), formal(primReal(), SYM(acc), true, false), formal(primReal(), SYM(dxmax), true, false)); #line 1617 "runarray.in" - addFunc(ve, run::gen_runarray65, pairArray(), "fft", formal(pairArray(), "a", false, false), formal(primInt(), "sign", true, false)); + addFunc(ve, run::gen_runarray65, pairArray(), SYM(fft), formal(pairArray(), SYM(a), false, false), formal(primInt(), SYM(sign), true, false)); #line 1648 "runarray.in" - addFunc(ve, run::gen_runarray66, IntArray2(), "triangulate", formal(pairArray(), "z", false, false)); + addFunc(ve, run::gen_runarray66, IntArray2(), SYM(triangulate), formal(pairArray(), SYM(z), false, false)); #line 1683 "runarray.in" - addFunc(ve, run::gen_runarray67, primReal(), "norm", formal(realArray(), "a", false, false)); + addFunc(ve, run::gen_runarray67, primReal(), SYM(norm), formal(realArray(), SYM(a), false, false)); #line 1694 "runarray.in" - addFunc(ve, run::gen_runarray68, primReal(), "norm", formal(realArray2(), "a", false, false)); + addFunc(ve, run::gen_runarray68, primReal(), SYM(norm), formal(realArray2(), SYM(a), false, false)); #line 1709 "runarray.in" - addFunc(ve, run::gen_runarray69, primReal(), "norm", formal(tripleArray2(), "a", false, false)); + addFunc(ve, run::gen_runarray69, primReal(), SYM(norm), formal(tripleArray2(), SYM(a), false, false)); #line 1724 "runarray.in" - addFunc(ve, run::gen_runarray70, primReal(), "change2", formal(tripleArray2(), "a", false, false)); + addFunc(ve, run::gen_runarray70, primReal(), SYM(change2), formal(tripleArray2(), SYM(a), false, false)); #line 1746 "runarray.in" - addFunc(ve, run::gen_runarray71, primTriple(), "minbezier", formal(tripleArray2(), "p", false, false), formal(primTriple(), "b", false, false)); + addFunc(ve, run::gen_runarray71, primTriple(), SYM(minbezier), formal(tripleArray2(), SYM(p), false, false), formal(primTriple(), SYM(b), false, false)); #line 1756 "runarray.in" - addFunc(ve, run::gen_runarray72, primTriple(), "maxbezier", formal(tripleArray2(), "p", false, false), formal(primTriple(), "b", false, false)); + addFunc(ve, run::gen_runarray72, primTriple(), SYM(maxbezier), formal(tripleArray2(), SYM(p), false, false), formal(primTriple(), SYM(b), false, false)); #line 1766 "runarray.in" - addFunc(ve, run::gen_runarray73, primPair(), "minratio", formal(tripleArray2(), "p", false, false), formal(primPair(), "b", false, false)); + addFunc(ve, run::gen_runarray73, primPair(), SYM(minratio), formal(tripleArray2(), SYM(p), false, false), formal(primPair(), SYM(b), false, false)); #line 1777 "runarray.in" - addFunc(ve, run::gen_runarray74, primPair(), "maxratio", formal(tripleArray2(), "p", false, false), formal(primPair(), "b", false, false)); + addFunc(ve, run::gen_runarray74, primPair(), SYM(maxratio), formal(tripleArray2(), SYM(p), false, false), formal(primPair(), SYM(b), false, false)); #line 1788 "runarray.in" - addFunc(ve, run::gen_runarray75, realArray(), "_projection"); + addFunc(ve, run::gen_runarray75, realArray(), SYM(_projection)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runarray.in b/Build/source/utils/asymptote/runarray.in index 7e99a875f4b..cf04637ce31 100644 --- a/Build/source/utils/asymptote/runarray.in +++ b/Build/source/utils/asymptote/runarray.in @@ -1621,8 +1621,8 @@ pairarray* fft(pairarray *a, Int sign=1) #ifdef HAVE_LIBFFTW3 array *c=new array(n); if(n) { - Complex *f=ComplexAlign(n); - fft1d Forward(n,intcast(sign),f); + Complex *f=fftwpp::ComplexAlign(n); + fftwpp::fft1d Forward(n,intcast(sign),f); for(size_t i=0; i < n; i++) { pair z=read<pair>(a,i); @@ -1634,7 +1634,7 @@ pairarray* fft(pairarray *a, Int sign=1) Complex z=f[i]; (*c)[i]=pair(z.real(),z.imag()); } - deleteAlign(f); + fftwpp::deleteAlign(f); } #else unused(&n); diff --git a/Build/source/utils/asymptote/runarray.symbols.h b/Build/source/utils/asymptote/runarray.symbols.h new file mode 100644 index 00000000000..08c4fa12f2b --- /dev/null +++ b/Build/source/utils/asymptote/runarray.symbols.h @@ -0,0 +1,59 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(_projection); +ADDSYMBOL(a); +ADDSYMBOL(acc); +ADDSYMBOL(all); +ADDSYMBOL(b); +ADDSYMBOL(c); +ADDSYMBOL(change2); +ADDSYMBOL(complement); +ADDSYMBOL(determinant); +ADDSYMBOL(dot); +ADDSYMBOL(dxmax); +ADDSYMBOL(f); +ADDSYMBOL(fft); +ADDSYMBOL(find); +ADDSYMBOL(fprime); +ADDSYMBOL(identity); +ADDSYMBOL(inverse); +ADDSYMBOL(iterations); +ADDSYMBOL(maxbezier); +ADDSYMBOL(maxratio); +ADDSYMBOL(minbezier); +ADDSYMBOL(minratio); +ADDSYMBOL(n); +ADDSYMBOL(newton); +ADDSYMBOL(norm); +ADDSYMBOL(p); +ADDSYMBOL(project); +ADDSYMBOL(sequence); +ADDSYMBOL(sign); +ADDSYMBOL(simpson); +ADDSYMBOL(solve); +ADDSYMBOL(sum); +ADDSYMBOL(t); +ADDSYMBOL(triangulate); +ADDSYMBOL(tridiagonal); +ADDSYMBOL(v); +ADDSYMBOL(verbose); +ADDSYMBOL(warn); +ADDSYMBOL(x); +ADDSYMBOL(x1); +ADDSYMBOL(x2); +ADDSYMBOL(z); diff --git a/Build/source/utils/asymptote/runbacktrace.cc b/Build/source/utils/asymptote/runbacktrace.cc index 8d8c8ff0447..9e99d5f4864 100644 --- a/Build/source/utils/asymptote/runbacktrace.cc +++ b/Build/source/utils/asymptote/runbacktrace.cc @@ -28,6 +28,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -112,6 +113,8 @@ function *realRealFunction(); +#include "runbacktrace.symbols.h" + namespace run { #line 16 "runbacktrace.in" // void generate_random_backtrace(); @@ -148,9 +151,9 @@ namespace trans { void gen_runbacktrace_venv(venv &ve) { #line 16 "runbacktrace.in" - addFunc(ve, run::gen_runbacktrace0, primVoid(), "generate_random_backtrace"); + addFunc(ve, run::gen_runbacktrace0, primVoid(), SYM(generate_random_backtrace)); #line 25 "runbacktrace.in" - addFunc(ve, run::gen_runbacktrace1, primVoid(), "print_random_addresses", formal(primInt(), "n", true, false)); + addFunc(ve, run::gen_runbacktrace1, primVoid(), SYM(print_random_addresses), formal(primInt(), SYM(n), true, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runbacktrace.symbols.h b/Build/source/utils/asymptote/runbacktrace.symbols.h new file mode 100644 index 00000000000..dbab3fb4c43 --- /dev/null +++ b/Build/source/utils/asymptote/runbacktrace.symbols.h @@ -0,0 +1,20 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(generate_random_backtrace); +ADDSYMBOL(n); +ADDSYMBOL(print_random_addresses); diff --git a/Build/source/utils/asymptote/runfile.cc b/Build/source/utils/asymptote/runfile.cc index 1351be016d1..6cf0636413a 100644 --- a/Build/source/utils/asymptote/runfile.cc +++ b/Build/source/utils/asymptote/runfile.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -120,6 +121,8 @@ string commentchar="#"; +#include "runfile.symbols.h" + namespace run { #line 24 "runfile.in" // bool ==(file *a, file *b); @@ -638,45 +641,45 @@ namespace trans { void gen_runfile_venv(venv &ve) { #line 24 "runfile.in" - addFunc(ve, run::gen_runfile0, primBoolean(), "==", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false)); + addFunc(ve, run::gen_runfile0, primBoolean(), SYM_EQ, formal(primFile(), SYM(a), false, false), formal(primFile(), SYM(b), false, false)); #line 29 "runfile.in" - addFunc(ve, run::gen_runfile1, primBoolean(), "!=", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false)); + addFunc(ve, run::gen_runfile1, primBoolean(), SYM_NEQ, formal(primFile(), SYM(a), false, false), formal(primFile(), SYM(b), false, false)); #line 34 "runfile.in" REGISTER_BLTIN(run::nullFile,"nullFile"); #line 39 "runfile.in" - addFunc(ve, run::gen_runfile3, primFile(), "input", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false), formal(primString() , "comment", true, false)); + addFunc(ve, run::gen_runfile3, primFile(), SYM(input), formal(primString() , SYM(name), false, false), formal(primBoolean(), SYM(check), true, false), formal(primString() , SYM(comment), true, false)); #line 47 "runfile.in" - addFunc(ve, run::gen_runfile4, primFile(), "output", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false), formal(primString() , "comment", true, false)); + addFunc(ve, run::gen_runfile4, primFile(), SYM(output), formal(primString() , SYM(name), false, false), formal(primBoolean(), SYM(update), true, false), formal(primString() , SYM(comment), true, false)); #line 59 "runfile.in" - addFunc(ve, run::gen_runfile5, primFile(), "xinput", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false)); + addFunc(ve, run::gen_runfile5, primFile(), SYM(xinput), formal(primString() , SYM(name), false, false), formal(primBoolean(), SYM(check), true, false)); #line 73 "runfile.in" - addFunc(ve, run::gen_runfile6, primFile(), "xoutput", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false)); + addFunc(ve, run::gen_runfile6, primFile(), SYM(xoutput), formal(primString() , SYM(name), false, false), formal(primBoolean(), SYM(update), true, false)); #line 91 "runfile.in" - addFunc(ve, run::gen_runfile7, primFile(), "binput", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false)); + addFunc(ve, run::gen_runfile7, primFile(), SYM(binput), formal(primString() , SYM(name), false, false), formal(primBoolean(), SYM(check), true, false)); #line 98 "runfile.in" - addFunc(ve, run::gen_runfile8, primFile(), "boutput", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false)); + addFunc(ve, run::gen_runfile8, primFile(), SYM(boutput), formal(primString() , SYM(name), false, false), formal(primBoolean(), SYM(update), true, false)); #line 108 "runfile.in" - addFunc(ve, run::gen_runfile9, primBoolean(), "eof", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile9, primBoolean(), SYM(eof), formal(primFile(), SYM(f), false, false)); #line 113 "runfile.in" - addFunc(ve, run::gen_runfile10, primBoolean(), "eol", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile10, primBoolean(), SYM(eol), formal(primFile(), SYM(f), false, false)); #line 118 "runfile.in" - addFunc(ve, run::gen_runfile11, primBoolean(), "error", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile11, primBoolean(), SYM(error), formal(primFile(), SYM(f), false, false)); #line 123 "runfile.in" - addFunc(ve, run::gen_runfile12, primVoid(), "clear", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile12, primVoid(), SYM(clear), formal(primFile(), SYM(f), false, false)); #line 128 "runfile.in" - addFunc(ve, run::gen_runfile13, primVoid(), "close", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile13, primVoid(), SYM(close), formal(primFile(), SYM(f), false, false)); #line 133 "runfile.in" - addFunc(ve, run::gen_runfile14, primInt(), "precision", formal(primFile(), "f", true, false), formal(primInt(), "digits", true, false)); + addFunc(ve, run::gen_runfile14, primInt(), SYM(precision), formal(primFile(), SYM(f), true, false), formal(primInt(), SYM(digits), true, false)); #line 139 "runfile.in" - addFunc(ve, run::gen_runfile15, primVoid(), "flush", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile15, primVoid(), SYM(flush), formal(primFile(), SYM(f), false, false)); #line 144 "runfile.in" - addFunc(ve, run::gen_runfile16, primString() , "getc", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile16, primString() , SYM(getc), formal(primFile(), SYM(f), false, false)); #line 153 "runfile.in" - addFunc(ve, run::gen_runfile17, primInt(), "tell", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile17, primInt(), SYM(tell), formal(primFile(), SYM(f), false, false)); #line 158 "runfile.in" - addFunc(ve, run::gen_runfile18, primVoid(), "seek", formal(primFile(), "f", false, false), formal(primInt(), "pos", false, false)); + addFunc(ve, run::gen_runfile18, primVoid(), SYM(seek), formal(primFile(), SYM(f), false, false), formal(primInt(), SYM(pos), false, false)); #line 163 "runfile.in" - addFunc(ve, run::gen_runfile19, primVoid(), "seekeof", formal(primFile(), "f", false, false)); + addFunc(ve, run::gen_runfile19, primVoid(), SYM(seekeof), formal(primFile(), SYM(f), false, false)); #line 168 "runfile.in" REGISTER_BLTIN(run::namePart,"namePart"); #line 173 "runfile.in" @@ -728,9 +731,9 @@ void gen_runfile_venv(venv &ve) #line 324 "runfile.in" REGISTER_BLTIN(run::readSet,"readSet"); #line 329 "runfile.in" - addFunc(ve, run::gen_runfile45, primInt(), "delete", formal(primString() , "s", false, false)); + addFunc(ve, run::gen_runfile45, primInt(), SYM(delete), formal(primString() , SYM(s), false, false)); #line 339 "runfile.in" - addFunc(ve, run::gen_runfile46, primInt(), "rename", formal(primString() , "from", false, false), formal(primString() , "to", false, false)); + addFunc(ve, run::gen_runfile46, primInt(), SYM(rename), formal(primString() , SYM(from), false, false), formal(primString() , SYM(to), false, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runfile.symbols.h b/Build/source/utils/asymptote/runfile.symbols.h new file mode 100644 index 00000000000..a1aad5396de --- /dev/null +++ b/Build/source/utils/asymptote/runfile.symbols.h @@ -0,0 +1,48 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(a); +ADDSYMBOL(b); +ADDSYMBOL(binput); +ADDSYMBOL(boutput); +ADDSYMBOL(check); +ADDSYMBOL(clear); +ADDSYMBOL(close); +ADDSYMBOL(comment); +ADDSYMBOL(delete); +ADDSYMBOL(digits); +ADDSYMBOL(eof); +ADDSYMBOL(eol); +ADDSYMBOL(error); +ADDSYMBOL(f); +ADDSYMBOL(flush); +ADDSYMBOL(from); +ADDSYMBOL(getc); +ADDSYMBOL(input); +ADDSYMBOL(name); +ADDSYMBOL(output); +ADDSYMBOL(pos); +ADDSYMBOL(precision); +ADDSYMBOL(rename); +ADDSYMBOL(s); +ADDSYMBOL(seek); +ADDSYMBOL(seekeof); +ADDSYMBOL(tell); +ADDSYMBOL(to); +ADDSYMBOL(update); +ADDSYMBOL(xinput); +ADDSYMBOL(xoutput); diff --git a/Build/source/utils/asymptote/runhistory.cc b/Build/source/utils/asymptote/runhistory.cc index 7bc7d456acf..6e81b00df37 100644 --- a/Build/source/utils/asymptote/runhistory.cc +++ b/Build/source/utils/asymptote/runhistory.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -195,6 +196,8 @@ void cleanup() +#include "runhistory.symbols.h" + namespace run { // Return the last n lines of the history named name. #line 102 "runhistory.in" @@ -341,13 +344,13 @@ namespace trans { void gen_runhistory_venv(venv &ve) { #line 101 "runhistory.in" - addFunc(ve, run::gen_runhistory0, stringArray(), "history", formal(primString() , "name", false, false), formal(primInt(), "n", true, false)); + addFunc(ve, run::gen_runhistory0, stringArray(), SYM(history), formal(primString() , SYM(name), false, false), formal(primInt(), SYM(n), true, false)); #line 134 "runhistory.in" - addFunc(ve, run::gen_runhistory1, stringArray(), "history", formal(primInt(), "n", true, false)); + addFunc(ve, run::gen_runhistory1, stringArray(), SYM(history), formal(primInt(), SYM(n), true, false)); #line 145 "runhistory.in" - addFunc(ve, run::gen_runhistory2, primString() , "readline", formal(primString() , "prompt", true, false), formal(primString() , "name", true, false), formal(primBoolean(), "tabcompletion", true, false)); + addFunc(ve, run::gen_runhistory2, primString() , SYM(readline), formal(primString() , SYM(prompt), true, false), formal(primString() , SYM(name), true, false), formal(primBoolean(), SYM(tabcompletion), true, false)); #line 189 "runhistory.in" - addFunc(ve, run::gen_runhistory3, primVoid(), "saveline", formal(primString() , "name", false, false), formal(primString() , "value", false, false), formal(primBoolean(), "store", true, false)); + addFunc(ve, run::gen_runhistory3, primVoid(), SYM(saveline), formal(primString() , SYM(name), false, false), formal(primString() , SYM(value), false, false), formal(primBoolean(), SYM(store), true, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runhistory.symbols.h b/Build/source/utils/asymptote/runhistory.symbols.h new file mode 100644 index 00000000000..34a82b35f06 --- /dev/null +++ b/Build/source/utils/asymptote/runhistory.symbols.h @@ -0,0 +1,26 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(history); +ADDSYMBOL(n); +ADDSYMBOL(name); +ADDSYMBOL(prompt); +ADDSYMBOL(readline); +ADDSYMBOL(saveline); +ADDSYMBOL(store); +ADDSYMBOL(tabcompletion); +ADDSYMBOL(value); diff --git a/Build/source/utils/asymptote/runlabel.cc b/Build/source/utils/asymptote/runlabel.cc index 7c10a605f33..d77cfa50af1 100644 --- a/Build/source/utils/asymptote/runlabel.cc +++ b/Build/source/utils/asymptote/runlabel.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -266,6 +267,8 @@ array *readpath(const string& psname, bool keep, +#include "runlabel.symbols.h" + namespace run { #line 176 "runlabel.in" // void label(picture *f, string *s, string *size, transform t, pair position, pair align, pen p); @@ -529,17 +532,17 @@ namespace trans { void gen_runlabel_venv(venv &ve) { #line 176 "runlabel.in" - addFunc(ve, run::gen_runlabel0, primVoid(), "label", formal(primPicture(), "f", false, false), formal(primString(), "s", false, false), formal(primString(), "size", false, false), formal(primTransform(), "t", false, false), formal(primPair(), "position", false, false), formal(primPair(), "align", false, false), formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runlabel0, primVoid(), SYM(label), formal(primPicture(), SYM(f), false, false), formal(primString(), SYM(s), false, false), formal(primString(), SYM(size), false, false), formal(primTransform(), SYM(t), false, false), formal(primPair(), SYM(position), false, false), formal(primPair(), SYM(align), false, false), formal(primPen(), SYM(p), false, false)); #line 182 "runlabel.in" - addFunc(ve, run::gen_runlabel1, primBoolean(), "labels", formal(primPicture(), "f", false, false)); + addFunc(ve, run::gen_runlabel1, primBoolean(), SYM(labels), formal(primPicture(), SYM(f), false, false)); #line 187 "runlabel.in" - addFunc(ve, run::gen_runlabel2, realArray(), "texsize", formal(primString(), "s", false, false), formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runlabel2, realArray(), SYM(texsize), formal(primString(), SYM(s), false, false), formal(primPen(), SYM(p), true, false)); #line 207 "runlabel.in" - addFunc(ve, run::gen_runlabel3, pathArray() , "_texpath", formal(primString(), "s", false, false), formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runlabel3, pathArray() , SYM(_texpath), formal(primString(), SYM(s), false, false), formal(primPen(), SYM(p), true, false)); #line 304 "runlabel.in" - addFunc(ve, run::gen_runlabel4, pathArray() , "textpath", formal(primString(), "s", false, false), formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runlabel4, pathArray() , SYM(textpath), formal(primString(), SYM(s), false, false), formal(primPen(), SYM(p), true, false)); #line 374 "runlabel.in" - addFunc(ve, run::gen_runlabel5, pathArray() , "_strokepath", formal(primPath(), "g", false, false), formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runlabel5, pathArray() , SYM(_strokepath), formal(primPath(), SYM(g), false, false), formal(primPen(), SYM(p), true, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runlabel.symbols.h b/Build/source/utils/asymptote/runlabel.symbols.h new file mode 100644 index 00000000000..80ac1d8b97e --- /dev/null +++ b/Build/source/utils/asymptote/runlabel.symbols.h @@ -0,0 +1,31 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(_strokepath); +ADDSYMBOL(_texpath); +ADDSYMBOL(align); +ADDSYMBOL(f); +ADDSYMBOL(g); +ADDSYMBOL(label); +ADDSYMBOL(labels); +ADDSYMBOL(p); +ADDSYMBOL(position); +ADDSYMBOL(s); +ADDSYMBOL(size); +ADDSYMBOL(t); +ADDSYMBOL(texsize); +ADDSYMBOL(textpath); diff --git a/Build/source/utils/asymptote/runmath.cc b/Build/source/utils/asymptote/runmath.cc index ed73781d84e..6bf13e7daba 100644 --- a/Build/source/utils/asymptote/runmath.cc +++ b/Build/source/utils/asymptote/runmath.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -152,241 +153,253 @@ inline Int sgn(double x) return (x > 0.0 ? 1 : (x < 0.0 ? -1 : 0)); } +static bool initializeRandom=true; + +void Srand(Int seed) +{ + initializeRandom=false; + const int n=256; + static char state[n]; + initstate(intcast(seed),state,n); +} + // Autogenerated routines: +#include "runmath.symbols.h" + namespace run { -#line 62 "runmath.in" +#line 72 "runmath.in" // real ^(real x, Int y); void gen_runmath0(stack *Stack) { Int y=vm::pop<Int>(Stack); real x=vm::pop<real>(Stack); -#line 63 "runmath.in" +#line 73 "runmath.in" {Stack->push<real>(pow(x,y)); return;} } -#line 67 "runmath.in" +#line 77 "runmath.in" // pair ^(pair z, Int y); void gen_runmath1(stack *Stack) { Int y=vm::pop<Int>(Stack); pair z=vm::pop<pair>(Stack); -#line 68 "runmath.in" +#line 78 "runmath.in" {Stack->push<pair>(pow(z,y)); return;} } -#line 72 "runmath.in" +#line 82 "runmath.in" // Int quotient(Int x, Int y); void gen_runmath2(stack *Stack) { Int y=vm::pop<Int>(Stack); Int x=vm::pop<Int>(Stack); -#line 73 "runmath.in" +#line 83 "runmath.in" if(y == 0) dividebyzero(); if(y == -1) {Stack->push<Int>(Negate(x)); return;} // Implementation-independent definition of integer division: round down {Stack->push<Int>((x-portableMod(x,y))/y); return;} } -#line 80 "runmath.in" +#line 90 "runmath.in" // Int abs(Int x); void gen_runmath3(stack *Stack) { Int x=vm::pop<Int>(Stack); -#line 81 "runmath.in" +#line 91 "runmath.in" {Stack->push<Int>(Abs(x)); return;} } -#line 85 "runmath.in" +#line 95 "runmath.in" // Int sgn(real x); void gen_runmath4(stack *Stack) { real x=vm::pop<real>(Stack); -#line 86 "runmath.in" +#line 96 "runmath.in" {Stack->push<Int>(sgn(x)); return;} } -#line 90 "runmath.in" +#line 100 "runmath.in" // Int rand(); void gen_runmath5(stack *Stack) { -#line 91 "runmath.in" +#line 101 "runmath.in" + if(initializeRandom) + Srand(1); {Stack->push<Int>(random()); return;} } -#line 95 "runmath.in" +#line 107 "runmath.in" // void srand(Int seed); void gen_runmath6(stack *Stack) { Int seed=vm::pop<Int>(Stack); -#line 96 "runmath.in" - const int n=256; - static char state[n]; - initstate(intcast(seed),state,n); +#line 108 "runmath.in" + Srand(seed); } // a random number uniformly distributed in the interval [0,1] -#line 103 "runmath.in" +#line 113 "runmath.in" // real unitrand(); void gen_runmath7(stack *Stack) { -#line 104 "runmath.in" +#line 114 "runmath.in" {Stack->push<real>(((real) random())/RAND_MAX); return;} } -#line 108 "runmath.in" +#line 118 "runmath.in" // Int ceil(real x); void gen_runmath8(stack *Stack) { real x=vm::pop<real>(Stack); -#line 109 "runmath.in" +#line 119 "runmath.in" {Stack->push<Int>(Intcast(ceil(x))); return;} } -#line 113 "runmath.in" +#line 123 "runmath.in" // Int floor(real x); void gen_runmath9(stack *Stack) { real x=vm::pop<real>(Stack); -#line 114 "runmath.in" +#line 124 "runmath.in" {Stack->push<Int>(Intcast(floor(x))); return;} } -#line 118 "runmath.in" +#line 128 "runmath.in" // Int round(real x); void gen_runmath10(stack *Stack) { real x=vm::pop<real>(Stack); -#line 119 "runmath.in" +#line 129 "runmath.in" if(validInt(x)) {Stack->push<Int>(Round(x)); return;} integeroverflow(0); } -#line 124 "runmath.in" +#line 134 "runmath.in" // Int Ceil(real x); void gen_runmath11(stack *Stack) { real x=vm::pop<real>(Stack); -#line 125 "runmath.in" +#line 135 "runmath.in" {Stack->push<Int>(Ceil(x)); return;} } -#line 129 "runmath.in" +#line 139 "runmath.in" // Int Floor(real x); void gen_runmath12(stack *Stack) { real x=vm::pop<real>(Stack); -#line 130 "runmath.in" +#line 140 "runmath.in" {Stack->push<Int>(Floor(x)); return;} } -#line 134 "runmath.in" +#line 144 "runmath.in" // Int Round(real x); void gen_runmath13(stack *Stack) { real x=vm::pop<real>(Stack); -#line 135 "runmath.in" +#line 145 "runmath.in" {Stack->push<Int>(Round(Intcap(x))); return;} } -#line 139 "runmath.in" +#line 149 "runmath.in" // real fmod(real x, real y); void gen_runmath14(stack *Stack) { real y=vm::pop<real>(Stack); real x=vm::pop<real>(Stack); -#line 140 "runmath.in" +#line 150 "runmath.in" if (y == 0.0) dividebyzero(); {Stack->push<real>(fmod(x,y)); return;} } -#line 145 "runmath.in" +#line 155 "runmath.in" // real atan2(real y, real x); void gen_runmath15(stack *Stack) { real x=vm::pop<real>(Stack); real y=vm::pop<real>(Stack); -#line 146 "runmath.in" +#line 156 "runmath.in" {Stack->push<real>(atan2(y,x)); return;} } -#line 150 "runmath.in" +#line 160 "runmath.in" // real hypot(real x, real y); void gen_runmath16(stack *Stack) { real y=vm::pop<real>(Stack); real x=vm::pop<real>(Stack); -#line 151 "runmath.in" +#line 161 "runmath.in" {Stack->push<real>(hypot(x,y)); return;} } -#line 155 "runmath.in" +#line 165 "runmath.in" // real remainder(real x, real y); void gen_runmath17(stack *Stack) { real y=vm::pop<real>(Stack); real x=vm::pop<real>(Stack); -#line 156 "runmath.in" +#line 166 "runmath.in" {Stack->push<real>(remainder(x,y)); return;} } -#line 160 "runmath.in" +#line 170 "runmath.in" // real Jn(Int n, real x); void gen_runmath18(stack *Stack) { real x=vm::pop<real>(Stack); Int n=vm::pop<Int>(Stack); -#line 161 "runmath.in" +#line 171 "runmath.in" {Stack->push<real>(jn(n,x)); return;} } -#line 165 "runmath.in" +#line 175 "runmath.in" // real Yn(Int n, real x); void gen_runmath19(stack *Stack) { real x=vm::pop<real>(Stack); Int n=vm::pop<Int>(Stack); -#line 166 "runmath.in" +#line 176 "runmath.in" {Stack->push<real>(yn(n,x)); return;} } -#line 170 "runmath.in" +#line 180 "runmath.in" // real erf(real x); void gen_runmath20(stack *Stack) { real x=vm::pop<real>(Stack); -#line 171 "runmath.in" +#line 181 "runmath.in" {Stack->push<real>(erf(x)); return;} } -#line 175 "runmath.in" +#line 185 "runmath.in" // real erfc(real x); void gen_runmath21(stack *Stack) { real x=vm::pop<real>(Stack); -#line 176 "runmath.in" +#line 186 "runmath.in" {Stack->push<real>(erfc(x)); return;} } -#line 180 "runmath.in" +#line 190 "runmath.in" // Int factorial(Int n); void gen_runmath22(stack *Stack) { Int n=vm::pop<Int>(Stack); -#line 181 "runmath.in" +#line 191 "runmath.in" if(n < 0) error(invalidargument); {Stack->push<Int>(factorial(n)); return;} } -#line 185 "runmath.in" +#line 195 "runmath.in" // Int choose(Int n, Int k); void gen_runmath23(stack *Stack) { Int k=vm::pop<Int>(Stack); Int n=vm::pop<Int>(Stack); -#line 186 "runmath.in" +#line 196 "runmath.in" if(n < 0 || k < 0 || k > n) error(invalidargument); Int f=1; Int r=n-k; @@ -397,12 +410,12 @@ void gen_runmath23(stack *Stack) {Stack->push<Int>(f); return;} } -#line 196 "runmath.in" +#line 206 "runmath.in" // real gamma(real x); void gen_runmath24(stack *Stack) { real x=vm::pop<real>(Stack); -#line 197 "runmath.in" +#line 207 "runmath.in" #ifdef HAVE_TGAMMA {Stack->push<real>(tgamma(x)); return;} #else @@ -411,14 +424,14 @@ void gen_runmath24(stack *Stack) #endif } -#line 206 "runmath.in" +#line 216 "runmath.in" // realarray* quadraticroots(real a, real b, real c); void gen_runmath25(stack *Stack) { real c=vm::pop<real>(Stack); real b=vm::pop<real>(Stack); real a=vm::pop<real>(Stack); -#line 207 "runmath.in" +#line 217 "runmath.in" quadraticroots q(a,b,c); array *roots=new array(q.roots); if(q.roots >= 1) (*roots)[0]=q.t1; @@ -426,14 +439,14 @@ void gen_runmath25(stack *Stack) {Stack->push<realarray*>(roots); return;} } -#line 215 "runmath.in" +#line 225 "runmath.in" // pairarray* quadraticroots(explicit pair a, explicit pair b, explicit pair c); void gen_runmath26(stack *Stack) { pair c=vm::pop<pair>(Stack); pair b=vm::pop<pair>(Stack); pair a=vm::pop<pair>(Stack); -#line 216 "runmath.in" +#line 226 "runmath.in" Quadraticroots q(a,b,c); array *roots=new array(q.roots); if(q.roots >= 1) (*roots)[0]=q.z1; @@ -441,7 +454,7 @@ void gen_runmath26(stack *Stack) {Stack->push<pairarray*>(roots); return;} } -#line 224 "runmath.in" +#line 234 "runmath.in" // realarray* cubicroots(real a, real b, real c, real d); void gen_runmath27(stack *Stack) { @@ -449,7 +462,7 @@ void gen_runmath27(stack *Stack) real c=vm::pop<real>(Stack); real b=vm::pop<real>(Stack); real a=vm::pop<real>(Stack); -#line 225 "runmath.in" +#line 235 "runmath.in" cubicroots q(a,b,c,d); array *roots=new array(q.roots); if(q.roots >= 1) (*roots)[0]=q.t1; @@ -460,98 +473,98 @@ void gen_runmath27(stack *Stack) // Logical operations -#line 236 "runmath.in" +#line 246 "runmath.in" // bool !(bool b); void gen_runmath28(stack *Stack) { bool b=vm::pop<bool>(Stack); -#line 237 "runmath.in" +#line 247 "runmath.in" {Stack->push<bool>(!b); return;} } -#line 242 "runmath.in" +#line 252 "runmath.in" void boolMemEq(stack *Stack) { frame * b=vm::pop<frame *>(Stack); frame * a=vm::pop<frame *>(Stack); -#line 243 "runmath.in" +#line 253 "runmath.in" {Stack->push<bool>(a == b); return;} } -#line 247 "runmath.in" +#line 257 "runmath.in" void boolMemNeq(stack *Stack) { frame * b=vm::pop<frame *>(Stack); frame * a=vm::pop<frame *>(Stack); -#line 248 "runmath.in" +#line 258 "runmath.in" {Stack->push<bool>(a != b); return;} } -#line 252 "runmath.in" +#line 262 "runmath.in" void boolFuncEq(stack *Stack) { callable * b=vm::pop<callable *>(Stack); callable * a=vm::pop<callable *>(Stack); -#line 253 "runmath.in" +#line 263 "runmath.in" {Stack->push<bool>(a->compare(b)); return;} } -#line 257 "runmath.in" +#line 267 "runmath.in" void boolFuncNeq(stack *Stack) { callable * b=vm::pop<callable *>(Stack); callable * a=vm::pop<callable *>(Stack); -#line 258 "runmath.in" +#line 268 "runmath.in" {Stack->push<bool>(!(a->compare(b))); return;} } // Bit operations -#line 264 "runmath.in" +#line 274 "runmath.in" // Int AND(Int a, Int b); void gen_runmath33(stack *Stack) { Int b=vm::pop<Int>(Stack); Int a=vm::pop<Int>(Stack); -#line 265 "runmath.in" +#line 275 "runmath.in" {Stack->push<Int>(a & b); return;} } -#line 270 "runmath.in" +#line 280 "runmath.in" // Int OR(Int a, Int b); void gen_runmath34(stack *Stack) { Int b=vm::pop<Int>(Stack); Int a=vm::pop<Int>(Stack); -#line 271 "runmath.in" +#line 281 "runmath.in" {Stack->push<Int>(a | b); return;} } -#line 275 "runmath.in" +#line 285 "runmath.in" // Int XOR(Int a, Int b); void gen_runmath35(stack *Stack) { Int b=vm::pop<Int>(Stack); Int a=vm::pop<Int>(Stack); -#line 276 "runmath.in" +#line 286 "runmath.in" {Stack->push<Int>(a ^ b); return;} } -#line 280 "runmath.in" +#line 290 "runmath.in" // Int NOT(Int a); void gen_runmath36(stack *Stack) { Int a=vm::pop<Int>(Stack); -#line 281 "runmath.in" +#line 291 "runmath.in" {Stack->push<Int>(~a); return;} } -#line 285 "runmath.in" +#line 295 "runmath.in" // Int CLZ(Int a); void gen_runmath37(stack *Stack) { Int a=vm::pop<Int>(Stack); -#line 286 "runmath.in" +#line 296 "runmath.in" if((unsignedInt) a > 0xFFFFFFFF) {Stack->push<Int>(-1); return;} #ifdef __GNUC__ {Stack->push<Int>(__builtin_clz(a)); return;} @@ -572,12 +585,12 @@ void gen_runmath37(stack *Stack) #endif } -#line 307 "runmath.in" +#line 317 "runmath.in" // Int CTZ(Int a); void gen_runmath38(stack *Stack) { Int a=vm::pop<Int>(Stack); -#line 308 "runmath.in" +#line 318 "runmath.in" if((unsignedInt) a > 0xFFFFFFFF) {Stack->push<Int>(-1); return;} #ifdef __GNUC__ {Stack->push<Int>(__builtin_ctz(a)); return;} @@ -598,84 +611,84 @@ namespace trans { void gen_runmath_venv(venv &ve) { -#line 62 "runmath.in" - addFunc(ve, run::gen_runmath0, primReal(), "^", formal(primReal(), "x", false, false), formal(primInt(), "y", false, false)); -#line 67 "runmath.in" - addFunc(ve, run::gen_runmath1, primPair(), "^", formal(primPair(), "z", false, false), formal(primInt(), "y", false, false)); #line 72 "runmath.in" - addFunc(ve, run::gen_runmath2, primInt(), "quotient", formal(primInt(), "x", false, false), formal(primInt(), "y", false, false)); -#line 80 "runmath.in" - addFunc(ve, run::gen_runmath3, primInt(), "abs", formal(primInt(), "x", false, false)); -#line 85 "runmath.in" - addFunc(ve, run::gen_runmath4, primInt(), "sgn", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath0, primReal(), SYM_CARET, formal(primReal(), SYM(x), false, false), formal(primInt(), SYM(y), false, false)); +#line 77 "runmath.in" + addFunc(ve, run::gen_runmath1, primPair(), SYM_CARET, formal(primPair(), SYM(z), false, false), formal(primInt(), SYM(y), false, false)); +#line 82 "runmath.in" + addFunc(ve, run::gen_runmath2, primInt(), SYM(quotient), formal(primInt(), SYM(x), false, false), formal(primInt(), SYM(y), false, false)); #line 90 "runmath.in" - addFunc(ve, run::gen_runmath5, primInt(), "rand"); + addFunc(ve, run::gen_runmath3, primInt(), SYM(abs), formal(primInt(), SYM(x), false, false)); #line 95 "runmath.in" - addFunc(ve, run::gen_runmath6, primVoid(), "srand", formal(primInt(), "seed", false, false)); -#line 102 "runmath.in" - addFunc(ve, run::gen_runmath7, primReal(), "unitrand"); -#line 108 "runmath.in" - addFunc(ve, run::gen_runmath8, primInt(), "ceil", formal(primReal(), "x", false, false)); -#line 113 "runmath.in" - addFunc(ve, run::gen_runmath9, primInt(), "floor", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath4, primInt(), SYM(sgn), formal(primReal(), SYM(x), false, false)); +#line 100 "runmath.in" + addFunc(ve, run::gen_runmath5, primInt(), SYM(rand)); +#line 107 "runmath.in" + addFunc(ve, run::gen_runmath6, primVoid(), SYM(srand), formal(primInt(), SYM(seed), false, false)); +#line 112 "runmath.in" + addFunc(ve, run::gen_runmath7, primReal(), SYM(unitrand)); #line 118 "runmath.in" - addFunc(ve, run::gen_runmath10, primInt(), "round", formal(primReal(), "x", false, false)); -#line 124 "runmath.in" - addFunc(ve, run::gen_runmath11, primInt(), "Ceil", formal(primReal(), "x", false, false)); -#line 129 "runmath.in" - addFunc(ve, run::gen_runmath12, primInt(), "Floor", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath8, primInt(), SYM(ceil), formal(primReal(), SYM(x), false, false)); +#line 123 "runmath.in" + addFunc(ve, run::gen_runmath9, primInt(), SYM(floor), formal(primReal(), SYM(x), false, false)); +#line 128 "runmath.in" + addFunc(ve, run::gen_runmath10, primInt(), SYM(round), formal(primReal(), SYM(x), false, false)); #line 134 "runmath.in" - addFunc(ve, run::gen_runmath13, primInt(), "Round", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath11, primInt(), SYM(Ceil), formal(primReal(), SYM(x), false, false)); #line 139 "runmath.in" - addFunc(ve, run::gen_runmath14, primReal(), "fmod", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); -#line 145 "runmath.in" - addFunc(ve, run::gen_runmath15, primReal(), "atan2", formal(primReal(), "y", false, false), formal(primReal(), "x", false, false)); -#line 150 "runmath.in" - addFunc(ve, run::gen_runmath16, primReal(), "hypot", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); + addFunc(ve, run::gen_runmath12, primInt(), SYM(Floor), formal(primReal(), SYM(x), false, false)); +#line 144 "runmath.in" + addFunc(ve, run::gen_runmath13, primInt(), SYM(Round), formal(primReal(), SYM(x), false, false)); +#line 149 "runmath.in" + addFunc(ve, run::gen_runmath14, primReal(), SYM(fmod), formal(primReal(), SYM(x), false, false), formal(primReal(), SYM(y), false, false)); #line 155 "runmath.in" - addFunc(ve, run::gen_runmath17, primReal(), "remainder", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); + addFunc(ve, run::gen_runmath15, primReal(), SYM(atan2), formal(primReal(), SYM(y), false, false), formal(primReal(), SYM(x), false, false)); #line 160 "runmath.in" - addFunc(ve, run::gen_runmath18, primReal(), "Jn", formal(primInt(), "n", false, false), formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath16, primReal(), SYM(hypot), formal(primReal(), SYM(x), false, false), formal(primReal(), SYM(y), false, false)); #line 165 "runmath.in" - addFunc(ve, run::gen_runmath19, primReal(), "Yn", formal(primInt(), "n", false, false), formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath17, primReal(), SYM(remainder), formal(primReal(), SYM(x), false, false), formal(primReal(), SYM(y), false, false)); #line 170 "runmath.in" - addFunc(ve, run::gen_runmath20, primReal(), "erf", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath18, primReal(), SYM(Jn), formal(primInt(), SYM(n), false, false), formal(primReal(), SYM(x), false, false)); #line 175 "runmath.in" - addFunc(ve, run::gen_runmath21, primReal(), "erfc", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath19, primReal(), SYM(Yn), formal(primInt(), SYM(n), false, false), formal(primReal(), SYM(x), false, false)); #line 180 "runmath.in" - addFunc(ve, run::gen_runmath22, primInt(), "factorial", formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runmath20, primReal(), SYM(erf), formal(primReal(), SYM(x), false, false)); #line 185 "runmath.in" - addFunc(ve, run::gen_runmath23, primInt(), "choose", formal(primInt(), "n", false, false), formal(primInt(), "k", false, false)); -#line 196 "runmath.in" - addFunc(ve, run::gen_runmath24, primReal(), "gamma", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runmath21, primReal(), SYM(erfc), formal(primReal(), SYM(x), false, false)); +#line 190 "runmath.in" + addFunc(ve, run::gen_runmath22, primInt(), SYM(factorial), formal(primInt(), SYM(n), false, false)); +#line 195 "runmath.in" + addFunc(ve, run::gen_runmath23, primInt(), SYM(choose), formal(primInt(), SYM(n), false, false), formal(primInt(), SYM(k), false, false)); #line 206 "runmath.in" - addFunc(ve, run::gen_runmath25, realArray(), "quadraticroots", formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "c", false, false)); -#line 215 "runmath.in" - addFunc(ve, run::gen_runmath26, pairArray(), "quadraticroots", formal(primPair(), "a", false, true), formal(primPair(), "b", false, true), formal(primPair(), "c", false, true)); -#line 224 "runmath.in" - addFunc(ve, run::gen_runmath27, realArray(), "cubicroots", formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "c", false, false), formal(primReal(), "d", false, false)); + addFunc(ve, run::gen_runmath24, primReal(), SYM(gamma), formal(primReal(), SYM(x), false, false)); +#line 216 "runmath.in" + addFunc(ve, run::gen_runmath25, realArray(), SYM(quadraticroots), formal(primReal(), SYM(a), false, false), formal(primReal(), SYM(b), false, false), formal(primReal(), SYM(c), false, false)); +#line 225 "runmath.in" + addFunc(ve, run::gen_runmath26, pairArray(), SYM(quadraticroots), formal(primPair(), SYM(a), false, true), formal(primPair(), SYM(b), false, true), formal(primPair(), SYM(c), false, true)); #line 234 "runmath.in" - addFunc(ve, run::gen_runmath28, primBoolean(), "!", formal(primBoolean(), "b", false, false)); -#line 242 "runmath.in" + addFunc(ve, run::gen_runmath27, realArray(), SYM(cubicroots), formal(primReal(), SYM(a), false, false), formal(primReal(), SYM(b), false, false), formal(primReal(), SYM(c), false, false), formal(primReal(), SYM(d), false, false)); +#line 244 "runmath.in" + addFunc(ve, run::gen_runmath28, primBoolean(), SYM_LOGNOT, formal(primBoolean(), SYM(b), false, false)); +#line 252 "runmath.in" REGISTER_BLTIN(run::boolMemEq,"boolMemEq"); -#line 247 "runmath.in" +#line 257 "runmath.in" REGISTER_BLTIN(run::boolMemNeq,"boolMemNeq"); -#line 252 "runmath.in" +#line 262 "runmath.in" REGISTER_BLTIN(run::boolFuncEq,"boolFuncEq"); -#line 257 "runmath.in" +#line 267 "runmath.in" REGISTER_BLTIN(run::boolFuncNeq,"boolFuncNeq"); -#line 262 "runmath.in" - addFunc(ve, run::gen_runmath33, primInt(), "AND", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); -#line 270 "runmath.in" - addFunc(ve, run::gen_runmath34, primInt(), "OR", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); -#line 275 "runmath.in" - addFunc(ve, run::gen_runmath35, primInt(), "XOR", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); +#line 272 "runmath.in" + addFunc(ve, run::gen_runmath33, primInt(), SYM(AND), formal(primInt(), SYM(a), false, false), formal(primInt(), SYM(b), false, false)); #line 280 "runmath.in" - addFunc(ve, run::gen_runmath36, primInt(), "NOT", formal(primInt(), "a", false, false)); + addFunc(ve, run::gen_runmath34, primInt(), SYM(OR), formal(primInt(), SYM(a), false, false), formal(primInt(), SYM(b), false, false)); #line 285 "runmath.in" - addFunc(ve, run::gen_runmath37, primInt(), "CLZ", formal(primInt(), "a", false, false)); -#line 307 "runmath.in" - addFunc(ve, run::gen_runmath38, primInt(), "CTZ", formal(primInt(), "a", false, false)); + addFunc(ve, run::gen_runmath35, primInt(), SYM(XOR), formal(primInt(), SYM(a), false, false), formal(primInt(), SYM(b), false, false)); +#line 290 "runmath.in" + addFunc(ve, run::gen_runmath36, primInt(), SYM(NOT), formal(primInt(), SYM(a), false, false)); +#line 295 "runmath.in" + addFunc(ve, run::gen_runmath37, primInt(), SYM(CLZ), formal(primInt(), SYM(a), false, false)); +#line 317 "runmath.in" + addFunc(ve, run::gen_runmath38, primInt(), SYM(CTZ), formal(primInt(), SYM(a), false, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runmath.in b/Build/source/utils/asymptote/runmath.in index d8f473a8433..2c4b0ef733d 100644 --- a/Build/source/utils/asymptote/runmath.in +++ b/Build/source/utils/asymptote/runmath.in @@ -56,6 +56,16 @@ inline Int sgn(double x) return (x > 0.0 ? 1 : (x < 0.0 ? -1 : 0)); } +static bool initializeRandom=true; + +void Srand(Int seed) +{ + initializeRandom=false; + const int n=256; + static char state[n]; + initstate(intcast(seed),state,n); +} + // Autogenerated routines: @@ -89,14 +99,14 @@ Int sgn(real x) Int rand() { + if(initializeRandom) + Srand(1); return random(); } void srand(Int seed) { - const int n=256; - static char state[n]; - initstate(intcast(seed),state,n); + Srand(seed); } // a random number uniformly distributed in the interval [0,1] diff --git a/Build/source/utils/asymptote/runmath.symbols.h b/Build/source/utils/asymptote/runmath.symbols.h new file mode 100644 index 00000000000..ab1ae9b283b --- /dev/null +++ b/Build/source/utils/asymptote/runmath.symbols.h @@ -0,0 +1,58 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(AND); +ADDSYMBOL(CLZ); +ADDSYMBOL(CTZ); +ADDSYMBOL(Ceil); +ADDSYMBOL(Floor); +ADDSYMBOL(Jn); +ADDSYMBOL(NOT); +ADDSYMBOL(OR); +ADDSYMBOL(Round); +ADDSYMBOL(XOR); +ADDSYMBOL(Yn); +ADDSYMBOL(a); +ADDSYMBOL(abs); +ADDSYMBOL(atan2); +ADDSYMBOL(b); +ADDSYMBOL(c); +ADDSYMBOL(ceil); +ADDSYMBOL(choose); +ADDSYMBOL(cubicroots); +ADDSYMBOL(d); +ADDSYMBOL(erf); +ADDSYMBOL(erfc); +ADDSYMBOL(factorial); +ADDSYMBOL(floor); +ADDSYMBOL(fmod); +ADDSYMBOL(gamma); +ADDSYMBOL(hypot); +ADDSYMBOL(k); +ADDSYMBOL(n); +ADDSYMBOL(quadraticroots); +ADDSYMBOL(quotient); +ADDSYMBOL(rand); +ADDSYMBOL(remainder); +ADDSYMBOL(round); +ADDSYMBOL(seed); +ADDSYMBOL(sgn); +ADDSYMBOL(srand); +ADDSYMBOL(unitrand); +ADDSYMBOL(x); +ADDSYMBOL(y); +ADDSYMBOL(z); diff --git a/Build/source/utils/asymptote/runpair.cc b/Build/source/utils/asymptote/runpair.cc index cd44539d9e3..89eec01aedf 100644 --- a/Build/source/utils/asymptote/runpair.cc +++ b/Build/source/utils/asymptote/runpair.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -145,6 +146,8 @@ pair gamma(pair z) +#include "runpair.symbols.h" + namespace run { #line 49 "runpair.in" void pairZero(stack *Stack) @@ -501,69 +504,69 @@ void gen_runpair_venv(venv &ve) #line 59 "runpair.in" REGISTER_BLTIN(run::pairNegate,"pairNegate"); #line 64 "runpair.in" - addFunc(ve, run::pairXPart, primReal(), "xpart", formal(primPair(), "z", false, false)); + addFunc(ve, run::pairXPart, primReal(), SYM(xpart), formal(primPair(), SYM(z), false, false)); #line 69 "runpair.in" - addFunc(ve, run::pairYPart, primReal(), "ypart", formal(primPair(), "z", false, false)); + addFunc(ve, run::pairYPart, primReal(), SYM(ypart), formal(primPair(), SYM(z), false, false)); #line 74 "runpair.in" - addFunc(ve, run::gen_runpair5, primReal(), "length", formal(primPair(), "z", false, false)); + addFunc(ve, run::gen_runpair5, primReal(), SYM(length), formal(primPair(), SYM(z), false, false)); #line 79 "runpair.in" - addFunc(ve, run::gen_runpair6, primReal(), "abs", formal(primPair(), "z", false, false)); + addFunc(ve, run::gen_runpair6, primReal(), SYM(abs), formal(primPair(), SYM(z), false, false)); #line 84 "runpair.in" - addFunc(ve, run::gen_runpair7, primPair(), "sqrt", formal(primPair(), "z", false, true)); + addFunc(ve, run::gen_runpair7, primPair(), SYM(sqrt), formal(primPair(), SYM(z), false, true)); #line 89 "runpair.in" - addFunc(ve, run::gen_runpair8, primReal(), "angle", formal(primPair(), "z", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runpair8, primReal(), SYM(angle), formal(primPair(), SYM(z), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 96 "runpair.in" - addFunc(ve, run::gen_runpair9, primReal(), "degrees", formal(primPair(), "z", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runpair9, primReal(), SYM(degrees), formal(primPair(), SYM(z), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 103 "runpair.in" - addFunc(ve, run::gen_runpair10, primReal(), "radians", formal(primReal(), "degrees", false, false)); + addFunc(ve, run::gen_runpair10, primReal(), SYM(radians), formal(primReal(), SYM(degrees), false, false)); #line 109 "runpair.in" - addFunc(ve, run::gen_runpair11, primReal(), "degrees", formal(primReal(), "radians", false, false)); + addFunc(ve, run::gen_runpair11, primReal(), SYM(degrees), formal(primReal(), SYM(radians), false, false)); #line 115 "runpair.in" - addFunc(ve, run::gen_runpair12, primReal(), "Degrees", formal(primReal(), "radians", false, false)); + addFunc(ve, run::gen_runpair12, primReal(), SYM(Degrees), formal(primReal(), SYM(radians), false, false)); #line 121 "runpair.in" - addFunc(ve, run::gen_runpair13, primReal(), "Sin", formal(primReal(), "deg", false, false)); + addFunc(ve, run::gen_runpair13, primReal(), SYM(Sin), formal(primReal(), SYM(deg), false, false)); #line 126 "runpair.in" - addFunc(ve, run::gen_runpair14, primReal(), "Cos", formal(primReal(), "deg", false, false)); + addFunc(ve, run::gen_runpair14, primReal(), SYM(Cos), formal(primReal(), SYM(deg), false, false)); #line 131 "runpair.in" - addFunc(ve, run::gen_runpair15, primReal(), "Tan", formal(primReal(), "deg", false, false)); + addFunc(ve, run::gen_runpair15, primReal(), SYM(Tan), formal(primReal(), SYM(deg), false, false)); #line 136 "runpair.in" - addFunc(ve, run::gen_runpair16, primReal(), "aSin", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runpair16, primReal(), SYM(aSin), formal(primReal(), SYM(x), false, false)); #line 141 "runpair.in" - addFunc(ve, run::gen_runpair17, primReal(), "aCos", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runpair17, primReal(), SYM(aCos), formal(primReal(), SYM(x), false, false)); #line 146 "runpair.in" - addFunc(ve, run::gen_runpair18, primReal(), "aTan", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runpair18, primReal(), SYM(aTan), formal(primReal(), SYM(x), false, false)); #line 151 "runpair.in" - addFunc(ve, run::gen_runpair19, primPair(), "unit", formal(primPair(), "z", false, false)); + addFunc(ve, run::gen_runpair19, primPair(), SYM(unit), formal(primPair(), SYM(z), false, false)); #line 156 "runpair.in" - addFunc(ve, run::gen_runpair20, primPair(), "dir", formal(primReal(), "degrees", false, false)); + addFunc(ve, run::gen_runpair20, primPair(), SYM(dir), formal(primReal(), SYM(degrees), false, false)); #line 161 "runpair.in" - addFunc(ve, run::gen_runpair21, primPair(), "dir", formal(primPair(), "z", false, true)); + addFunc(ve, run::gen_runpair21, primPair(), SYM(dir), formal(primPair(), SYM(z), false, true)); #line 166 "runpair.in" - addFunc(ve, run::gen_runpair22, primPair(), "expi", formal(primReal(), "angle", false, false)); + addFunc(ve, run::gen_runpair22, primPair(), SYM(expi), formal(primReal(), SYM(angle), false, false)); #line 171 "runpair.in" - addFunc(ve, run::gen_runpair23, primPair(), "exp", formal(primPair(), "z", false, true)); + addFunc(ve, run::gen_runpair23, primPair(), SYM(exp), formal(primPair(), SYM(z), false, true)); #line 176 "runpair.in" - addFunc(ve, run::gen_runpair24, primPair(), "log", formal(primPair(), "z", false, true)); + addFunc(ve, run::gen_runpair24, primPair(), SYM(log), formal(primPair(), SYM(z), false, true)); #line 181 "runpair.in" - addFunc(ve, run::gen_runpair25, primPair(), "sin", formal(primPair(), "z", false, true)); + addFunc(ve, run::gen_runpair25, primPair(), SYM(sin), formal(primPair(), SYM(z), false, true)); #line 186 "runpair.in" - addFunc(ve, run::gen_runpair26, primPair(), "cos", formal(primPair(), "z", false, true)); + addFunc(ve, run::gen_runpair26, primPair(), SYM(cos), formal(primPair(), SYM(z), false, true)); #line 191 "runpair.in" - addFunc(ve, run::gen_runpair27, primPair(), "gamma", formal(primPair(), "z", false, true)); + addFunc(ve, run::gen_runpair27, primPair(), SYM(gamma), formal(primPair(), SYM(z), false, true)); #line 197 "runpair.in" - addFunc(ve, run::gen_runpair28, primPair(), "conj", formal(primPair(), "z", false, false)); + addFunc(ve, run::gen_runpair28, primPair(), SYM(conj), formal(primPair(), SYM(z), false, false)); #line 202 "runpair.in" - addFunc(ve, run::gen_runpair29, primPair(), "realmult", formal(primPair(), "z", false, false), formal(primPair(), "w", false, false)); + addFunc(ve, run::gen_runpair29, primPair(), SYM(realmult), formal(primPair(), SYM(z), false, false), formal(primPair(), SYM(w), false, false)); #line 207 "runpair.in" - addFunc(ve, run::gen_runpair30, primReal(), "dot", formal(primPair(), "z", false, true), formal(primPair(), "w", false, true)); + addFunc(ve, run::gen_runpair30, primReal(), SYM(dot), formal(primPair(), SYM(z), false, true), formal(primPair(), SYM(w), false, true)); #line 213 "runpair.in" - addFunc(ve, run::gen_runpair31, primPair(), "bezier", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpair31, primPair(), SYM(bezier), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false), formal(primPair(), SYM(c), false, false), formal(primPair(), SYM(d), false, false), formal(primReal(), SYM(t), false, false)); #line 220 "runpair.in" - addFunc(ve, run::gen_runpair32, primPair(), "bezierP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpair32, primPair(), SYM(bezierP), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false), formal(primPair(), SYM(c), false, false), formal(primPair(), SYM(d), false, false), formal(primReal(), SYM(t), false, false)); #line 225 "runpair.in" - addFunc(ve, run::gen_runpair33, primPair(), "bezierPP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpair33, primPair(), SYM(bezierPP), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false), formal(primPair(), SYM(c), false, false), formal(primPair(), SYM(d), false, false), formal(primReal(), SYM(t), false, false)); #line 230 "runpair.in" - addFunc(ve, run::gen_runpair34, primPair(), "bezierPPP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false)); + addFunc(ve, run::gen_runpair34, primPair(), SYM(bezierPPP), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false), formal(primPair(), SYM(c), false, false), formal(primPair(), SYM(d), false, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runpair.symbols.h b/Build/source/utils/asymptote/runpair.symbols.h new file mode 100644 index 00000000000..33a745e789d --- /dev/null +++ b/Build/source/utils/asymptote/runpair.symbols.h @@ -0,0 +1,57 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(Cos); +ADDSYMBOL(Degrees); +ADDSYMBOL(Sin); +ADDSYMBOL(Tan); +ADDSYMBOL(a); +ADDSYMBOL(aCos); +ADDSYMBOL(aSin); +ADDSYMBOL(aTan); +ADDSYMBOL(abs); +ADDSYMBOL(angle); +ADDSYMBOL(b); +ADDSYMBOL(bezier); +ADDSYMBOL(bezierP); +ADDSYMBOL(bezierPP); +ADDSYMBOL(bezierPPP); +ADDSYMBOL(c); +ADDSYMBOL(conj); +ADDSYMBOL(cos); +ADDSYMBOL(d); +ADDSYMBOL(deg); +ADDSYMBOL(degrees); +ADDSYMBOL(dir); +ADDSYMBOL(dot); +ADDSYMBOL(exp); +ADDSYMBOL(expi); +ADDSYMBOL(gamma); +ADDSYMBOL(length); +ADDSYMBOL(log); +ADDSYMBOL(radians); +ADDSYMBOL(realmult); +ADDSYMBOL(sin); +ADDSYMBOL(sqrt); +ADDSYMBOL(t); +ADDSYMBOL(unit); +ADDSYMBOL(w); +ADDSYMBOL(warn); +ADDSYMBOL(x); +ADDSYMBOL(xpart); +ADDSYMBOL(ypart); +ADDSYMBOL(z); diff --git a/Build/source/utils/asymptote/runpath.cc b/Build/source/utils/asymptote/runpath.cc index 3b672de21cc..00a0a7ab8e7 100644 --- a/Build/source/utils/asymptote/runpath.cc +++ b/Build/source/utils/asymptote/runpath.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -133,6 +134,8 @@ Int windingnumber(array *p, camp::pair z) +#include "runpath.symbols.h" + namespace run { #line 43 "runpath.in" void nullPath(stack *Stack) @@ -649,87 +652,87 @@ void gen_runpath_venv(venv &ve) #line 43 "runpath.in" REGISTER_BLTIN(run::nullPath,"nullPath"); #line 48 "runpath.in" - addFunc(ve, run::gen_runpath1, primBoolean(), "==", formal(primPath(), "a", false, false), formal(primPath(), "b", false, false)); + addFunc(ve, run::gen_runpath1, primBoolean(), SYM_EQ, formal(primPath(), SYM(a), false, false), formal(primPath(), SYM(b), false, false)); #line 53 "runpath.in" - addFunc(ve, run::gen_runpath2, primBoolean(), "!=", formal(primPath(), "a", false, false), formal(primPath(), "b", false, false)); + addFunc(ve, run::gen_runpath2, primBoolean(), SYM_NEQ, formal(primPath(), SYM(a), false, false), formal(primPath(), SYM(b), false, false)); #line 58 "runpath.in" - addFunc(ve, run::gen_runpath3, primPair(), "point", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath3, primPair(), SYM(point), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 63 "runpath.in" - addFunc(ve, run::gen_runpath4, primPair(), "point", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath4, primPair(), SYM(point), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 68 "runpath.in" - addFunc(ve, run::gen_runpath5, primPair(), "precontrol", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath5, primPair(), SYM(precontrol), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 73 "runpath.in" - addFunc(ve, run::gen_runpath6, primPair(), "precontrol", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath6, primPair(), SYM(precontrol), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 78 "runpath.in" - addFunc(ve, run::gen_runpath7, primPair(), "postcontrol", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath7, primPair(), SYM(postcontrol), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 83 "runpath.in" - addFunc(ve, run::gen_runpath8, primPair(), "postcontrol", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath8, primPair(), SYM(postcontrol), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 88 "runpath.in" - addFunc(ve, run::gen_runpath9, primPair(), "dir", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false), formal(primBoolean(), "normalize", true, false)); + addFunc(ve, run::gen_runpath9, primPair(), SYM(dir), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false), formal(primInt(), SYM(sign), true, false), formal(primBoolean(), SYM(normalize), true, false)); #line 93 "runpath.in" - addFunc(ve, run::gen_runpath10, primPair(), "dir", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "normalize", true, false)); + addFunc(ve, run::gen_runpath10, primPair(), SYM(dir), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false), formal(primBoolean(), SYM(normalize), true, false)); #line 98 "runpath.in" - addFunc(ve, run::gen_runpath11, primPair(), "accel", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false)); + addFunc(ve, run::gen_runpath11, primPair(), SYM(accel), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false), formal(primInt(), SYM(sign), true, false)); #line 103 "runpath.in" - addFunc(ve, run::gen_runpath12, primPair(), "accel", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath12, primPair(), SYM(accel), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 108 "runpath.in" - addFunc(ve, run::gen_runpath13, primReal(), "radius", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath13, primReal(), SYM(radius), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 120 "runpath.in" - addFunc(ve, run::gen_runpath14, primPath(), "reverse", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath14, primPath(), SYM(reverse), formal(primPath(), SYM(p), false, false)); #line 125 "runpath.in" - addFunc(ve, run::gen_runpath15, primPath(), "subpath", formal(primPath(), "p", false, false), formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); + addFunc(ve, run::gen_runpath15, primPath(), SYM(subpath), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(a), false, false), formal(primInt(), SYM(b), false, false)); #line 130 "runpath.in" - addFunc(ve, run::gen_runpath16, primPath(), "subpath", formal(primPath(), "p", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false)); + addFunc(ve, run::gen_runpath16, primPath(), SYM(subpath), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(a), false, false), formal(primReal(), SYM(b), false, false)); #line 135 "runpath.in" - addFunc(ve, run::gen_runpath17, primPath(), "nurb", formal(primPair(), "z0", false, false), formal(primPair(), "z1", false, false), formal(primPair(), "z2", false, false), formal(primPair(), "z3", false, false), formal(primReal(), "w0", false, false), formal(primReal(), "w1", false, false), formal(primReal(), "w2", false, false), formal(primReal(), "w3", false, false), formal(primInt(), "m", false, false)); + addFunc(ve, run::gen_runpath17, primPath(), SYM(nurb), formal(primPair(), SYM(z0), false, false), formal(primPair(), SYM(z1), false, false), formal(primPair(), SYM(z2), false, false), formal(primPair(), SYM(z3), false, false), formal(primReal(), SYM(w0), false, false), formal(primReal(), SYM(w1), false, false), formal(primReal(), SYM(w2), false, false), formal(primReal(), SYM(w3), false, false), formal(primInt(), SYM(m), false, false)); #line 141 "runpath.in" - addFunc(ve, run::gen_runpath18, primInt(), "length", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath18, primInt(), SYM(length), formal(primPath(), SYM(p), false, false)); #line 146 "runpath.in" - addFunc(ve, run::gen_runpath19, primBoolean(), "cyclic", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath19, primBoolean(), SYM(cyclic), formal(primPath(), SYM(p), false, false)); #line 151 "runpath.in" - addFunc(ve, run::gen_runpath20, primBoolean(), "straight", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath20, primBoolean(), SYM(straight), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 156 "runpath.in" - addFunc(ve, run::gen_runpath21, primPath(), "unstraighten", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath21, primPath(), SYM(unstraighten), formal(primPath(), SYM(p), false, false)); #line 161 "runpath.in" - addFunc(ve, run::gen_runpath22, primBoolean(), "piecewisestraight", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath22, primBoolean(), SYM(piecewisestraight), formal(primPath(), SYM(p), false, false)); #line 166 "runpath.in" - addFunc(ve, run::gen_runpath23, primReal(), "arclength", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath23, primReal(), SYM(arclength), formal(primPath(), SYM(p), false, false)); #line 171 "runpath.in" - addFunc(ve, run::gen_runpath24, primReal(), "arctime", formal(primPath(), "p", false, false), formal(primReal(), "dval", false, false)); + addFunc(ve, run::gen_runpath24, primReal(), SYM(arctime), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(dval), false, false)); #line 176 "runpath.in" - addFunc(ve, run::gen_runpath25, primReal(), "dirtime", formal(primPath(), "p", false, false), formal(primPair(), "z", false, false)); + addFunc(ve, run::gen_runpath25, primReal(), SYM(dirtime), formal(primPath(), SYM(p), false, false), formal(primPair(), SYM(z), false, false)); #line 181 "runpath.in" - addFunc(ve, run::gen_runpath26, realArray(), "intersect", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false), formal(primReal(), "fuzz", true, false)); + addFunc(ve, run::gen_runpath26, realArray(), SYM(intersect), formal(primPath(), SYM(p), false, false), formal(primPath(), SYM(q), false, false), formal(primReal(), SYM(fuzz), true, false)); #line 198 "runpath.in" - addFunc(ve, run::gen_runpath27, realArray2(), "intersections", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false), formal(primReal(), "fuzz", true, false)); + addFunc(ve, run::gen_runpath27, realArray2(), SYM(intersections), formal(primPath(), SYM(p), false, false), formal(primPath(), SYM(q), false, false), formal(primReal(), SYM(fuzz), true, false)); #line 229 "runpath.in" - addFunc(ve, run::gen_runpath28, realArray(), "intersections", formal(primPath(), "p", false, false), formal(primPair(), "a", false, true), formal(primPair(), "b", false, true), formal(primReal(), "fuzz", true, false)); + addFunc(ve, run::gen_runpath28, realArray(), SYM(intersections), formal(primPath(), SYM(p), false, false), formal(primPair(), SYM(a), false, true), formal(primPair(), SYM(b), false, true), formal(primReal(), SYM(fuzz), true, false)); #line 244 "runpath.in" - addFunc(ve, run::gen_runpath29, primPair(), "extension", formal(primPair(), "p", false, false), formal(primPair(), "q", false, false), formal(primPair(), "p", false, false), formal(primPair(), "q", false, false)); + addFunc(ve, run::gen_runpath29, primPair(), SYM(extension), formal(primPair(), SYM(p), false, false), formal(primPair(), SYM(q), false, false), formal(primPair(), SYM(p), false, false), formal(primPair(), SYM(q), false, false)); #line 255 "runpath.in" - addFunc(ve, run::gen_runpath30, primInt(), "size", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath30, primInt(), SYM(size), formal(primPath(), SYM(p), false, false)); #line 260 "runpath.in" - addFunc(ve, run::gen_runpath31, primPath(), "&", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false)); + addFunc(ve, run::gen_runpath31, primPath(), SYM_AMPERSAND, formal(primPath(), SYM(p), false, false), formal(primPath(), SYM(q), false, false)); #line 265 "runpath.in" - addFunc(ve, run::gen_runpath32, primPair(), "min", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath32, primPair(), SYM(min), formal(primPath(), SYM(p), false, false)); #line 270 "runpath.in" - addFunc(ve, run::gen_runpath33, primPair(), "max", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath33, primPair(), SYM(max), formal(primPath(), SYM(p), false, false)); #line 275 "runpath.in" - addFunc(ve, run::gen_runpath34, realArray(), "mintimes", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath34, realArray(), SYM(mintimes), formal(primPath(), SYM(p), false, false)); #line 284 "runpath.in" - addFunc(ve, run::gen_runpath35, realArray(), "maxtimes", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runpath35, realArray(), SYM(maxtimes), formal(primPath(), SYM(p), false, false)); #line 293 "runpath.in" - addFunc(ve, run::gen_runpath36, primReal(), "relativedistance", formal(primReal(), "theta", false, false), formal(primReal(), "phi", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "atleast", false, false)); + addFunc(ve, run::gen_runpath36, primReal(), SYM(relativedistance), formal(primReal(), SYM(theta), false, false), formal(primReal(), SYM(phi), false, false), formal(primReal(), SYM(t), false, false), formal(primBoolean(), SYM(atleast), false, false)); #line 298 "runpath.in" - addFunc(ve, run::gen_runpath37, primInt(), "windingnumber", formal(pathArray() , "p", false, false), formal(primPair(), "z", false, false)); + addFunc(ve, run::gen_runpath37, primInt(), SYM(windingnumber), formal(pathArray() , SYM(p), false, false), formal(primPair(), SYM(z), false, false)); #line 303 "runpath.in" - addFunc(ve, run::gen_runpath38, primBoolean(), "inside", formal(pathArray() , "g", false, true), formal(primPair(), "z", false, false), formal(primPen(), "fillrule", true, false)); + addFunc(ve, run::gen_runpath38, primBoolean(), SYM(inside), formal(pathArray() , SYM(g), false, true), formal(primPair(), SYM(z), false, false), formal(primPen(), SYM(fillrule), true, false)); #line 308 "runpath.in" - addFunc(ve, run::gen_runpath39, primBoolean(), "inside", formal(primPath(), "g", false, false), formal(primPair(), "z", false, false), formal(primPen(), "fillrule", true, false)); + addFunc(ve, run::gen_runpath39, primBoolean(), SYM(inside), formal(primPath(), SYM(g), false, false), formal(primPair(), SYM(z), false, false), formal(primPen(), SYM(fillrule), true, false)); #line 313 "runpath.in" - addFunc(ve, run::gen_runpath40, primReal(), "side", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false)); + addFunc(ve, run::gen_runpath40, primReal(), SYM(side), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false), formal(primPair(), SYM(c), false, false)); #line 320 "runpath.in" - addFunc(ve, run::gen_runpath41, primReal(), "incircle", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false)); + addFunc(ve, run::gen_runpath41, primReal(), SYM(incircle), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false), formal(primPair(), SYM(c), false, false), formal(primPair(), SYM(d), false, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runpath.symbols.h b/Build/source/utils/asymptote/runpath.symbols.h new file mode 100644 index 00000000000..d93857ff7eb --- /dev/null +++ b/Build/source/utils/asymptote/runpath.symbols.h @@ -0,0 +1,73 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(a); +ADDSYMBOL(accel); +ADDSYMBOL(arclength); +ADDSYMBOL(arctime); +ADDSYMBOL(atleast); +ADDSYMBOL(b); +ADDSYMBOL(c); +ADDSYMBOL(cyclic); +ADDSYMBOL(d); +ADDSYMBOL(dir); +ADDSYMBOL(dirtime); +ADDSYMBOL(dval); +ADDSYMBOL(extension); +ADDSYMBOL(fillrule); +ADDSYMBOL(fuzz); +ADDSYMBOL(g); +ADDSYMBOL(incircle); +ADDSYMBOL(inside); +ADDSYMBOL(intersect); +ADDSYMBOL(intersections); +ADDSYMBOL(length); +ADDSYMBOL(m); +ADDSYMBOL(max); +ADDSYMBOL(maxtimes); +ADDSYMBOL(min); +ADDSYMBOL(mintimes); +ADDSYMBOL(normalize); +ADDSYMBOL(nurb); +ADDSYMBOL(p); +ADDSYMBOL(phi); +ADDSYMBOL(piecewisestraight); +ADDSYMBOL(point); +ADDSYMBOL(postcontrol); +ADDSYMBOL(precontrol); +ADDSYMBOL(q); +ADDSYMBOL(radius); +ADDSYMBOL(relativedistance); +ADDSYMBOL(reverse); +ADDSYMBOL(side); +ADDSYMBOL(sign); +ADDSYMBOL(size); +ADDSYMBOL(straight); +ADDSYMBOL(subpath); +ADDSYMBOL(t); +ADDSYMBOL(theta); +ADDSYMBOL(unstraighten); +ADDSYMBOL(w0); +ADDSYMBOL(w1); +ADDSYMBOL(w2); +ADDSYMBOL(w3); +ADDSYMBOL(windingnumber); +ADDSYMBOL(z); +ADDSYMBOL(z0); +ADDSYMBOL(z1); +ADDSYMBOL(z2); +ADDSYMBOL(z3); diff --git a/Build/source/utils/asymptote/runpath3d.cc b/Build/source/utils/asymptote/runpath3d.cc index 25233ab4a28..1b70db7c7c8 100644 --- a/Build/source/utils/asymptote/runpath3d.cc +++ b/Build/source/utils/asymptote/runpath3d.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -128,6 +129,8 @@ using types::tripleArray2; +#include "runpath3d.symbols.h" + namespace run { #line 39 "runpath3d.in" // path3 path3(triplearray *pre, triplearray *point, triplearray *post, boolarray *straight, bool cyclic); @@ -638,85 +641,85 @@ namespace trans { void gen_runpath3d_venv(venv &ve) { #line 39 "runpath3d.in" - addFunc(ve, run::gen_runpath3d0, primPath3(), "path3", formal(tripleArray(), "pre", false, false), formal(tripleArray(), "point", false, false), formal(tripleArray(), "post", false, false), formal(booleanArray(), "straight", false, false), formal(primBoolean(), "cyclic", false, false)); + addFunc(ve, run::gen_runpath3d0, primPath3(), SYM(path3), formal(tripleArray(), SYM(pre), false, false), formal(tripleArray(), SYM(point), false, false), formal(tripleArray(), SYM(post), false, false), formal(booleanArray(), SYM(straight), false, false), formal(primBoolean(), SYM(cyclic), false, false)); #line 56 "runpath3d.in" REGISTER_BLTIN(run::nullPath3,"nullPath3"); #line 61 "runpath3d.in" - addFunc(ve, run::gen_runpath3d2, primBoolean(), "==", formal(primPath3(), "a", false, false), formal(primPath3(), "b", false, false)); + addFunc(ve, run::gen_runpath3d2, primBoolean(), SYM_EQ, formal(primPath3(), SYM(a), false, false), formal(primPath3(), SYM(b), false, false)); #line 66 "runpath3d.in" - addFunc(ve, run::gen_runpath3d3, primBoolean(), "!=", formal(primPath3(), "a", false, false), formal(primPath3(), "b", false, false)); + addFunc(ve, run::gen_runpath3d3, primBoolean(), SYM_NEQ, formal(primPath3(), SYM(a), false, false), formal(primPath3(), SYM(b), false, false)); #line 71 "runpath3d.in" - addFunc(ve, run::gen_runpath3d4, primTriple(), "point", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath3d4, primTriple(), SYM(point), formal(primPath3(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 76 "runpath3d.in" - addFunc(ve, run::gen_runpath3d5, primTriple(), "point", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath3d5, primTriple(), SYM(point), formal(primPath3(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 81 "runpath3d.in" - addFunc(ve, run::gen_runpath3d6, primTriple(), "precontrol", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath3d6, primTriple(), SYM(precontrol), formal(primPath3(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 86 "runpath3d.in" - addFunc(ve, run::gen_runpath3d7, primTriple(), "precontrol", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath3d7, primTriple(), SYM(precontrol), formal(primPath3(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 91 "runpath3d.in" - addFunc(ve, run::gen_runpath3d8, primTriple(), "postcontrol", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath3d8, primTriple(), SYM(postcontrol), formal(primPath3(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 96 "runpath3d.in" - addFunc(ve, run::gen_runpath3d9, primTriple(), "postcontrol", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath3d9, primTriple(), SYM(postcontrol), formal(primPath3(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 101 "runpath3d.in" - addFunc(ve, run::gen_runpath3d10, primTriple(), "dir", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false), formal(primBoolean(), "normalize", true, false)); + addFunc(ve, run::gen_runpath3d10, primTriple(), SYM(dir), formal(primPath3(), SYM(p), false, false), formal(primInt(), SYM(t), false, false), formal(primInt(), SYM(sign), true, false), formal(primBoolean(), SYM(normalize), true, false)); #line 106 "runpath3d.in" - addFunc(ve, run::gen_runpath3d11, primTriple(), "dir", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "normalize", true, false)); + addFunc(ve, run::gen_runpath3d11, primTriple(), SYM(dir), formal(primPath3(), SYM(p), false, false), formal(primReal(), SYM(t), false, false), formal(primBoolean(), SYM(normalize), true, false)); #line 111 "runpath3d.in" - addFunc(ve, run::gen_runpath3d12, primTriple(), "accel", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false)); + addFunc(ve, run::gen_runpath3d12, primTriple(), SYM(accel), formal(primPath3(), SYM(p), false, false), formal(primInt(), SYM(t), false, false), formal(primInt(), SYM(sign), true, false)); #line 116 "runpath3d.in" - addFunc(ve, run::gen_runpath3d13, primTriple(), "accel", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath3d13, primTriple(), SYM(accel), formal(primPath3(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 121 "runpath3d.in" - addFunc(ve, run::gen_runpath3d14, primReal(), "radius", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath3d14, primReal(), SYM(radius), formal(primPath3(), SYM(p), false, false), formal(primReal(), SYM(t), false, false)); #line 133 "runpath3d.in" - addFunc(ve, run::gen_runpath3d15, primReal(), "radius", formal(primTriple(), "z0", false, false), formal(primTriple(), "c0", false, false), formal(primTriple(), "c1", false, false), formal(primTriple(), "z1", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runpath3d15, primReal(), SYM(radius), formal(primTriple(), SYM(z0), false, false), formal(primTriple(), SYM(c0), false, false), formal(primTriple(), SYM(c1), false, false), formal(primTriple(), SYM(z1), false, false), formal(primReal(), SYM(t), false, false)); #line 145 "runpath3d.in" - addFunc(ve, run::gen_runpath3d16, primPath3(), "reverse", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d16, primPath3(), SYM(reverse), formal(primPath3(), SYM(p), false, false)); #line 150 "runpath3d.in" - addFunc(ve, run::gen_runpath3d17, primPath3(), "subpath", formal(primPath3(), "p", false, false), formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); + addFunc(ve, run::gen_runpath3d17, primPath3(), SYM(subpath), formal(primPath3(), SYM(p), false, false), formal(primInt(), SYM(a), false, false), formal(primInt(), SYM(b), false, false)); #line 155 "runpath3d.in" - addFunc(ve, run::gen_runpath3d18, primPath3(), "subpath", formal(primPath3(), "p", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false)); + addFunc(ve, run::gen_runpath3d18, primPath3(), SYM(subpath), formal(primPath3(), SYM(p), false, false), formal(primReal(), SYM(a), false, false), formal(primReal(), SYM(b), false, false)); #line 160 "runpath3d.in" - addFunc(ve, run::gen_runpath3d19, primInt(), "length", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d19, primInt(), SYM(length), formal(primPath3(), SYM(p), false, false)); #line 165 "runpath3d.in" - addFunc(ve, run::gen_runpath3d20, primBoolean(), "cyclic", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d20, primBoolean(), SYM(cyclic), formal(primPath3(), SYM(p), false, false)); #line 170 "runpath3d.in" - addFunc(ve, run::gen_runpath3d21, primBoolean(), "straight", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath3d21, primBoolean(), SYM(straight), formal(primPath3(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 175 "runpath3d.in" - addFunc(ve, run::gen_runpath3d22, primPath3(), "unstraighten", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d22, primPath3(), SYM(unstraighten), formal(primPath3(), SYM(p), false, false)); #line 180 "runpath3d.in" - addFunc(ve, run::gen_runpath3d23, primReal(), "straightness", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runpath3d23, primReal(), SYM(straightness), formal(primPath3(), SYM(p), false, false), formal(primInt(), SYM(t), false, false)); #line 191 "runpath3d.in" - addFunc(ve, run::gen_runpath3d24, primReal(), "straightness", formal(primTriple(), "z0", false, false), formal(primTriple(), "c0", false, false), formal(primTriple(), "c1", false, false), formal(primTriple(), "z1", false, false)); + addFunc(ve, run::gen_runpath3d24, primReal(), SYM(straightness), formal(primTriple(), SYM(z0), false, false), formal(primTriple(), SYM(c0), false, false), formal(primTriple(), SYM(c1), false, false), formal(primTriple(), SYM(z1), false, false)); #line 199 "runpath3d.in" - addFunc(ve, run::gen_runpath3d25, primBoolean(), "piecewisestraight", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d25, primBoolean(), SYM(piecewisestraight), formal(primPath3(), SYM(p), false, false)); #line 204 "runpath3d.in" - addFunc(ve, run::gen_runpath3d26, primReal(), "arclength", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d26, primReal(), SYM(arclength), formal(primPath3(), SYM(p), false, false)); #line 209 "runpath3d.in" - addFunc(ve, run::gen_runpath3d27, primReal(), "arctime", formal(primPath3(), "p", false, false), formal(primReal(), "dval", false, false)); + addFunc(ve, run::gen_runpath3d27, primReal(), SYM(arctime), formal(primPath3(), SYM(p), false, false), formal(primReal(), SYM(dval), false, false)); #line 214 "runpath3d.in" - addFunc(ve, run::gen_runpath3d28, realArray(), "intersect", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false), formal(primReal(), "fuzz", true, false)); + addFunc(ve, run::gen_runpath3d28, realArray(), SYM(intersect), formal(primPath3(), SYM(p), false, false), formal(primPath3(), SYM(q), false, false), formal(primReal(), SYM(fuzz), true, false)); #line 232 "runpath3d.in" - addFunc(ve, run::gen_runpath3d29, realArray2(), "intersections", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false), formal(primReal(), "fuzz", true, false)); + addFunc(ve, run::gen_runpath3d29, realArray2(), SYM(intersections), formal(primPath3(), SYM(p), false, false), formal(primPath3(), SYM(q), false, false), formal(primReal(), SYM(fuzz), true, false)); #line 265 "runpath3d.in" - addFunc(ve, run::gen_runpath3d30, realArray2(), "intersections", formal(primPath3(), "p", false, false), formal(tripleArray2(), "p", false, false), formal(primReal(), "fuzz", true, false)); + addFunc(ve, run::gen_runpath3d30, realArray2(), SYM(intersections), formal(primPath3(), SYM(p), false, false), formal(tripleArray2(), SYM(p), false, false), formal(primReal(), SYM(fuzz), true, false)); #line 286 "runpath3d.in" - addFunc(ve, run::gen_runpath3d31, primInt(), "size", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d31, primInt(), SYM(size), formal(primPath3(), SYM(p), false, false)); #line 291 "runpath3d.in" - addFunc(ve, run::gen_runpath3d32, primPath3(), "&", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false)); + addFunc(ve, run::gen_runpath3d32, primPath3(), SYM_AMPERSAND, formal(primPath3(), SYM(p), false, false), formal(primPath3(), SYM(q), false, false)); #line 296 "runpath3d.in" - addFunc(ve, run::gen_runpath3d33, primTriple(), "min", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d33, primTriple(), SYM(min), formal(primPath3(), SYM(p), false, false)); #line 301 "runpath3d.in" - addFunc(ve, run::gen_runpath3d34, primTriple(), "max", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d34, primTriple(), SYM(max), formal(primPath3(), SYM(p), false, false)); #line 306 "runpath3d.in" - addFunc(ve, run::gen_runpath3d35, realArray(), "mintimes", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d35, realArray(), SYM(mintimes), formal(primPath3(), SYM(p), false, false)); #line 316 "runpath3d.in" - addFunc(ve, run::gen_runpath3d36, realArray(), "maxtimes", formal(primPath3(), "p", false, false)); + addFunc(ve, run::gen_runpath3d36, realArray(), SYM(maxtimes), formal(primPath3(), SYM(p), false, false)); #line 326 "runpath3d.in" - addFunc(ve, run::gen_runpath3d37, primPath3(), "*", formal(realArray2(), "t", false, false), formal(primPath3(), "g", false, false)); + addFunc(ve, run::gen_runpath3d37, primPath3(), SYM_TIMES, formal(realArray2(), SYM(t), false, false), formal(primPath3(), SYM(g), false, false)); #line 331 "runpath3d.in" - addFunc(ve, run::gen_runpath3d38, primPair(), "minratio", formal(primPath3(), "g", false, false)); + addFunc(ve, run::gen_runpath3d38, primPair(), SYM(minratio), formal(primPath3(), SYM(g), false, false)); #line 336 "runpath3d.in" - addFunc(ve, run::gen_runpath3d39, primPair(), "maxratio", formal(primPath3(), "g", false, false)); + addFunc(ve, run::gen_runpath3d39, primPair(), SYM(maxratio), formal(primPath3(), SYM(g), false, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runpath3d.symbols.h b/Build/source/utils/asymptote/runpath3d.symbols.h new file mode 100644 index 00000000000..cf34628c3e0 --- /dev/null +++ b/Build/source/utils/asymptote/runpath3d.symbols.h @@ -0,0 +1,59 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(a); +ADDSYMBOL(accel); +ADDSYMBOL(arclength); +ADDSYMBOL(arctime); +ADDSYMBOL(b); +ADDSYMBOL(c0); +ADDSYMBOL(c1); +ADDSYMBOL(cyclic); +ADDSYMBOL(dir); +ADDSYMBOL(dval); +ADDSYMBOL(fuzz); +ADDSYMBOL(g); +ADDSYMBOL(intersect); +ADDSYMBOL(intersections); +ADDSYMBOL(length); +ADDSYMBOL(max); +ADDSYMBOL(maxratio); +ADDSYMBOL(maxtimes); +ADDSYMBOL(min); +ADDSYMBOL(minratio); +ADDSYMBOL(mintimes); +ADDSYMBOL(normalize); +ADDSYMBOL(p); +ADDSYMBOL(path3); +ADDSYMBOL(piecewisestraight); +ADDSYMBOL(point); +ADDSYMBOL(post); +ADDSYMBOL(postcontrol); +ADDSYMBOL(pre); +ADDSYMBOL(precontrol); +ADDSYMBOL(q); +ADDSYMBOL(radius); +ADDSYMBOL(reverse); +ADDSYMBOL(sign); +ADDSYMBOL(size); +ADDSYMBOL(straight); +ADDSYMBOL(straightness); +ADDSYMBOL(subpath); +ADDSYMBOL(t); +ADDSYMBOL(unstraighten); +ADDSYMBOL(z0); +ADDSYMBOL(z1); diff --git a/Build/source/utils/asymptote/runpicture.cc b/Build/source/utils/asymptote/runpicture.cc index 3f3f2b9c51e..e677d45c72c 100644 --- a/Build/source/utils/asymptote/runpicture.cc +++ b/Build/source/utils/asymptote/runpicture.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -167,76 +168,80 @@ array *nop(array *a) return a; } +triple Zero; + // Autogenerated routines: +#include "runpicture.symbols.h" + namespace run { -#line 92 "runpicture.in" +#line 94 "runpicture.in" void newPicture(stack *Stack) { -#line 93 "runpicture.in" +#line 95 "runpicture.in" {Stack->push<picture*>(new picture()); return;} } -#line 97 "runpicture.in" +#line 99 "runpicture.in" // bool empty(picture *f); void gen_runpicture1(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 98 "runpicture.in" +#line 100 "runpicture.in" {Stack->push<bool>(f->null()); return;} } -#line 102 "runpicture.in" +#line 104 "runpicture.in" // void erase(picture *f); void gen_runpicture2(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 103 "runpicture.in" +#line 105 "runpicture.in" f->nodes.clear(); } -#line 107 "runpicture.in" +#line 109 "runpicture.in" // pair min(picture *f); void gen_runpicture3(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 108 "runpicture.in" +#line 110 "runpicture.in" {Stack->push<pair>(f->bounds().Min()); return;} } -#line 112 "runpicture.in" +#line 114 "runpicture.in" // pair max(picture *f); void gen_runpicture4(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 113 "runpicture.in" +#line 115 "runpicture.in" {Stack->push<pair>(f->bounds().Max()); return;} } -#line 117 "runpicture.in" +#line 119 "runpicture.in" // pair size(picture *f); void gen_runpicture5(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 118 "runpicture.in" +#line 120 "runpicture.in" bbox b=f->bounds(); {Stack->push<pair>(b.Max()-b.Min()); return;} } -#line 123 "runpicture.in" +#line 125 "runpicture.in" // void _draw(picture *f, path g, pen p); void gen_runpicture6(stack *Stack) { pen p=vm::pop<pen>(Stack); path g=vm::pop<path>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 124 "runpicture.in" +#line 126 "runpicture.in" f->append(new drawPath(g,p)); } -#line 128 "runpicture.in" +#line 130 "runpicture.in" // void fill(picture *f, patharray *g, pen p=CURRENTPEN, bool copy=true); void gen_runpicture7(stack *Stack) { @@ -244,12 +249,12 @@ void gen_runpicture7(stack *Stack) pen p=vm::pop<pen>(Stack,CURRENTPEN); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 129 "runpicture.in" +#line 131 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; f->append(new drawFill(*copyarray(g),false,p)); } -#line 134 "runpicture.in" +#line 136 "runpicture.in" // void latticeshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray2 *p, transform t=identity, bool copy=true); void gen_runpicture8(stack *Stack) { @@ -260,13 +265,13 @@ void gen_runpicture8(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 137 "runpicture.in" +#line 139 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; f->append(new drawLatticeShade(*copyarray(g),stroke,fillrule,*copyarray(p), t)); } -#line 143 "runpicture.in" +#line 145 "runpicture.in" // void axialshade(picture *f, patharray *g, bool stroke=false, pen pena, pair a, pen penb, pair b, bool copy=true); void gen_runpicture9(stack *Stack) { @@ -278,12 +283,12 @@ void gen_runpicture9(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 145 "runpicture.in" +#line 147 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; f->append(new drawAxialShade(*copyarray(g),stroke,pena,a,penb,b)); } -#line 150 "runpicture.in" +#line 152 "runpicture.in" // void radialshade(picture *f, patharray *g, bool stroke=false, pen pena, pair a, real ra, pen penb, pair b, real rb, bool copy=true); void gen_runpicture10(stack *Stack) { @@ -297,12 +302,12 @@ void gen_runpicture10(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 152 "runpicture.in" +#line 154 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; f->append(new drawRadialShade(*copyarray(g),stroke,pena,a,ra,penb,b,rb)); } -#line 157 "runpicture.in" +#line 159 "runpicture.in" // void gouraudshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray *p, pairarray *z, Intarray *edges, bool copy=true); void gen_runpicture11(stack *Stack) { @@ -314,7 +319,7 @@ void gen_runpicture11(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 160 "runpicture.in" +#line 162 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; checkArrays(p,z); checkArrays(z,edges); @@ -322,7 +327,7 @@ void gen_runpicture11(stack *Stack) *copyarray(z),*copyarray(edges))); } -#line 168 "runpicture.in" +#line 170 "runpicture.in" // void gouraudshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray *p, Intarray *edges, bool copy=true); void gen_runpicture12(stack *Stack) { @@ -333,7 +338,7 @@ void gen_runpicture12(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 171 "runpicture.in" +#line 173 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; size_t n=checkArrays(p,edges); size_t m=checkArray(g); @@ -354,7 +359,7 @@ void gen_runpicture12(stack *Stack) *z,*copyarray(edges))); } -#line 192 "runpicture.in" +#line 194 "runpicture.in" // void tensorshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray2 *p, patharray *b=NULL, pairarray2 *z=emptyarray, bool copy=true); void gen_runpicture13(stack *Stack) { @@ -366,7 +371,7 @@ void gen_runpicture13(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 195 "runpicture.in" +#line 197 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; array *(*copyarray2)(array *a)=copy ? copyArray2: nop; if(b == NULL) b=g; @@ -378,7 +383,7 @@ void gen_runpicture13(stack *Stack) *copyarray(b),*copyarray2(z))); } -#line 207 "runpicture.in" +#line 209 "runpicture.in" // void functionshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, string shader=emptystring, bool copy=true); void gen_runpicture14(stack *Stack) { @@ -388,14 +393,14 @@ void gen_runpicture14(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 210 "runpicture.in" +#line 212 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; f->append(new drawFunctionShade(*copyarray(g),stroke,fillrule,shader)); } // Clip a picture to a superpath using the given fill rule. // Subsequent additions to the picture will not be affected by the clipping. -#line 217 "runpicture.in" +#line 219 "runpicture.in" // void clip(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, bool copy=true); void gen_runpicture15(stack *Stack) { @@ -404,13 +409,13 @@ void gen_runpicture15(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 219 "runpicture.in" +#line 221 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; drawClipBegin *begin=new drawClipBegin(*copyarray(g),stroke,fillrule,true); f->enclose(begin,new drawClipEnd(true,begin)); } -#line 225 "runpicture.in" +#line 227 "runpicture.in" // void beginclip(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, bool copy=true); void gen_runpicture16(stack *Stack) { @@ -419,146 +424,174 @@ void gen_runpicture16(stack *Stack) bool stroke=vm::pop<bool>(Stack,false); patharray * g=vm::pop<patharray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 227 "runpicture.in" +#line 229 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; f->append(new drawClipBegin(*copyarray(g),stroke,fillrule,false)); } -#line 232 "runpicture.in" +#line 234 "runpicture.in" // void endclip(picture *f); void gen_runpicture17(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 233 "runpicture.in" +#line 235 "runpicture.in" f->append(new drawClipEnd(false)); } -#line 237 "runpicture.in" +#line 239 "runpicture.in" // void gsave(picture *f); void gen_runpicture18(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 238 "runpicture.in" +#line 240 "runpicture.in" f->append(new drawGsave()); } -#line 242 "runpicture.in" +#line 244 "runpicture.in" // void grestore(picture *f); void gen_runpicture19(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 243 "runpicture.in" +#line 245 "runpicture.in" f->append(new drawGrestore()); } -#line 247 "runpicture.in" -// void begingroup(picture *f, string name=emptystring); +#line 249 "runpicture.in" +// void begingroup(picture *f); void gen_runpicture20(stack *Stack) { - string name=vm::pop<string>(Stack,emptystring); picture * f=vm::pop<picture *>(Stack); -#line 248 "runpicture.in" - f->append(new drawBegin(name)); +#line 250 "runpicture.in" + f->append(new drawBegin()); } -#line 252 "runpicture.in" +#line 254 "runpicture.in" // void endgroup(picture *f); void gen_runpicture21(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 253 "runpicture.in" +#line 255 "runpicture.in" f->append(new drawEnd()); } -#line 257 "runpicture.in" -// void add(picture *dest, picture *src); +#line 259 "runpicture.in" +// void _begingroup3(picture *f, string name, real compression, real granularity, bool closed, bool tessellate, bool dobreak, bool nobreak, triple center, Int interaction); void gen_runpicture22(stack *Stack) { + Int interaction=vm::pop<Int>(Stack); + triple center=vm::pop<triple>(Stack); + bool nobreak=vm::pop<bool>(Stack); + bool dobreak=vm::pop<bool>(Stack); + bool tessellate=vm::pop<bool>(Stack); + bool closed=vm::pop<bool>(Stack); + real granularity=vm::pop<real>(Stack); + real compression=vm::pop<real>(Stack); + string name=vm::pop<string>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 262 "runpicture.in" + f->append(new drawBegin3(name,compression,granularity, + closed,tessellate,dobreak,nobreak, + center,(Interaction) intcast(interaction))); +} + +#line 268 "runpicture.in" +// void endgroup3(picture *f); +void gen_runpicture23(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 269 "runpicture.in" + f->append(new drawEnd3()); +} + +#line 273 "runpicture.in" +// void add(picture *dest, picture *src); +void gen_runpicture24(stack *Stack) +{ picture * src=vm::pop<picture *>(Stack); picture * dest=vm::pop<picture *>(Stack); -#line 258 "runpicture.in" +#line 274 "runpicture.in" dest->add(*src); } -#line 262 "runpicture.in" +#line 278 "runpicture.in" // void prepend(picture *dest, picture *src); -void gen_runpicture23(stack *Stack) +void gen_runpicture25(stack *Stack) { picture * src=vm::pop<picture *>(Stack); picture * dest=vm::pop<picture *>(Stack); -#line 263 "runpicture.in" +#line 279 "runpicture.in" dest->prepend(*src); } -#line 267 "runpicture.in" +#line 283 "runpicture.in" // void postscript(picture *f, string s); -void gen_runpicture24(stack *Stack) +void gen_runpicture26(stack *Stack) { string s=vm::pop<string>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 268 "runpicture.in" +#line 284 "runpicture.in" f->append(new drawVerbatim(PostScript,s)); } -#line 272 "runpicture.in" +#line 288 "runpicture.in" // void tex(picture *f, string s); -void gen_runpicture25(stack *Stack) +void gen_runpicture27(stack *Stack) { string s=vm::pop<string>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 273 "runpicture.in" +#line 289 "runpicture.in" f->append(new drawVerbatim(TeX,s)); } -#line 277 "runpicture.in" +#line 293 "runpicture.in" // void postscript(picture *f, string s, pair min, pair max); -void gen_runpicture26(stack *Stack) +void gen_runpicture28(stack *Stack) { pair max=vm::pop<pair>(Stack); pair min=vm::pop<pair>(Stack); string s=vm::pop<string>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 278 "runpicture.in" +#line 294 "runpicture.in" f->append(new drawVerbatim(PostScript,s,min,max)); } -#line 282 "runpicture.in" +#line 298 "runpicture.in" // void tex(picture *f, string s, pair min, pair max); -void gen_runpicture27(stack *Stack) +void gen_runpicture29(stack *Stack) { pair max=vm::pop<pair>(Stack); pair min=vm::pop<pair>(Stack); string s=vm::pop<string>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 283 "runpicture.in" +#line 299 "runpicture.in" f->append(new drawVerbatim(TeX,s,min,max)); } -#line 287 "runpicture.in" +#line 303 "runpicture.in" // void texpreamble(string s); -void gen_runpicture28(stack *Stack) +void gen_runpicture30(stack *Stack) { string s=vm::pop<string>(Stack); -#line 288 "runpicture.in" +#line 304 "runpicture.in" string t=s+"\n"; processDataStruct &pd=processData(); pd.TeXpipepreamble.push_back(t); pd.TeXpreamble.push_back(t); } -#line 295 "runpicture.in" +#line 311 "runpicture.in" // void deletepreamble(); -void gen_runpicture29(stack *) +void gen_runpicture31(stack *) { -#line 296 "runpicture.in" +#line 312 "runpicture.in" if(getSetting<bool>("inlinetex")) { unlink(auxname(outname(),"pre").c_str()); } } -#line 302 "runpicture.in" +#line 318 "runpicture.in" // void _labelpath(picture *f, string s, string size, path g, string justify, pair offset, pen p); -void gen_runpicture30(stack *Stack) +void gen_runpicture32(stack *Stack) { pen p=vm::pop<pen>(Stack); pair offset=vm::pop<pair>(Stack); @@ -567,42 +600,42 @@ void gen_runpicture30(stack *Stack) string size=vm::pop<string>(Stack); string s=vm::pop<string>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 304 "runpicture.in" +#line 320 "runpicture.in" f->append(new drawLabelPath(s,size,g,justify,offset,p)); } -#line 308 "runpicture.in" +#line 324 "runpicture.in" // void texreset(); -void gen_runpicture31(stack *) +void gen_runpicture33(stack *) { -#line 309 "runpicture.in" +#line 325 "runpicture.in" processDataStruct &pd=processData(); pd.TeXpipepreamble.clear(); pd.TeXpreamble.clear(); pd.tex.pipeclose(); } -#line 316 "runpicture.in" +#line 332 "runpicture.in" // void layer(picture *f); -void gen_runpicture32(stack *Stack) +void gen_runpicture34(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 317 "runpicture.in" +#line 333 "runpicture.in" f->append(new drawLayer()); } -#line 321 "runpicture.in" +#line 337 "runpicture.in" // void newpage(picture *f); -void gen_runpicture33(stack *Stack) +void gen_runpicture35(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 322 "runpicture.in" +#line 338 "runpicture.in" f->append(new drawNewPage()); } -#line 326 "runpicture.in" +#line 342 "runpicture.in" // void _image(picture *f, realarray2 *data, pair initial, pair final, penarray *palette=NULL, transform t=identity, bool copy=true, bool antialias=false); -void gen_runpicture34(stack *Stack) +void gen_runpicture36(stack *Stack) { bool antialias=vm::pop<bool>(Stack,false); bool copy=vm::pop<bool>(Stack,true); @@ -612,16 +645,16 @@ void gen_runpicture34(stack *Stack) pair initial=vm::pop<pair>(Stack); realarray2 * data=vm::pop<realarray2 *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 329 "runpicture.in" +#line 345 "runpicture.in" array *(*copyarray)(array *a)=copy ? copyArray: nop; array *(*copyarray2)(array *a)=copy ? copyArray2: nop; f->append(new drawImage(*copyarray2(data),*copyarray(palette), t*matrix(initial,final),antialias)); } -#line 336 "runpicture.in" +#line 352 "runpicture.in" // void _image(picture *f, penarray2 *data, pair initial, pair final, transform t=identity, bool copy=true, bool antialias=false); -void gen_runpicture35(stack *Stack) +void gen_runpicture37(stack *Stack) { bool antialias=vm::pop<bool>(Stack,false); bool copy=vm::pop<bool>(Stack,true); @@ -630,38 +663,38 @@ void gen_runpicture35(stack *Stack) pair initial=vm::pop<pair>(Stack); penarray2 * data=vm::pop<penarray2 *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 338 "runpicture.in" +#line 354 "runpicture.in" array *(*copyarray2)(array *a)=copy ? copyArray2: nop; f->append(new drawImage(*copyarray2(data),t*matrix(initial,final),antialias)); } -#line 343 "runpicture.in" +#line 359 "runpicture.in" // string nativeformat(); -void gen_runpicture36(stack *Stack) +void gen_runpicture38(stack *Stack) { -#line 344 "runpicture.in" +#line 360 "runpicture.in" {Stack->push<string>(nativeformat()); return;} } -#line 348 "runpicture.in" +#line 364 "runpicture.in" // bool latex(); -void gen_runpicture37(stack *Stack) +void gen_runpicture39(stack *Stack) { -#line 349 "runpicture.in" +#line 365 "runpicture.in" {Stack->push<bool>(latex(getSetting<string>("tex"))); return;} } -#line 353 "runpicture.in" +#line 369 "runpicture.in" // bool pdf(); -void gen_runpicture38(stack *Stack) +void gen_runpicture40(stack *Stack) { -#line 354 "runpicture.in" +#line 370 "runpicture.in" {Stack->push<bool>(pdf(getSetting<string>("tex"))); return;} } -#line 358 "runpicture.in" +#line 374 "runpicture.in" // void shipout(string prefix=emptystring, picture *f, picture *preamble=NULL, string format=emptystring, bool wait=false, bool view=true, callableTransform *xform); -void gen_runpicture39(stack *Stack) +void gen_runpicture41(stack *Stack) { callableTransform * xform=vm::pop<callableTransform *>(Stack); bool view=vm::pop<bool>(Stack,true); @@ -670,7 +703,7 @@ void gen_runpicture39(stack *Stack) picture * preamble=vm::pop<picture *>(Stack,NULL); picture * f=vm::pop<picture *>(Stack); string prefix=vm::pop<string>(Stack,emptystring); -#line 361 "runpicture.in" +#line 377 "runpicture.in" if(prefix.empty()) prefix=outname(); picture *result=new picture; @@ -713,9 +746,9 @@ void gen_runpicture39(stack *Stack) result->shipout(preamble,prefix,format,0.0,wait,view); } -#line 404 "runpicture.in" +#line 420 "runpicture.in" // void shipout3(string prefix, picture *f, string format=emptystring, real width, real height, real angle, real zoom, triple m, triple M, pair shift, realarray2 *t, realarray *background, triplearray *lights, realarray2 *diffuse, realarray2 *ambient, realarray2 *specular, bool viewportlighting, bool view=true); -void gen_runpicture40(stack *Stack) +void gen_runpicture42(stack *Stack) { bool view=vm::pop<bool>(Stack,true); bool viewportlighting=vm::pop<bool>(Stack); @@ -735,7 +768,7 @@ void gen_runpicture40(stack *Stack) string format=vm::pop<string>(Stack,emptystring); picture * f=vm::pop<picture *>(Stack); string prefix=vm::pop<string>(Stack); -#line 410 "runpicture.in" +#line 426 "runpicture.in" size_t n=checkArrays(lights,diffuse); checkEqual(n,checkArray(ambient)); checkEqual(n,checkArray(specular)); @@ -757,27 +790,27 @@ void gen_runpicture40(stack *Stack) delete[] T; } -#line 432 "runpicture.in" +#line 448 "runpicture.in" // void shipout3(string prefix, picture *f, Intarray *index, triplearray *center); -void gen_runpicture41(stack *Stack) +void gen_runpicture43(stack *Stack) { triplearray * center=vm::pop<triplearray *>(Stack); Intarray * index=vm::pop<Intarray *>(Stack); picture * f=vm::pop<picture *>(Stack); string prefix=vm::pop<string>(Stack); -#line 433 "runpicture.in" +#line 449 "runpicture.in" f->shipout3(prefix,index,center); } -#line 437 "runpicture.in" +#line 453 "runpicture.in" // void deconstruct(picture *f, picture *preamble=NULL, real magnification=1, callableTransform *xform); -void gen_runpicture42(stack *Stack) +void gen_runpicture44(stack *Stack) { callableTransform * xform=vm::pop<callableTransform *>(Stack); real magnification=vm::pop<real>(Stack,1); picture * preamble=vm::pop<picture *>(Stack,NULL); picture * f=vm::pop<picture *>(Stack); -#line 439 "runpicture.in" +#line 455 "runpicture.in" unsigned level=0; unsigned n=0; @@ -902,30 +935,28 @@ void gen_runpicture42(stack *Stack) // Three-dimensional picture and surface operations // Bezier curve -#line 564 "runpicture.in" -// void _draw(picture *f, path3 g, pen p, string name=emptystring); -void gen_runpicture43(stack *Stack) +#line 580 "runpicture.in" +// void _draw(picture *f, path3 g, pen p); +void gen_runpicture45(stack *Stack) { - string name=vm::pop<string>(Stack,emptystring); pen p=vm::pop<pen>(Stack); path3 g=vm::pop<path3>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 565 "runpicture.in" +#line 581 "runpicture.in" if(g.size() > 0) - f->append(new drawPath3(g,p,name)); + f->append(new drawPath3(g,p)); } // Bezier patch -#line 571 "runpicture.in" -// void draw(picture *f, triplearray2 *P, triple center, bool straight, penarray *p, real opacity, real shininess, real PRCshininess, real granularity, triple normal, penarray *colors, bool lighton, string name=emptystring, Int interaction); -void gen_runpicture44(stack *Stack) +#line 587 "runpicture.in" +// void draw(picture *f, triplearray2 *P, triple center, bool straight, penarray *p, real opacity, real shininess, real PRCshininess, triple normal, penarray *colors, bool lighton, Int interaction, bool prc=true); +void gen_runpicture46(stack *Stack) { + bool prc=vm::pop<bool>(Stack,true); Int interaction=vm::pop<Int>(Stack); - string name=vm::pop<string>(Stack,emptystring); bool lighton=vm::pop<bool>(Stack); penarray * colors=vm::pop<penarray *>(Stack); triple normal=vm::pop<triple>(Stack); - real granularity=vm::pop<real>(Stack); real PRCshininess=vm::pop<real>(Stack); real shininess=vm::pop<real>(Stack); real opacity=vm::pop<real>(Stack); @@ -934,36 +965,33 @@ void gen_runpicture44(stack *Stack) triple center=vm::pop<triple>(Stack); triplearray2 * P=vm::pop<triplearray2 *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 575 "runpicture.in" +#line 591 "runpicture.in" f->append(new drawSurface(*P,center,straight,*p,opacity,shininess, - PRCshininess,granularity,normal,*colors,lighton, - name,interaction)); + PRCshininess,normal,*colors,lighton, + (Interaction) intcast(interaction),prc)); } // General NURBS curve -#line 582 "runpicture.in" -// void draw(picture *f, triplearray *P, realarray *knot, realarray *weights=emptyarray, pen p, string name=emptystring); -void gen_runpicture45(stack *Stack) +#line 598 "runpicture.in" +// void draw(picture *f, triplearray *P, realarray *knot, realarray *weights=emptyarray, pen p); +void gen_runpicture47(stack *Stack) { - string name=vm::pop<string>(Stack,emptystring); pen p=vm::pop<pen>(Stack); realarray * weights=vm::pop<realarray *>(Stack,emptyarray); realarray * knot=vm::pop<realarray *>(Stack); triplearray * P=vm::pop<triplearray *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 584 "runpicture.in" - f->append(new drawNurbsPath3(*P,knot,weights,p,name)); +#line 600 "runpicture.in" + f->append(new drawNurbsPath3(*P,knot,weights,p)); } // General NURBS surface -#line 589 "runpicture.in" -// void draw(picture *f, triplearray2 *P, realarray *uknot, realarray *vknot, realarray2 *weights=emptyarray, penarray *p, real opacity, real shininess, real PRCshininess, real granularity, penarray *colors, bool lighton, string name=emptystring); -void gen_runpicture46(stack *Stack) +#line 605 "runpicture.in" +// void draw(picture *f, triplearray2 *P, realarray *uknot, realarray *vknot, realarray2 *weights=emptyarray, penarray *p, real opacity, real shininess, real PRCshininess, penarray *colors, bool lighton); +void gen_runpicture48(stack *Stack) { - string name=vm::pop<string>(Stack,emptystring); bool lighton=vm::pop<bool>(Stack); penarray * colors=vm::pop<penarray *>(Stack); - real granularity=vm::pop<real>(Stack); real PRCshininess=vm::pop<real>(Stack); real shininess=vm::pop<real>(Stack); real opacity=vm::pop<real>(Stack); @@ -973,63 +1001,122 @@ void gen_runpicture46(stack *Stack) realarray * uknot=vm::pop<realarray *>(Stack); triplearray2 * P=vm::pop<triplearray2 *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 593 "runpicture.in" +#line 608 "runpicture.in" f->append(new drawNurbs(*P,uknot,vknot,weights,*p,opacity,shininess, - PRCshininess,granularity,*colors,lighton,name)); + PRCshininess,*colors,lighton)); } -#line 598 "runpicture.in" +// PRC unit sphere +#line 614 "runpicture.in" +// void drawPRCsphere(picture *f, realarray2 *t, bool half=false, penarray *p, real opacity, real shininess, Int type); +void gen_runpicture49(stack *Stack) +{ + Int type=vm::pop<Int>(Stack); + real shininess=vm::pop<real>(Stack); + real opacity=vm::pop<real>(Stack); + penarray * p=vm::pop<penarray *>(Stack); + bool half=vm::pop<bool>(Stack,false); + realarray2 * t=vm::pop<realarray2 *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 616 "runpicture.in" + f->append(new drawSphere(*t,half,*p,opacity,shininess,intcast(type))); +} + +// PRC unit cylinder +#line 621 "runpicture.in" +// void drawPRCcylinder(picture *f, realarray2 *t, penarray *p, real opacity, real shininess); +void gen_runpicture50(stack *Stack) +{ + real shininess=vm::pop<real>(Stack); + real opacity=vm::pop<real>(Stack); + penarray * p=vm::pop<penarray *>(Stack); + realarray2 * t=vm::pop<realarray2 *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 623 "runpicture.in" + f->append(new drawCylinder(*t,*p,opacity,shininess)); +} + +// PRC unit disk +#line 628 "runpicture.in" +// void drawPRCdisk(picture *f, realarray2 *t, penarray *p, real opacity, real shininess); +void gen_runpicture51(stack *Stack) +{ + real shininess=vm::pop<real>(Stack); + real opacity=vm::pop<real>(Stack); + penarray * p=vm::pop<penarray *>(Stack); + realarray2 * t=vm::pop<realarray2 *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 630 "runpicture.in" + f->append(new drawDisk(*t,*p,opacity,shininess)); +} + +// General PRC tube +#line 635 "runpicture.in" +// void drawPRCtube(picture *f, path3 center, path3 g, penarray *p, real opacity, real shininess); +void gen_runpicture52(stack *Stack) +{ + real shininess=vm::pop<real>(Stack); + real opacity=vm::pop<real>(Stack); + penarray * p=vm::pop<penarray *>(Stack); + path3 g=vm::pop<path3>(Stack); + path3 center=vm::pop<path3>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 637 "runpicture.in" + f->append(new drawTube(center,g,*p,opacity,shininess)); +} + +#line 641 "runpicture.in" // triple min3(picture *f); -void gen_runpicture47(stack *Stack) +void gen_runpicture53(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 599 "runpicture.in" +#line 642 "runpicture.in" {Stack->push<triple>(f->bounds3().Min()); return;} } -#line 603 "runpicture.in" +#line 646 "runpicture.in" // triple max3(picture *f); -void gen_runpicture48(stack *Stack) +void gen_runpicture54(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 604 "runpicture.in" +#line 647 "runpicture.in" {Stack->push<triple>(f->bounds3().Max()); return;} } -#line 608 "runpicture.in" +#line 651 "runpicture.in" // triple size3(picture *f); -void gen_runpicture49(stack *Stack) +void gen_runpicture55(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 609 "runpicture.in" +#line 652 "runpicture.in" bbox3 b=f->bounds3(); {Stack->push<triple>(b.Max()-b.Min()); return;} } -#line 614 "runpicture.in" +#line 657 "runpicture.in" // pair minratio(picture *f); -void gen_runpicture50(stack *Stack) +void gen_runpicture56(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 615 "runpicture.in" +#line 658 "runpicture.in" {Stack->push<pair>(f->ratio(::min)); return;} } -#line 619 "runpicture.in" +#line 662 "runpicture.in" // pair maxratio(picture *f); -void gen_runpicture51(stack *Stack) +void gen_runpicture57(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 620 "runpicture.in" +#line 663 "runpicture.in" {Stack->push<pair>(f->ratio(::max)); return;} } -#line 624 "runpicture.in" +#line 667 "runpicture.in" // bool is3D(picture *f); -void gen_runpicture52(stack *Stack) +void gen_runpicture58(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 625 "runpicture.in" +#line 668 "runpicture.in" {Stack->push<bool>(f->have3D()); return;} } @@ -1039,112 +1126,124 @@ namespace trans { void gen_runpicture_venv(venv &ve) { -#line 92 "runpicture.in" +#line 94 "runpicture.in" REGISTER_BLTIN(run::newPicture,"newPicture"); -#line 97 "runpicture.in" - addFunc(ve, run::gen_runpicture1, primBoolean(), "empty", formal(primPicture(), "f", false, false)); -#line 102 "runpicture.in" - addFunc(ve, run::gen_runpicture2, primVoid(), "erase", formal(primPicture(), "f", false, false)); -#line 107 "runpicture.in" - addFunc(ve, run::gen_runpicture3, primPair(), "min", formal(primPicture(), "f", false, false)); -#line 112 "runpicture.in" - addFunc(ve, run::gen_runpicture4, primPair(), "max", formal(primPicture(), "f", false, false)); -#line 117 "runpicture.in" - addFunc(ve, run::gen_runpicture5, primPair(), "size", formal(primPicture(), "f", false, false)); -#line 123 "runpicture.in" - addFunc(ve, run::gen_runpicture6, primVoid(), "_draw", formal(primPicture(), "f", false, false), formal(primPath(), "g", false, false), formal(primPen(), "p", false, false)); -#line 128 "runpicture.in" - addFunc(ve, run::gen_runpicture7, primVoid(), "fill", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primPen(), "p", true, false), formal(primBoolean(), "copy", true, false)); -#line 134 "runpicture.in" - addFunc(ve, run::gen_runpicture8, primVoid(), "latticeshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray2() , "p", false, false), formal(primTransform(), "t", true, false), formal(primBoolean(), "copy", true, false)); -#line 143 "runpicture.in" - addFunc(ve, run::gen_runpicture9, primVoid(), "axialshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "pena", false, false), formal(primPair(), "a", false, false), formal(primPen(), "penb", false, false), formal(primPair(), "b", false, false), formal(primBoolean(), "copy", true, false)); -#line 150 "runpicture.in" - addFunc(ve, run::gen_runpicture10, primVoid(), "radialshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "pena", false, false), formal(primPair(), "a", false, false), formal(primReal(), "ra", false, false), formal(primPen(), "penb", false, false), formal(primPair(), "b", false, false), formal(primReal(), "rb", false, false), formal(primBoolean(), "copy", true, false)); -#line 157 "runpicture.in" - addFunc(ve, run::gen_runpicture11, primVoid(), "gouraudshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray() , "p", false, false), formal(pairArray(), "z", false, false), formal(IntArray(), "edges", false, false), formal(primBoolean(), "copy", true, false)); -#line 168 "runpicture.in" - addFunc(ve, run::gen_runpicture12, primVoid(), "gouraudshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray() , "p", false, false), formal(IntArray(), "edges", false, false), formal(primBoolean(), "copy", true, false)); -#line 192 "runpicture.in" - addFunc(ve, run::gen_runpicture13, primVoid(), "tensorshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray2() , "p", false, false), formal(pathArray() , "b", true, false), formal(pairArray2(), "z", true, false), formal(primBoolean(), "copy", true, false)); -#line 207 "runpicture.in" - addFunc(ve, run::gen_runpicture14, primVoid(), "functionshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primString() , "shader", true, false), formal(primBoolean(), "copy", true, false)); -#line 215 "runpicture.in" - addFunc(ve, run::gen_runpicture15, primVoid(), "clip", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primBoolean(), "copy", true, false)); -#line 225 "runpicture.in" - addFunc(ve, run::gen_runpicture16, primVoid(), "beginclip", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primBoolean(), "copy", true, false)); -#line 232 "runpicture.in" - addFunc(ve, run::gen_runpicture17, primVoid(), "endclip", formal(primPicture(), "f", false, false)); -#line 237 "runpicture.in" - addFunc(ve, run::gen_runpicture18, primVoid(), "gsave", formal(primPicture(), "f", false, false)); -#line 242 "runpicture.in" - addFunc(ve, run::gen_runpicture19, primVoid(), "grestore", formal(primPicture(), "f", false, false)); -#line 247 "runpicture.in" - addFunc(ve, run::gen_runpicture20, primVoid(), "begingroup", formal(primPicture(), "f", false, false), formal(primString() , "name", true, false)); -#line 252 "runpicture.in" - addFunc(ve, run::gen_runpicture21, primVoid(), "endgroup", formal(primPicture(), "f", false, false)); -#line 257 "runpicture.in" - addFunc(ve, run::gen_runpicture22, primVoid(), "add", formal(primPicture(), "dest", false, false), formal(primPicture(), "src", false, false)); -#line 262 "runpicture.in" - addFunc(ve, run::gen_runpicture23, primVoid(), "prepend", formal(primPicture(), "dest", false, false), formal(primPicture(), "src", false, false)); -#line 267 "runpicture.in" - addFunc(ve, run::gen_runpicture24, primVoid(), "postscript", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false)); -#line 272 "runpicture.in" - addFunc(ve, run::gen_runpicture25, primVoid(), "tex", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false)); -#line 277 "runpicture.in" - addFunc(ve, run::gen_runpicture26, primVoid(), "postscript", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primPair(), "min", false, false), formal(primPair(), "max", false, false)); -#line 282 "runpicture.in" - addFunc(ve, run::gen_runpicture27, primVoid(), "tex", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primPair(), "min", false, false), formal(primPair(), "max", false, false)); -#line 287 "runpicture.in" - addFunc(ve, run::gen_runpicture28, primVoid(), "texpreamble", formal(primString() , "s", false, false)); -#line 295 "runpicture.in" - addFunc(ve, run::gen_runpicture29, primVoid(), "deletepreamble"); -#line 302 "runpicture.in" - addFunc(ve, run::gen_runpicture30, primVoid(), "_labelpath", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primString() , "size", false, false), formal(primPath(), "g", false, false), formal(primString() , "justify", false, false), formal(primPair(), "offset", false, false), formal(primPen(), "p", false, false)); -#line 308 "runpicture.in" - addFunc(ve, run::gen_runpicture31, primVoid(), "texreset"); -#line 316 "runpicture.in" - addFunc(ve, run::gen_runpicture32, primVoid(), "layer", formal(primPicture(), "f", false, false)); -#line 321 "runpicture.in" - addFunc(ve, run::gen_runpicture33, primVoid(), "newpage", formal(primPicture(), "f", false, false)); -#line 326 "runpicture.in" - addFunc(ve, run::gen_runpicture34, primVoid(), "_image", formal(primPicture(), "f", false, false), formal(realArray2(), "data", false, false), formal(primPair(), "initial", false, false), formal(primPair(), "final", false, false), formal(penArray() , "palette", true, false), formal(primTransform(), "t", true, false), formal(primBoolean(), "copy", true, false), formal(primBoolean(), "antialias", true, false)); -#line 336 "runpicture.in" - addFunc(ve, run::gen_runpicture35, primVoid(), "_image", formal(primPicture(), "f", false, false), formal(penArray2() , "data", false, false), formal(primPair(), "initial", false, false), formal(primPair(), "final", false, false), formal(primTransform(), "t", true, false), formal(primBoolean(), "copy", true, false), formal(primBoolean(), "antialias", true, false)); -#line 343 "runpicture.in" - addFunc(ve, run::gen_runpicture36, primString() , "nativeformat"); -#line 348 "runpicture.in" - addFunc(ve, run::gen_runpicture37, primBoolean(), "latex"); -#line 353 "runpicture.in" - addFunc(ve, run::gen_runpicture38, primBoolean(), "pdf"); -#line 358 "runpicture.in" - addFunc(ve, run::gen_runpicture39, primVoid(), "shipout", formal(primString() , "prefix", true, false), formal(primPicture(), "f", false, false), formal(primPicture(), "preamble", true, false), formal(primString() , "format", true, false), formal(primBoolean(), "wait", true, false), formal(primBoolean(), "view", true, false), formal(transformFunction(), "xform", false, false)); -#line 404 "runpicture.in" - addFunc(ve, run::gen_runpicture40, primVoid(), "shipout3", formal(primString() , "prefix", false, false), formal(primPicture(), "f", false, false), formal(primString() , "format", true, false), formal(primReal(), "width", false, false), formal(primReal(), "height", false, false), formal(primReal(), "angle", false, false), formal(primReal(), "zoom", false, false), formal(primTriple(), "m", false, false), formal(primTriple(), "m", false, false), formal(primPair(), "shift", false, false), formal(realArray2(), "t", false, false), formal(realArray(), "background", false, false), formal(tripleArray(), "lights", false, false), formal(realArray2(), "diffuse", false, false), formal(realArray2(), "ambient", false, false), formal(realArray2(), "specular", false, false), formal(primBoolean(), "viewportlighting", false, false), formal(primBoolean(), "view", true, false)); -#line 432 "runpicture.in" - addFunc(ve, run::gen_runpicture41, primVoid(), "shipout3", formal(primString() , "prefix", false, false), formal(primPicture(), "f", false, false), formal(IntArray(), "index", false, false), formal(tripleArray(), "center", false, false)); -#line 437 "runpicture.in" - addFunc(ve, run::gen_runpicture42, primVoid(), "deconstruct", formal(primPicture(), "f", false, false), formal(primPicture(), "preamble", true, false), formal(primReal(), "magnification", true, false), formal(transformFunction(), "xform", false, false)); -#line 560 "runpicture.in" - addFunc(ve, run::gen_runpicture43, primVoid(), "_draw", formal(primPicture(), "f", false, false), formal(primPath3(), "g", false, false), formal(primPen(), "p", false, false), formal(primString() , "name", true, false)); -#line 570 "runpicture.in" - addFunc(ve, run::gen_runpicture44, primVoid(), "draw", formal(primPicture(), "f", false, false), formal(tripleArray2(), "p", false, false), formal(primTriple(), "center", false, false), formal(primBoolean(), "straight", false, false), formal(penArray() , "p", false, false), formal(primReal(), "opacity", false, false), formal(primReal(), "shininess", false, false), formal(primReal(), "prcshininess", false, false), formal(primReal(), "granularity", false, false), formal(primTriple(), "normal", false, false), formal(penArray() , "colors", false, false), formal(primBoolean(), "lighton", false, false), formal(primString() , "name", true, false), formal(primInt(), "interaction", false, false)); -#line 581 "runpicture.in" - addFunc(ve, run::gen_runpicture45, primVoid(), "draw", formal(primPicture(), "f", false, false), formal(tripleArray(), "p", false, false), formal(realArray(), "knot", false, false), formal(realArray(), "weights", true, false), formal(primPen(), "p", false, false), formal(primString() , "name", true, false)); -#line 588 "runpicture.in" - addFunc(ve, run::gen_runpicture46, primVoid(), "draw", formal(primPicture(), "f", false, false), formal(tripleArray2(), "p", false, false), formal(realArray(), "uknot", false, false), formal(realArray(), "vknot", false, false), formal(realArray2(), "weights", true, false), formal(penArray() , "p", false, false), formal(primReal(), "opacity", false, false), formal(primReal(), "shininess", false, false), formal(primReal(), "prcshininess", false, false), formal(primReal(), "granularity", false, false), formal(penArray() , "colors", false, false), formal(primBoolean(), "lighton", false, false), formal(primString() , "name", true, false)); -#line 598 "runpicture.in" - addFunc(ve, run::gen_runpicture47, primTriple(), "min3", formal(primPicture(), "f", false, false)); -#line 603 "runpicture.in" - addFunc(ve, run::gen_runpicture48, primTriple(), "max3", formal(primPicture(), "f", false, false)); -#line 608 "runpicture.in" - addFunc(ve, run::gen_runpicture49, primTriple(), "size3", formal(primPicture(), "f", false, false)); -#line 614 "runpicture.in" - addFunc(ve, run::gen_runpicture50, primPair(), "minratio", formal(primPicture(), "f", false, false)); -#line 619 "runpicture.in" - addFunc(ve, run::gen_runpicture51, primPair(), "maxratio", formal(primPicture(), "f", false, false)); -#line 624 "runpicture.in" - addFunc(ve, run::gen_runpicture52, primBoolean(), "is3D", formal(primPicture(), "f", false, false)); +#line 99 "runpicture.in" + addFunc(ve, run::gen_runpicture1, primBoolean(), SYM(empty), formal(primPicture(), SYM(f), false, false)); +#line 104 "runpicture.in" + addFunc(ve, run::gen_runpicture2, primVoid(), SYM(erase), formal(primPicture(), SYM(f), false, false)); +#line 109 "runpicture.in" + addFunc(ve, run::gen_runpicture3, primPair(), SYM(min), formal(primPicture(), SYM(f), false, false)); +#line 114 "runpicture.in" + addFunc(ve, run::gen_runpicture4, primPair(), SYM(max), formal(primPicture(), SYM(f), false, false)); +#line 119 "runpicture.in" + addFunc(ve, run::gen_runpicture5, primPair(), SYM(size), formal(primPicture(), SYM(f), false, false)); +#line 125 "runpicture.in" + addFunc(ve, run::gen_runpicture6, primVoid(), SYM(_draw), formal(primPicture(), SYM(f), false, false), formal(primPath(), SYM(g), false, false), formal(primPen(), SYM(p), false, false)); +#line 130 "runpicture.in" + addFunc(ve, run::gen_runpicture7, primVoid(), SYM(fill), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primPen(), SYM(p), true, false), formal(primBoolean(), SYM(copy), true, false)); +#line 136 "runpicture.in" + addFunc(ve, run::gen_runpicture8, primVoid(), SYM(latticeshade), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(fillrule), true, false), formal(penArray2() , SYM(p), false, false), formal(primTransform(), SYM(t), true, false), formal(primBoolean(), SYM(copy), true, false)); +#line 145 "runpicture.in" + addFunc(ve, run::gen_runpicture9, primVoid(), SYM(axialshade), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(pena), false, false), formal(primPair(), SYM(a), false, false), formal(primPen(), SYM(penb), false, false), formal(primPair(), SYM(b), false, false), formal(primBoolean(), SYM(copy), true, false)); +#line 152 "runpicture.in" + addFunc(ve, run::gen_runpicture10, primVoid(), SYM(radialshade), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(pena), false, false), formal(primPair(), SYM(a), false, false), formal(primReal(), SYM(ra), false, false), formal(primPen(), SYM(penb), false, false), formal(primPair(), SYM(b), false, false), formal(primReal(), SYM(rb), false, false), formal(primBoolean(), SYM(copy), true, false)); +#line 159 "runpicture.in" + addFunc(ve, run::gen_runpicture11, primVoid(), SYM(gouraudshade), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(fillrule), true, false), formal(penArray() , SYM(p), false, false), formal(pairArray(), SYM(z), false, false), formal(IntArray(), SYM(edges), false, false), formal(primBoolean(), SYM(copy), true, false)); +#line 170 "runpicture.in" + addFunc(ve, run::gen_runpicture12, primVoid(), SYM(gouraudshade), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(fillrule), true, false), formal(penArray() , SYM(p), false, false), formal(IntArray(), SYM(edges), false, false), formal(primBoolean(), SYM(copy), true, false)); +#line 194 "runpicture.in" + addFunc(ve, run::gen_runpicture13, primVoid(), SYM(tensorshade), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(fillrule), true, false), formal(penArray2() , SYM(p), false, false), formal(pathArray() , SYM(b), true, false), formal(pairArray2(), SYM(z), true, false), formal(primBoolean(), SYM(copy), true, false)); +#line 209 "runpicture.in" + addFunc(ve, run::gen_runpicture14, primVoid(), SYM(functionshade), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(fillrule), true, false), formal(primString() , SYM(shader), true, false), formal(primBoolean(), SYM(copy), true, false)); +#line 217 "runpicture.in" + addFunc(ve, run::gen_runpicture15, primVoid(), SYM(clip), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(fillrule), true, false), formal(primBoolean(), SYM(copy), true, false)); +#line 227 "runpicture.in" + addFunc(ve, run::gen_runpicture16, primVoid(), SYM(beginclip), formal(primPicture(), SYM(f), false, false), formal(pathArray() , SYM(g), false, false), formal(primBoolean(), SYM(stroke), true, false), formal(primPen(), SYM(fillrule), true, false), formal(primBoolean(), SYM(copy), true, false)); +#line 234 "runpicture.in" + addFunc(ve, run::gen_runpicture17, primVoid(), SYM(endclip), formal(primPicture(), SYM(f), false, false)); +#line 239 "runpicture.in" + addFunc(ve, run::gen_runpicture18, primVoid(), SYM(gsave), formal(primPicture(), SYM(f), false, false)); +#line 244 "runpicture.in" + addFunc(ve, run::gen_runpicture19, primVoid(), SYM(grestore), formal(primPicture(), SYM(f), false, false)); +#line 249 "runpicture.in" + addFunc(ve, run::gen_runpicture20, primVoid(), SYM(begingroup), formal(primPicture(), SYM(f), false, false)); +#line 254 "runpicture.in" + addFunc(ve, run::gen_runpicture21, primVoid(), SYM(endgroup), formal(primPicture(), SYM(f), false, false)); +#line 259 "runpicture.in" + addFunc(ve, run::gen_runpicture22, primVoid(), SYM(_begingroup3), formal(primPicture(), SYM(f), false, false), formal(primString() , SYM(name), false, false), formal(primReal(), SYM(compression), false, false), formal(primReal(), SYM(granularity), false, false), formal(primBoolean(), SYM(closed), false, false), formal(primBoolean(), SYM(tessellate), false, false), formal(primBoolean(), SYM(dobreak), false, false), formal(primBoolean(), SYM(nobreak), false, false), formal(primTriple(), SYM(center), false, false), formal(primInt(), SYM(interaction), false, false)); +#line 268 "runpicture.in" + addFunc(ve, run::gen_runpicture23, primVoid(), SYM(endgroup3), formal(primPicture(), SYM(f), false, false)); +#line 273 "runpicture.in" + addFunc(ve, run::gen_runpicture24, primVoid(), SYM(add), formal(primPicture(), SYM(dest), false, false), formal(primPicture(), SYM(src), false, false)); +#line 278 "runpicture.in" + addFunc(ve, run::gen_runpicture25, primVoid(), SYM(prepend), formal(primPicture(), SYM(dest), false, false), formal(primPicture(), SYM(src), false, false)); +#line 283 "runpicture.in" + addFunc(ve, run::gen_runpicture26, primVoid(), SYM(postscript), formal(primPicture(), SYM(f), false, false), formal(primString() , SYM(s), false, false)); +#line 288 "runpicture.in" + addFunc(ve, run::gen_runpicture27, primVoid(), SYM(tex), formal(primPicture(), SYM(f), false, false), formal(primString() , SYM(s), false, false)); +#line 293 "runpicture.in" + addFunc(ve, run::gen_runpicture28, primVoid(), SYM(postscript), formal(primPicture(), SYM(f), false, false), formal(primString() , SYM(s), false, false), formal(primPair(), SYM(min), false, false), formal(primPair(), SYM(max), false, false)); +#line 298 "runpicture.in" + addFunc(ve, run::gen_runpicture29, primVoid(), SYM(tex), formal(primPicture(), SYM(f), false, false), formal(primString() , SYM(s), false, false), formal(primPair(), SYM(min), false, false), formal(primPair(), SYM(max), false, false)); +#line 303 "runpicture.in" + addFunc(ve, run::gen_runpicture30, primVoid(), SYM(texpreamble), formal(primString() , SYM(s), false, false)); +#line 311 "runpicture.in" + addFunc(ve, run::gen_runpicture31, primVoid(), SYM(deletepreamble)); +#line 318 "runpicture.in" + addFunc(ve, run::gen_runpicture32, primVoid(), SYM(_labelpath), formal(primPicture(), SYM(f), false, false), formal(primString() , SYM(s), false, false), formal(primString() , SYM(size), false, false), formal(primPath(), SYM(g), false, false), formal(primString() , SYM(justify), false, false), formal(primPair(), SYM(offset), false, false), formal(primPen(), SYM(p), false, false)); +#line 324 "runpicture.in" + addFunc(ve, run::gen_runpicture33, primVoid(), SYM(texreset)); +#line 332 "runpicture.in" + addFunc(ve, run::gen_runpicture34, primVoid(), SYM(layer), formal(primPicture(), SYM(f), false, false)); +#line 337 "runpicture.in" + addFunc(ve, run::gen_runpicture35, primVoid(), SYM(newpage), formal(primPicture(), SYM(f), false, false)); +#line 342 "runpicture.in" + addFunc(ve, run::gen_runpicture36, primVoid(), SYM(_image), formal(primPicture(), SYM(f), false, false), formal(realArray2(), SYM(data), false, false), formal(primPair(), SYM(initial), false, false), formal(primPair(), SYM(final), false, false), formal(penArray() , SYM(palette), true, false), formal(primTransform(), SYM(t), true, false), formal(primBoolean(), SYM(copy), true, false), formal(primBoolean(), SYM(antialias), true, false)); +#line 352 "runpicture.in" + addFunc(ve, run::gen_runpicture37, primVoid(), SYM(_image), formal(primPicture(), SYM(f), false, false), formal(penArray2() , SYM(data), false, false), formal(primPair(), SYM(initial), false, false), formal(primPair(), SYM(final), false, false), formal(primTransform(), SYM(t), true, false), formal(primBoolean(), SYM(copy), true, false), formal(primBoolean(), SYM(antialias), true, false)); +#line 359 "runpicture.in" + addFunc(ve, run::gen_runpicture38, primString() , SYM(nativeformat)); +#line 364 "runpicture.in" + addFunc(ve, run::gen_runpicture39, primBoolean(), SYM(latex)); +#line 369 "runpicture.in" + addFunc(ve, run::gen_runpicture40, primBoolean(), SYM(pdf)); +#line 374 "runpicture.in" + addFunc(ve, run::gen_runpicture41, primVoid(), SYM(shipout), formal(primString() , SYM(prefix), true, false), formal(primPicture(), SYM(f), false, false), formal(primPicture(), SYM(preamble), true, false), formal(primString() , SYM(format), true, false), formal(primBoolean(), SYM(wait), true, false), formal(primBoolean(), SYM(view), true, false), formal(transformFunction(), SYM(xform), false, false)); +#line 420 "runpicture.in" + addFunc(ve, run::gen_runpicture42, primVoid(), SYM(shipout3), formal(primString() , SYM(prefix), false, false), formal(primPicture(), SYM(f), false, false), formal(primString() , SYM(format), true, false), formal(primReal(), SYM(width), false, false), formal(primReal(), SYM(height), false, false), formal(primReal(), SYM(angle), false, false), formal(primReal(), SYM(zoom), false, false), formal(primTriple(), SYM(m), false, false), formal(primTriple(), SYM(m), false, false), formal(primPair(), SYM(shift), false, false), formal(realArray2(), SYM(t), false, false), formal(realArray(), SYM(background), false, false), formal(tripleArray(), SYM(lights), false, false), formal(realArray2(), SYM(diffuse), false, false), formal(realArray2(), SYM(ambient), false, false), formal(realArray2(), SYM(specular), false, false), formal(primBoolean(), SYM(viewportlighting), false, false), formal(primBoolean(), SYM(view), true, false)); +#line 448 "runpicture.in" + addFunc(ve, run::gen_runpicture43, primVoid(), SYM(shipout3), formal(primString() , SYM(prefix), false, false), formal(primPicture(), SYM(f), false, false), formal(IntArray(), SYM(index), false, false), formal(tripleArray(), SYM(center), false, false)); +#line 453 "runpicture.in" + addFunc(ve, run::gen_runpicture44, primVoid(), SYM(deconstruct), formal(primPicture(), SYM(f), false, false), formal(primPicture(), SYM(preamble), true, false), formal(primReal(), SYM(magnification), true, false), formal(transformFunction(), SYM(xform), false, false)); +#line 576 "runpicture.in" + addFunc(ve, run::gen_runpicture45, primVoid(), SYM(_draw), formal(primPicture(), SYM(f), false, false), formal(primPath3(), SYM(g), false, false), formal(primPen(), SYM(p), false, false)); +#line 586 "runpicture.in" + addFunc(ve, run::gen_runpicture46, primVoid(), SYM(draw), formal(primPicture(), SYM(f), false, false), formal(tripleArray2(), SYM(p), false, false), formal(primTriple(), SYM(center), false, false), formal(primBoolean(), SYM(straight), false, false), formal(penArray() , SYM(p), false, false), formal(primReal(), SYM(opacity), false, false), formal(primReal(), SYM(shininess), false, false), formal(primReal(), SYM(prcshininess), false, false), formal(primTriple(), SYM(normal), false, false), formal(penArray() , SYM(colors), false, false), formal(primBoolean(), SYM(lighton), false, false), formal(primInt(), SYM(interaction), false, false), formal(primBoolean(), SYM(prc), true, false)); +#line 597 "runpicture.in" + addFunc(ve, run::gen_runpicture47, primVoid(), SYM(draw), formal(primPicture(), SYM(f), false, false), formal(tripleArray(), SYM(p), false, false), formal(realArray(), SYM(knot), false, false), formal(realArray(), SYM(weights), true, false), formal(primPen(), SYM(p), false, false)); +#line 604 "runpicture.in" + addFunc(ve, run::gen_runpicture48, primVoid(), SYM(draw), formal(primPicture(), SYM(f), false, false), formal(tripleArray2(), SYM(p), false, false), formal(realArray(), SYM(uknot), false, false), formal(realArray(), SYM(vknot), false, false), formal(realArray2(), SYM(weights), true, false), formal(penArray() , SYM(p), false, false), formal(primReal(), SYM(opacity), false, false), formal(primReal(), SYM(shininess), false, false), formal(primReal(), SYM(prcshininess), false, false), formal(penArray() , SYM(colors), false, false), formal(primBoolean(), SYM(lighton), false, false)); +#line 613 "runpicture.in" + addFunc(ve, run::gen_runpicture49, primVoid(), SYM(drawPRCsphere), formal(primPicture(), SYM(f), false, false), formal(realArray2(), SYM(t), false, false), formal(primBoolean(), SYM(half), true, false), formal(penArray() , SYM(p), false, false), formal(primReal(), SYM(opacity), false, false), formal(primReal(), SYM(shininess), false, false), formal(primInt(), SYM(type), false, false)); +#line 620 "runpicture.in" + addFunc(ve, run::gen_runpicture50, primVoid(), SYM(drawPRCcylinder), formal(primPicture(), SYM(f), false, false), formal(realArray2(), SYM(t), false, false), formal(penArray() , SYM(p), false, false), formal(primReal(), SYM(opacity), false, false), formal(primReal(), SYM(shininess), false, false)); +#line 627 "runpicture.in" + addFunc(ve, run::gen_runpicture51, primVoid(), SYM(drawPRCdisk), formal(primPicture(), SYM(f), false, false), formal(realArray2(), SYM(t), false, false), formal(penArray() , SYM(p), false, false), formal(primReal(), SYM(opacity), false, false), formal(primReal(), SYM(shininess), false, false)); +#line 634 "runpicture.in" + addFunc(ve, run::gen_runpicture52, primVoid(), SYM(drawPRCtube), formal(primPicture(), SYM(f), false, false), formal(primPath3(), SYM(center), false, false), formal(primPath3(), SYM(g), false, false), formal(penArray() , SYM(p), false, false), formal(primReal(), SYM(opacity), false, false), formal(primReal(), SYM(shininess), false, false)); +#line 641 "runpicture.in" + addFunc(ve, run::gen_runpicture53, primTriple(), SYM(min3), formal(primPicture(), SYM(f), false, false)); +#line 646 "runpicture.in" + addFunc(ve, run::gen_runpicture54, primTriple(), SYM(max3), formal(primPicture(), SYM(f), false, false)); +#line 651 "runpicture.in" + addFunc(ve, run::gen_runpicture55, primTriple(), SYM(size3), formal(primPicture(), SYM(f), false, false)); +#line 657 "runpicture.in" + addFunc(ve, run::gen_runpicture56, primPair(), SYM(minratio), formal(primPicture(), SYM(f), false, false)); +#line 662 "runpicture.in" + addFunc(ve, run::gen_runpicture57, primPair(), SYM(maxratio), formal(primPicture(), SYM(f), false, false)); +#line 667 "runpicture.in" + addFunc(ve, run::gen_runpicture58, primBoolean(), SYM(is3D), formal(primPicture(), SYM(f), false, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runpicture.in b/Build/source/utils/asymptote/runpicture.in index d5a7b32b618..710aa3e2e32 100644 --- a/Build/source/utils/asymptote/runpicture.in +++ b/Build/source/utils/asymptote/runpicture.in @@ -86,6 +86,8 @@ array *nop(array *a) return a; } +triple Zero; + // Autogenerated routines: @@ -244,9 +246,9 @@ void grestore(picture *f) f->append(new drawGrestore()); } -void begingroup(picture *f, string name=emptystring) +void begingroup(picture *f) { - f->append(new drawBegin(name)); + f->append(new drawBegin()); } void endgroup(picture *f) @@ -254,6 +256,20 @@ void endgroup(picture *f) f->append(new drawEnd()); } +void _begingroup3(picture *f, string name, real compression, + real granularity, bool closed, bool tessellate, + bool dobreak, bool nobreak, triple center, Int interaction) +{ + f->append(new drawBegin3(name,compression,granularity, + closed,tessellate,dobreak,nobreak, + center,(Interaction) intcast(interaction))); +} + +void endgroup3(picture *f) +{ + f->append(new drawEnd3()); +} + void add(picture *dest, picture *src) { dest->add(*src); @@ -561,38 +577,65 @@ void deconstruct(picture *f, picture *preamble=NULL, real magnification=1, // Three-dimensional picture and surface operations // Bezier curve -void _draw(picture *f, path3 g, pen p, string name=emptystring) +void _draw(picture *f, path3 g, pen p) { if(g.size() > 0) - f->append(new drawPath3(g,p,name)); + f->append(new drawPath3(g,p)); } // Bezier patch void draw(picture *f, triplearray2 *P, triple center, bool straight, penarray *p, real opacity, real shininess, real PRCshininess, - real granularity, triple normal, penarray *colors, bool lighton, - string name=emptystring, Int interaction) + triple normal, penarray *colors, bool lighton, + Int interaction, bool prc=true) { f->append(new drawSurface(*P,center,straight,*p,opacity,shininess, - PRCshininess,granularity,normal,*colors,lighton, - name,interaction)); + PRCshininess,normal,*colors,lighton, + (Interaction) intcast(interaction),prc)); } // General NURBS curve void draw(picture *f, triplearray *P, realarray *knot, - realarray *weights=emptyarray, pen p, string name=emptystring) + realarray *weights=emptyarray, pen p) { - f->append(new drawNurbsPath3(*P,knot,weights,p,name)); + f->append(new drawNurbsPath3(*P,knot,weights,p)); } // General NURBS surface void draw(picture *f, triplearray2 *P, realarray *uknot, realarray *vknot, - realarray2 *weights=emptyarray, penarray *p, - real opacity, real shininess, real PRCshininess, real granularity, - penarray *colors, bool lighton, string name=emptystring) + realarray2 *weights=emptyarray, penarray *p, real opacity, + real shininess, real PRCshininess, penarray *colors, bool lighton) { f->append(new drawNurbs(*P,uknot,vknot,weights,*p,opacity,shininess, - PRCshininess,granularity,*colors,lighton,name)); + PRCshininess,*colors,lighton)); +} + +// PRC unit sphere +void drawPRCsphere(picture *f, realarray2 *t, bool half=false, penarray *p, + real opacity, real shininess, Int type) +{ + f->append(new drawSphere(*t,half,*p,opacity,shininess,intcast(type))); +} + +// PRC unit cylinder +void drawPRCcylinder(picture *f, realarray2 *t, penarray *p, real opacity, + real shininess) +{ + f->append(new drawCylinder(*t,*p,opacity,shininess)); +} + +// PRC unit disk +void drawPRCdisk(picture *f, realarray2 *t, penarray *p, real opacity, + real shininess) +{ + f->append(new drawDisk(*t,*p,opacity,shininess)); +} + +// General PRC tube +void drawPRCtube(picture *f, path3 center, path3 g, penarray *p, real opacity, + real shininess) +{ + f->append(new drawTube(center,g,*p,opacity,shininess)); } triple min3(picture *f) diff --git a/Build/source/utils/asymptote/runpicture.symbols.h b/Build/source/utils/asymptote/runpicture.symbols.h new file mode 100644 index 00000000000..5d7daceeed1 --- /dev/null +++ b/Build/source/utils/asymptote/runpicture.symbols.h @@ -0,0 +1,136 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(_begingroup3); +ADDSYMBOL(_draw); +ADDSYMBOL(_image); +ADDSYMBOL(_labelpath); +ADDSYMBOL(a); +ADDSYMBOL(add); +ADDSYMBOL(ambient); +ADDSYMBOL(angle); +ADDSYMBOL(antialias); +ADDSYMBOL(axialshade); +ADDSYMBOL(b); +ADDSYMBOL(background); +ADDSYMBOL(beginclip); +ADDSYMBOL(begingroup); +ADDSYMBOL(center); +ADDSYMBOL(clip); +ADDSYMBOL(closed); +ADDSYMBOL(colors); +ADDSYMBOL(compression); +ADDSYMBOL(copy); +ADDSYMBOL(data); +ADDSYMBOL(deconstruct); +ADDSYMBOL(deletepreamble); +ADDSYMBOL(dest); +ADDSYMBOL(diffuse); +ADDSYMBOL(dobreak); +ADDSYMBOL(draw); +ADDSYMBOL(drawPRCcylinder); +ADDSYMBOL(drawPRCdisk); +ADDSYMBOL(drawPRCsphere); +ADDSYMBOL(drawPRCtube); +ADDSYMBOL(edges); +ADDSYMBOL(empty); +ADDSYMBOL(endclip); +ADDSYMBOL(endgroup); +ADDSYMBOL(endgroup3); +ADDSYMBOL(erase); +ADDSYMBOL(f); +ADDSYMBOL(fill); +ADDSYMBOL(fillrule); +ADDSYMBOL(final); +ADDSYMBOL(format); +ADDSYMBOL(functionshade); +ADDSYMBOL(g); +ADDSYMBOL(gouraudshade); +ADDSYMBOL(granularity); +ADDSYMBOL(grestore); +ADDSYMBOL(gsave); +ADDSYMBOL(half); +ADDSYMBOL(height); +ADDSYMBOL(index); +ADDSYMBOL(initial); +ADDSYMBOL(interaction); +ADDSYMBOL(is3D); +ADDSYMBOL(justify); +ADDSYMBOL(knot); +ADDSYMBOL(latex); +ADDSYMBOL(latticeshade); +ADDSYMBOL(layer); +ADDSYMBOL(lighton); +ADDSYMBOL(lights); +ADDSYMBOL(m); +ADDSYMBOL(magnification); +ADDSYMBOL(max); +ADDSYMBOL(max3); +ADDSYMBOL(maxratio); +ADDSYMBOL(min); +ADDSYMBOL(min3); +ADDSYMBOL(minratio); +ADDSYMBOL(name); +ADDSYMBOL(nativeformat); +ADDSYMBOL(newpage); +ADDSYMBOL(nobreak); +ADDSYMBOL(normal); +ADDSYMBOL(offset); +ADDSYMBOL(opacity); +ADDSYMBOL(p); +ADDSYMBOL(palette); +ADDSYMBOL(pdf); +ADDSYMBOL(pena); +ADDSYMBOL(penb); +ADDSYMBOL(postscript); +ADDSYMBOL(prc); +ADDSYMBOL(prcshininess); +ADDSYMBOL(preamble); +ADDSYMBOL(prefix); +ADDSYMBOL(prepend); +ADDSYMBOL(ra); +ADDSYMBOL(radialshade); +ADDSYMBOL(rb); +ADDSYMBOL(s); +ADDSYMBOL(shader); +ADDSYMBOL(shift); +ADDSYMBOL(shininess); +ADDSYMBOL(shipout); +ADDSYMBOL(shipout3); +ADDSYMBOL(size); +ADDSYMBOL(size3); +ADDSYMBOL(specular); +ADDSYMBOL(src); +ADDSYMBOL(straight); +ADDSYMBOL(stroke); +ADDSYMBOL(t); +ADDSYMBOL(tensorshade); +ADDSYMBOL(tessellate); +ADDSYMBOL(tex); +ADDSYMBOL(texpreamble); +ADDSYMBOL(texreset); +ADDSYMBOL(type); +ADDSYMBOL(uknot); +ADDSYMBOL(view); +ADDSYMBOL(viewportlighting); +ADDSYMBOL(vknot); +ADDSYMBOL(wait); +ADDSYMBOL(weights); +ADDSYMBOL(width); +ADDSYMBOL(xform); +ADDSYMBOL(z); +ADDSYMBOL(zoom); diff --git a/Build/source/utils/asymptote/runstring.cc b/Build/source/utils/asymptote/runstring.cc index 91b58a9719a..e251957a4e9 100644 --- a/Build/source/utils/asymptote/runstring.cc +++ b/Build/source/utils/asymptote/runstring.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -207,6 +208,8 @@ void checkformat(const char *ptr, bool intformat) +#include "runstring.symbols.h" + namespace run { // String operations #line 112 "runstring.in" @@ -599,41 +602,41 @@ void gen_runstring_venv(venv &ve) #line 111 "runstring.in" REGISTER_BLTIN(run::emptyString,"emptyString"); #line 118 "runstring.in" - addFunc(ve, run::gen_runstring1, primInt(), "length", formal(primString(), "s", false, false)); + addFunc(ve, run::gen_runstring1, primInt(), SYM(length), formal(primString(), SYM(s), false, false)); #line 123 "runstring.in" - addFunc(ve, run::gen_runstring2, primInt(), "find", formal(primString(), "s", false, false), formal(primString() , "t", false, false), formal(primInt(), "pos", true, false)); + addFunc(ve, run::gen_runstring2, primInt(), SYM(find), formal(primString(), SYM(s), false, false), formal(primString() , SYM(t), false, false), formal(primInt(), SYM(pos), true, false)); #line 129 "runstring.in" - addFunc(ve, run::gen_runstring3, primInt(), "rfind", formal(primString(), "s", false, false), formal(primString() , "t", false, false), formal(primInt(), "pos", true, false)); + addFunc(ve, run::gen_runstring3, primInt(), SYM(rfind), formal(primString(), SYM(s), false, false), formal(primString() , SYM(t), false, false), formal(primInt(), SYM(pos), true, false)); #line 135 "runstring.in" - addFunc(ve, run::gen_runstring4, primString() , "reverse", formal(primString() , "s", false, false)); + addFunc(ve, run::gen_runstring4, primString() , SYM(reverse), formal(primString() , SYM(s), false, false)); #line 141 "runstring.in" - addFunc(ve, run::gen_runstring5, primString() , "insert", formal(primString() , "s", false, false), formal(primInt(), "pos", false, false), formal(primString() , "t", false, false)); + addFunc(ve, run::gen_runstring5, primString() , SYM(insert), formal(primString() , SYM(s), false, false), formal(primInt(), SYM(pos), false, false), formal(primString() , SYM(t), false, false)); #line 148 "runstring.in" - addFunc(ve, run::gen_runstring6, primString() , "substr", formal(primString(), "s", false, false), formal(primInt(), "pos", false, false), formal(primInt(), "n", true, false)); + addFunc(ve, run::gen_runstring6, primString() , SYM(substr), formal(primString(), SYM(s), false, false), formal(primInt(), SYM(pos), false, false), formal(primInt(), SYM(n), true, false)); #line 155 "runstring.in" - addFunc(ve, run::gen_runstring7, primString() , "erase", formal(primString() , "s", false, false), formal(primInt(), "pos", false, false), formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runstring7, primString() , SYM(erase), formal(primString() , SYM(s), false, false), formal(primInt(), SYM(pos), false, false), formal(primInt(), SYM(n), false, false)); #line 162 "runstring.in" - addFunc(ve, run::gen_runstring8, primString() , "downcase", formal(primString() , "s", false, false)); + addFunc(ve, run::gen_runstring8, primString() , SYM(downcase), formal(primString() , SYM(s), false, false)); #line 168 "runstring.in" - addFunc(ve, run::gen_runstring9, primString() , "upcase", formal(primString() , "s", false, false)); + addFunc(ve, run::gen_runstring9, primString() , SYM(upcase), formal(primString() , SYM(s), false, false)); #line 174 "runstring.in" - addFunc(ve, run::gen_runstring10, primString() , "replace", formal(primString(), "s", false, false), formal(stringArray2(), "translate", false, false)); + addFunc(ve, run::gen_runstring10, primString() , SYM(replace), formal(primString(), SYM(s), false, false), formal(stringArray2(), SYM(translate), false, false)); #line 201 "runstring.in" - addFunc(ve, run::gen_runstring11, primString() , "format", formal(primString(), "format", false, false), formal(primInt(), "x", false, false)); + addFunc(ve, run::gen_runstring11, primString() , SYM(format), formal(primString(), SYM(format), false, false), formal(primInt(), SYM(x), false, false)); #line 216 "runstring.in" - addFunc(ve, run::gen_runstring12, primString() , "format", formal(primString(), "format", false, false), formal(primReal(), "x", false, false), formal(primString() , "locale", true, false)); + addFunc(ve, run::gen_runstring12, primString() , SYM(format), formal(primString(), SYM(format), false, false), formal(primReal(), SYM(x), false, false), formal(primString() , SYM(locale), true, false)); #line 341 "runstring.in" - addFunc(ve, run::gen_runstring13, primInt(), "hex", formal(primString() , "s", false, false)); + addFunc(ve, run::gen_runstring13, primInt(), SYM(hex), formal(primString() , SYM(s), false, false)); #line 352 "runstring.in" - addFunc(ve, run::gen_runstring14, primString() , "string", formal(primInt(), "x", false, false)); + addFunc(ve, run::gen_runstring14, primString() , SYM(string), formal(primInt(), SYM(x), false, false)); #line 359 "runstring.in" - addFunc(ve, run::gen_runstring15, primString() , "string", formal(primReal(), "x", false, false), formal(primInt(), "digits", true, false)); + addFunc(ve, run::gen_runstring15, primString() , SYM(string), formal(primReal(), SYM(x), false, false), formal(primInt(), SYM(digits), true, false)); #line 367 "runstring.in" - addFunc(ve, run::gen_runstring16, primString() , "time", formal(primString() , "format", true, false)); + addFunc(ve, run::gen_runstring16, primString() , SYM(time), formal(primString() , SYM(format), true, false)); #line 378 "runstring.in" - addFunc(ve, run::gen_runstring17, primString() , "time", formal(primInt(), "seconds", false, false), formal(primString() , "format", true, false)); + addFunc(ve, run::gen_runstring17, primString() , SYM(time), formal(primInt(), SYM(seconds), false, false), formal(primString() , SYM(format), true, false)); #line 391 "runstring.in" - addFunc(ve, run::gen_runstring18, primInt(), "seconds", formal(primString() , "t", true, false), formal(primString() , "format", true, false)); + addFunc(ve, run::gen_runstring18, primInt(), SYM(seconds), formal(primString() , SYM(t), true, false), formal(primString() , SYM(format), true, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runstring.symbols.h b/Build/source/utils/asymptote/runstring.symbols.h new file mode 100644 index 00000000000..6ab67c65a08 --- /dev/null +++ b/Build/source/utils/asymptote/runstring.symbols.h @@ -0,0 +1,40 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(digits); +ADDSYMBOL(downcase); +ADDSYMBOL(erase); +ADDSYMBOL(find); +ADDSYMBOL(format); +ADDSYMBOL(hex); +ADDSYMBOL(insert); +ADDSYMBOL(length); +ADDSYMBOL(locale); +ADDSYMBOL(n); +ADDSYMBOL(pos); +ADDSYMBOL(replace); +ADDSYMBOL(reverse); +ADDSYMBOL(rfind); +ADDSYMBOL(s); +ADDSYMBOL(seconds); +ADDSYMBOL(string); +ADDSYMBOL(substr); +ADDSYMBOL(t); +ADDSYMBOL(time); +ADDSYMBOL(translate); +ADDSYMBOL(upcase); +ADDSYMBOL(x); diff --git a/Build/source/utils/asymptote/runsystem.cc b/Build/source/utils/asymptote/runsystem.cc index b1924985222..f1c4ad3b2be 100644 --- a/Build/source/utils/asymptote/runsystem.cc +++ b/Build/source/utils/asymptote/runsystem.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -203,6 +204,8 @@ void exitFunction(stack *Stack) // Autogenerated routines: +#include "runsystem.symbols.h" + namespace run { #line 109 "runsystem.in" // string outname(); @@ -448,47 +451,47 @@ namespace trans { void gen_runsystem_venv(venv &ve) { #line 109 "runsystem.in" - addFunc(ve, run::gen_runsystem0, primString() , "outname"); + addFunc(ve, run::gen_runsystem0, primString() , SYM(outname)); #line 114 "runsystem.in" - addFunc(ve, run::gen_runsystem1, primVoid(), "atupdate", formal(voidFunction(), "f", false, false)); + addFunc(ve, run::gen_runsystem1, primVoid(), SYM(atupdate), formal(voidFunction(), SYM(f), false, false)); #line 119 "runsystem.in" - addFunc(ve, run::gen_runsystem2, voidFunction(), "atupdate"); + addFunc(ve, run::gen_runsystem2, voidFunction(), SYM(atupdate)); #line 124 "runsystem.in" - addFunc(ve, run::gen_runsystem3, primVoid(), "atexit", formal(voidFunction(), "f", false, false)); + addFunc(ve, run::gen_runsystem3, primVoid(), SYM(atexit), formal(voidFunction(), SYM(f), false, false)); #line 129 "runsystem.in" - addFunc(ve, run::gen_runsystem4, voidFunction(), "atexit"); + addFunc(ve, run::gen_runsystem4, voidFunction(), SYM(atexit)); #line 134 "runsystem.in" - addFunc(ve, run::gen_runsystem5, primVoid(), "atbreakpoint", formal(breakpointFunction(), "f", false, false)); + addFunc(ve, run::gen_runsystem5, primVoid(), SYM(atbreakpoint), formal(breakpointFunction(), SYM(f), false, false)); #line 139 "runsystem.in" - addFunc(ve, run::gen_runsystem6, primVoid(), "breakpoint", formal(primCode(), "s", true, false)); + addFunc(ve, run::gen_runsystem6, primVoid(), SYM(breakpoint), formal(primCode(), SYM(s), true, false)); #line 144 "runsystem.in" - addFunc(ve, run::gen_runsystem7, primString() , "locatefile", formal(primString() , "file", false, false)); + addFunc(ve, run::gen_runsystem7, primString() , SYM(locatefile), formal(primString() , SYM(file), false, false)); #line 149 "runsystem.in" - addFunc(ve, run::gen_runsystem8, primVoid(), "stop", formal(primString() , "file", false, false), formal(primInt(), "line", false, false), formal(primCode(), "s", true, false)); + addFunc(ve, run::gen_runsystem8, primVoid(), SYM(stop), formal(primString() , SYM(file), false, false), formal(primInt(), SYM(line), false, false), formal(primCode(), SYM(s), true, false)); #line 157 "runsystem.in" - addFunc(ve, run::gen_runsystem9, primVoid(), "breakpoints"); + addFunc(ve, run::gen_runsystem9, primVoid(), SYM(breakpoints)); #line 163 "runsystem.in" - addFunc(ve, run::gen_runsystem10, primVoid(), "clear", formal(primString() , "file", false, false), formal(primInt(), "line", false, false)); + addFunc(ve, run::gen_runsystem10, primVoid(), SYM(clear), formal(primString() , SYM(file), false, false), formal(primInt(), SYM(line), false, false)); #line 169 "runsystem.in" - addFunc(ve, run::gen_runsystem11, primVoid(), "clear"); + addFunc(ve, run::gen_runsystem11, primVoid(), SYM(clear)); #line 174 "runsystem.in" - addFunc(ve, run::gen_runsystem12, primVoid(), "warn", formal(primString() , "s", false, false)); + addFunc(ve, run::gen_runsystem12, primVoid(), SYM(warn), formal(primString() , SYM(s), false, false)); #line 179 "runsystem.in" - addFunc(ve, run::gen_runsystem13, primVoid(), "nowarn", formal(primString() , "s", false, false)); + addFunc(ve, run::gen_runsystem13, primVoid(), SYM(nowarn), formal(primString() , SYM(s), false, false)); #line 184 "runsystem.in" - addFunc(ve, run::gen_runsystem14, primVoid(), "warning", formal(primString() , "s", false, false), formal(primString() , "t", false, false), formal(primBoolean(), "position", true, false)); + addFunc(ve, run::gen_runsystem14, primVoid(), SYM(warning), formal(primString() , SYM(s), false, false), formal(primString() , SYM(t), false, false), formal(primBoolean(), SYM(position), true, false)); #line 192 "runsystem.in" - addFunc(ve, run::gen_runsystem15, primString() , "stripdirectory", formal(primString(), "s", false, false)); + addFunc(ve, run::gen_runsystem15, primString() , SYM(stripdirectory), formal(primString(), SYM(s), false, false)); #line 198 "runsystem.in" - addFunc(ve, run::gen_runsystem16, primString() , "stripfile", formal(primString(), "s", false, false)); + addFunc(ve, run::gen_runsystem16, primString() , SYM(stripfile), formal(primString(), SYM(s), false, false)); #line 204 "runsystem.in" - addFunc(ve, run::gen_runsystem17, primString() , "stripextension", formal(primString(), "s", false, false)); + addFunc(ve, run::gen_runsystem17, primString() , SYM(stripextension), formal(primString(), SYM(s), false, false)); #line 210 "runsystem.in" - addFunc(ve, run::gen_runsystem18, primInt(), "convert", formal(primString() , "args", true, false), formal(primString() , "file", true, false), formal(primString() , "format", true, false)); + addFunc(ve, run::gen_runsystem18, primInt(), SYM(convert), formal(primString() , SYM(args), true, false), formal(primString() , SYM(file), true, false), formal(primString() , SYM(format), true, false)); #line 238 "runsystem.in" - addFunc(ve, run::gen_runsystem19, primInt(), "animate", formal(primString() , "args", true, false), formal(primString() , "file", true, false), formal(primString() , "format", true, false)); + addFunc(ve, run::gen_runsystem19, primInt(), SYM(animate), formal(primString() , SYM(args), true, false), formal(primString() , SYM(file), true, false), formal(primString() , SYM(format), true, false)); #line 255 "runsystem.in" - addFunc(ve, run::gen_runsystem20, primVoid(), "purge", formal(primInt(), "divisor", true, false)); + addFunc(ve, run::gen_runsystem20, primVoid(), SYM(purge), formal(primInt(), SYM(divisor), true, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runsystem.symbols.h b/Build/source/utils/asymptote/runsystem.symbols.h new file mode 100644 index 00000000000..c6071f901d5 --- /dev/null +++ b/Build/source/utils/asymptote/runsystem.symbols.h @@ -0,0 +1,44 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(animate); +ADDSYMBOL(args); +ADDSYMBOL(atbreakpoint); +ADDSYMBOL(atexit); +ADDSYMBOL(atupdate); +ADDSYMBOL(breakpoint); +ADDSYMBOL(breakpoints); +ADDSYMBOL(clear); +ADDSYMBOL(convert); +ADDSYMBOL(divisor); +ADDSYMBOL(f); +ADDSYMBOL(file); +ADDSYMBOL(format); +ADDSYMBOL(line); +ADDSYMBOL(locatefile); +ADDSYMBOL(nowarn); +ADDSYMBOL(outname); +ADDSYMBOL(position); +ADDSYMBOL(purge); +ADDSYMBOL(s); +ADDSYMBOL(stop); +ADDSYMBOL(stripdirectory); +ADDSYMBOL(stripextension); +ADDSYMBOL(stripfile); +ADDSYMBOL(t); +ADDSYMBOL(warn); +ADDSYMBOL(warning); diff --git a/Build/source/utils/asymptote/runtime.cc b/Build/source/utils/asymptote/runtime.cc index e71e6b0e3d1..6d32c064def 100644 --- a/Build/source/utils/asymptote/runtime.cc +++ b/Build/source/utils/asymptote/runtime.cc @@ -39,6 +39,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -271,6 +272,8 @@ void unused(void *) +#include "runtime.symbols.h" + namespace run { // Initializers @@ -1832,153 +1835,153 @@ void gen_runtime_venv(venv &ve) #line 276 "runtime.in" REGISTER_BLTIN(run::newPen,"newPen"); #line 284 "runtime.in" - addFunc(ve, run::gen_runtime12, primBoolean(), "==", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false)); + addFunc(ve, run::gen_runtime12, primBoolean(), SYM_EQ, formal(primPen(), SYM(a), false, false), formal(primPen(), SYM(b), false, false)); #line 289 "runtime.in" - addFunc(ve, run::gen_runtime13, primBoolean(), "!=", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false)); + addFunc(ve, run::gen_runtime13, primBoolean(), SYM_NEQ, formal(primPen(), SYM(a), false, false), formal(primPen(), SYM(b), false, false)); #line 294 "runtime.in" - addFunc(ve, run::gen_runtime14, primPen(), "+", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false)); + addFunc(ve, run::gen_runtime14, primPen(), SYM_PLUS, formal(primPen(), SYM(a), false, false), formal(primPen(), SYM(b), false, false)); #line 299 "runtime.in" - addFunc(ve, run::gen_runtime15, primPen(), "*", formal(primReal(), "a", false, false), formal(primPen(), "b", false, false)); + addFunc(ve, run::gen_runtime15, primPen(), SYM_TIMES, formal(primReal(), SYM(a), false, false), formal(primPen(), SYM(b), false, false)); #line 304 "runtime.in" - addFunc(ve, run::gen_runtime16, primPen(), "*", formal(primPen(), "a", false, false), formal(primReal(), "b", false, false)); + addFunc(ve, run::gen_runtime16, primPen(), SYM_TIMES, formal(primPen(), SYM(a), false, false), formal(primReal(), SYM(b), false, false)); #line 309 "runtime.in" - addFunc(ve, run::gen_runtime17, primPair(), "max", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime17, primPair(), SYM(max), formal(primPen(), SYM(p), false, false)); #line 314 "runtime.in" - addFunc(ve, run::gen_runtime18, primPair(), "min", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime18, primPair(), SYM(min), formal(primPen(), SYM(p), false, false)); #line 319 "runtime.in" - addFunc(ve, run::gen_runtime19, primVoid(), "resetdefaultpen"); + addFunc(ve, run::gen_runtime19, primVoid(), SYM(resetdefaultpen)); #line 325 "runtime.in" - addFunc(ve, run::gen_runtime20, primVoid(), "defaultpen", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime20, primVoid(), SYM(defaultpen), formal(primPen(), SYM(p), false, false)); #line 330 "runtime.in" - addFunc(ve, run::gen_runtime21, primPen(), "defaultpen"); + addFunc(ve, run::gen_runtime21, primPen(), SYM(defaultpen)); #line 335 "runtime.in" - addFunc(ve, run::gen_runtime22, primBoolean(), "invisible", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime22, primBoolean(), SYM(invisible), formal(primPen(), SYM(p), false, false)); #line 340 "runtime.in" - addFunc(ve, run::gen_runtime23, primPen(), "invisible"); + addFunc(ve, run::gen_runtime23, primPen(), SYM(invisible)); #line 345 "runtime.in" - addFunc(ve, run::gen_runtime24, primPen(), "gray", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime24, primPen(), SYM(gray), formal(primPen(), SYM(p), false, false)); #line 351 "runtime.in" - addFunc(ve, run::gen_runtime25, primPen(), "rgb", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime25, primPen(), SYM(rgb), formal(primPen(), SYM(p), false, false)); #line 357 "runtime.in" - addFunc(ve, run::gen_runtime26, primPen(), "cmyk", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime26, primPen(), SYM(cmyk), formal(primPen(), SYM(p), false, false)); #line 363 "runtime.in" - addFunc(ve, run::gen_runtime27, primPen(), "interp", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runtime27, primPen(), SYM(interp), formal(primPen(), SYM(a), false, false), formal(primPen(), SYM(b), false, false), formal(primReal(), SYM(t), false, false)); #line 368 "runtime.in" - addFunc(ve, run::gen_runtime28, primPen(), "rgb", formal(primReal(), "r", false, false), formal(primReal(), "g", false, false), formal(primReal(), "b", false, false)); + addFunc(ve, run::gen_runtime28, primPen(), SYM(rgb), formal(primReal(), SYM(r), false, false), formal(primReal(), SYM(g), false, false), formal(primReal(), SYM(b), false, false)); #line 373 "runtime.in" - addFunc(ve, run::gen_runtime29, primPen(), "cmyk", formal(primReal(), "c", false, false), formal(primReal(), "m", false, false), formal(primReal(), "y", false, false), formal(primReal(), "k", false, false)); + addFunc(ve, run::gen_runtime29, primPen(), SYM(cmyk), formal(primReal(), SYM(c), false, false), formal(primReal(), SYM(m), false, false), formal(primReal(), SYM(y), false, false), formal(primReal(), SYM(k), false, false)); #line 378 "runtime.in" - addFunc(ve, run::gen_runtime30, primPen(), "gray", formal(primReal(), "gray", false, false)); + addFunc(ve, run::gen_runtime30, primPen(), SYM(gray), formal(primReal(), SYM(gray), false, false)); #line 383 "runtime.in" - addFunc(ve, run::gen_runtime31, realArray(), "colors", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime31, realArray(), SYM(colors), formal(primPen(), SYM(p), false, false)); #line 411 "runtime.in" - addFunc(ve, run::gen_runtime32, primString() , "hex", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime32, primString() , SYM(hex), formal(primPen(), SYM(p), false, false)); #line 416 "runtime.in" - addFunc(ve, run::gen_runtime33, primInt(), "byte", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runtime33, primInt(), SYM(byte), formal(primReal(), SYM(x), false, false)); #line 421 "runtime.in" - addFunc(ve, run::gen_runtime34, primString() , "colorspace", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime34, primString() , SYM(colorspace), formal(primPen(), SYM(p), false, false)); #line 428 "runtime.in" - addFunc(ve, run::gen_runtime35, primPen(), "pattern", formal(primString(), "s", false, false)); + addFunc(ve, run::gen_runtime35, primPen(), SYM(pattern), formal(primString(), SYM(s), false, false)); #line 433 "runtime.in" - addFunc(ve, run::gen_runtime36, primString() , "pattern", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime36, primString() , SYM(pattern), formal(primPen(), SYM(p), false, false)); #line 438 "runtime.in" - addFunc(ve, run::gen_runtime37, primPen(), "fillrule", formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runtime37, primPen(), SYM(fillrule), formal(primInt(), SYM(n), false, false)); #line 443 "runtime.in" - addFunc(ve, run::gen_runtime38, primInt(), "fillrule", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime38, primInt(), SYM(fillrule), formal(primPen(), SYM(p), false, false)); #line 448 "runtime.in" - addFunc(ve, run::gen_runtime39, primPen(), "opacity", formal(primReal(), "opacity", true, false), formal(primString() , "blend", true, false)); + addFunc(ve, run::gen_runtime39, primPen(), SYM(opacity), formal(primReal(), SYM(opacity), true, false), formal(primString() , SYM(blend), true, false)); #line 458 "runtime.in" - addFunc(ve, run::gen_runtime40, primReal(), "opacity", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime40, primReal(), SYM(opacity), formal(primPen(), SYM(p), false, false)); #line 463 "runtime.in" - addFunc(ve, run::gen_runtime41, primString() , "blend", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime41, primString() , SYM(blend), formal(primPen(), SYM(p), false, false)); #line 468 "runtime.in" - addFunc(ve, run::gen_runtime42, primPen(), "linetype", formal(realArray(), "pattern", false, false), formal(primReal(), "offset", true, false), formal(primBoolean(), "scale", true, false), formal(primBoolean(), "adjust", true, false)); + addFunc(ve, run::gen_runtime42, primPen(), SYM(linetype), formal(realArray(), SYM(pattern), false, false), formal(primReal(), SYM(offset), true, false), formal(primBoolean(), SYM(scale), true, false), formal(primBoolean(), SYM(adjust), true, false)); #line 479 "runtime.in" - addFunc(ve, run::gen_runtime43, realArray(), "linetype", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime43, realArray(), SYM(linetype), formal(primPen(), SYM(p), true, false)); #line 485 "runtime.in" - addFunc(ve, run::gen_runtime44, primReal(), "offset", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime44, primReal(), SYM(offset), formal(primPen(), SYM(p), false, false)); #line 490 "runtime.in" - addFunc(ve, run::gen_runtime45, primBoolean(), "scale", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime45, primBoolean(), SYM(scale), formal(primPen(), SYM(p), false, false)); #line 495 "runtime.in" - addFunc(ve, run::gen_runtime46, primBoolean(), "adjust", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime46, primBoolean(), SYM(adjust), formal(primPen(), SYM(p), false, false)); #line 500 "runtime.in" - addFunc(ve, run::gen_runtime47, primPen(), "adjust", formal(primPen(), "p", false, false), formal(primReal(), "arclength", false, false), formal(primBoolean(), "cyclic", false, false)); + addFunc(ve, run::gen_runtime47, primPen(), SYM(adjust), formal(primPen(), SYM(p), false, false), formal(primReal(), SYM(arclength), false, false), formal(primBoolean(), SYM(cyclic), false, false)); #line 505 "runtime.in" - addFunc(ve, run::gen_runtime48, primPen(), "linecap", formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runtime48, primPen(), SYM(linecap), formal(primInt(), SYM(n), false, false)); #line 510 "runtime.in" - addFunc(ve, run::gen_runtime49, primInt(), "linecap", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime49, primInt(), SYM(linecap), formal(primPen(), SYM(p), true, false)); #line 515 "runtime.in" - addFunc(ve, run::gen_runtime50, primPen(), "linejoin", formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runtime50, primPen(), SYM(linejoin), formal(primInt(), SYM(n), false, false)); #line 520 "runtime.in" - addFunc(ve, run::gen_runtime51, primInt(), "linejoin", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime51, primInt(), SYM(linejoin), formal(primPen(), SYM(p), true, false)); #line 525 "runtime.in" - addFunc(ve, run::gen_runtime52, primPen(), "miterlimit", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runtime52, primPen(), SYM(miterlimit), formal(primReal(), SYM(x), false, false)); #line 530 "runtime.in" - addFunc(ve, run::gen_runtime53, primReal(), "miterlimit", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime53, primReal(), SYM(miterlimit), formal(primPen(), SYM(p), true, false)); #line 535 "runtime.in" - addFunc(ve, run::gen_runtime54, primPen(), "linewidth", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runtime54, primPen(), SYM(linewidth), formal(primReal(), SYM(x), false, false)); #line 540 "runtime.in" - addFunc(ve, run::gen_runtime55, primReal(), "linewidth", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime55, primReal(), SYM(linewidth), formal(primPen(), SYM(p), true, false)); #line 545 "runtime.in" - addFunc(ve, run::gen_runtime56, primPen(), "fontcommand", formal(primString(), "s", false, false)); + addFunc(ve, run::gen_runtime56, primPen(), SYM(fontcommand), formal(primString(), SYM(s), false, false)); #line 550 "runtime.in" - addFunc(ve, run::gen_runtime57, primString() , "font", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime57, primString() , SYM(font), formal(primPen(), SYM(p), true, false)); #line 555 "runtime.in" - addFunc(ve, run::gen_runtime58, primPen(), "fontsize", formal(primReal(), "size", false, false), formal(primReal(), "lineskip", false, false)); + addFunc(ve, run::gen_runtime58, primPen(), SYM(fontsize), formal(primReal(), SYM(size), false, false), formal(primReal(), SYM(lineskip), false, false)); #line 561 "runtime.in" - addFunc(ve, run::gen_runtime59, primReal(), "fontsize", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime59, primReal(), SYM(fontsize), formal(primPen(), SYM(p), true, false)); #line 566 "runtime.in" - addFunc(ve, run::gen_runtime60, primReal(), "lineskip", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime60, primReal(), SYM(lineskip), formal(primPen(), SYM(p), true, false)); #line 571 "runtime.in" - addFunc(ve, run::gen_runtime61, primPen(), "overwrite", formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runtime61, primPen(), SYM(overwrite), formal(primInt(), SYM(n), false, false)); #line 577 "runtime.in" - addFunc(ve, run::gen_runtime62, primInt(), "overwrite", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime62, primInt(), SYM(overwrite), formal(primPen(), SYM(p), true, false)); #line 582 "runtime.in" - addFunc(ve, run::gen_runtime63, primPen(), "basealign", formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runtime63, primPen(), SYM(basealign), formal(primInt(), SYM(n), false, false)); #line 587 "runtime.in" - addFunc(ve, run::gen_runtime64, primInt(), "basealign", formal(primPen(), "p", true, false)); + addFunc(ve, run::gen_runtime64, primInt(), SYM(basealign), formal(primPen(), SYM(p), true, false)); #line 592 "runtime.in" - addFunc(ve, run::gen_runtime65, primTransform(), "transform", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime65, primTransform(), SYM(transform), formal(primPen(), SYM(p), false, false)); #line 597 "runtime.in" - addFunc(ve, run::gen_runtime66, primPath(), "nib", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime66, primPath(), SYM(nib), formal(primPen(), SYM(p), false, false)); #line 602 "runtime.in" - addFunc(ve, run::gen_runtime67, primPen(), "makepen", formal(primPath(), "p", false, false)); + addFunc(ve, run::gen_runtime67, primPen(), SYM(makepen), formal(primPath(), SYM(p), false, false)); #line 607 "runtime.in" - addFunc(ve, run::gen_runtime68, primPen(), "colorless", formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime68, primPen(), SYM(colorless), formal(primPen(), SYM(p), false, false)); #line 613 "runtime.in" - addFunc(ve, run::gen_runtime69, primBoolean(), "interactive"); + addFunc(ve, run::gen_runtime69, primBoolean(), SYM(interactive)); #line 620 "runtime.in" - addFunc(ve, run::gen_runtime70, primBoolean(), "uptodate"); + addFunc(ve, run::gen_runtime70, primBoolean(), SYM(uptodate)); #line 625 "runtime.in" - addFunc(ve, run::gen_runtime71, primInt(), "system", formal(stringArray(), "s", false, false)); + addFunc(ve, run::gen_runtime71, primInt(), SYM(system), formal(stringArray(), SYM(s), false, false)); #line 639 "runtime.in" - addFunc(ve, run::gen_runtime72, primBoolean(), "view"); + addFunc(ve, run::gen_runtime72, primBoolean(), SYM(view)); #line 644 "runtime.in" - addFunc(ve, run::gen_runtime73, primString() , "asydir"); + addFunc(ve, run::gen_runtime73, primString() , SYM(asydir)); #line 649 "runtime.in" - addFunc(ve, run::gen_runtime74, primString() , "locale", formal(primString() , "s", true, false)); + addFunc(ve, run::gen_runtime74, primString() , SYM(locale), formal(primString() , SYM(s), true, false)); #line 655 "runtime.in" - addFunc(ve, run::gen_runtime75, primVoid(), "abort", formal(primString() , "s", true, false)); + addFunc(ve, run::gen_runtime75, primVoid(), SYM(abort), formal(primString() , SYM(s), true, false)); #line 661 "runtime.in" - addFunc(ve, run::gen_runtime76, primVoid(), "exit"); + addFunc(ve, run::gen_runtime76, primVoid(), SYM(exit)); #line 666 "runtime.in" - addFunc(ve, run::gen_runtime77, primVoid(), "assert", formal(primBoolean(), "b", false, false), formal(primString() , "s", true, false)); + addFunc(ve, run::gen_runtime77, primVoid(), SYM(assert), formal(primBoolean(), SYM(b), false, false), formal(primString() , SYM(s), true, false)); #line 677 "runtime.in" - addFunc(ve, run::gen_runtime78, primVoid(), "sleep", formal(primInt(), "seconds", false, false)); + addFunc(ve, run::gen_runtime78, primVoid(), SYM(sleep), formal(primInt(), SYM(seconds), false, false)); #line 683 "runtime.in" - addFunc(ve, run::gen_runtime79, primVoid(), "usleep", formal(primInt(), "microseconds", false, false)); + addFunc(ve, run::gen_runtime79, primVoid(), SYM(usleep), formal(primInt(), SYM(microseconds), false, false)); #line 689 "runtime.in" - addFunc(ve, run::gen_runtime80, primVoid(), "_eval", formal(primString(), "s", false, false), formal(primBoolean(), "embedded", false, false), formal(primBoolean(), "interactivewrite", true, false)); + addFunc(ve, run::gen_runtime80, primVoid(), SYM(_eval), formal(primString(), SYM(s), false, false), formal(primBoolean(), SYM(embedded), false, false), formal(primBoolean(), SYM(interactivewrite), true, false)); #line 702 "runtime.in" - addFunc(ve, run::gen_runtime81, primVoid(), "_eval", formal(primCode(), "s", false, false), formal(primBoolean(), "embedded", false, false)); + addFunc(ve, run::gen_runtime81, primVoid(), SYM(_eval), formal(primCode(), SYM(s), false, false), formal(primBoolean(), SYM(embedded), false, false)); #line 718 "runtime.in" - addFunc(ve, run::gen_runtime82, primString() , "location"); + addFunc(ve, run::gen_runtime82, primString() , SYM(location)); #line 724 "runtime.in" REGISTER_BLTIN(run::loadModule,"loadModule"); #line 730 "runtime.in" - addFunc(ve, run::gen_runtime84, primString() , "cd", formal(primString() , "s", true, false)); + addFunc(ve, run::gen_runtime84, primString() , SYM(cd), formal(primString() , SYM(s), true, false)); #line 740 "runtime.in" - addFunc(ve, run::gen_runtime85, primVoid(), "list", formal(primString(), "s", false, false), formal(primBoolean(), "imports", true, false)); + addFunc(ve, run::gen_runtime85, primVoid(), SYM(list), formal(primString(), SYM(s), false, false), formal(primBoolean(), SYM(imports), true, false)); #line 749 "runtime.in" REGISTER_BLTIN(run::nullGuide,"nullGuide"); #line 757 "runtime.in" @@ -1988,19 +1991,19 @@ void gen_runtime_venv(venv &ve) #line 794 "runtime.in" REGISTER_BLTIN(run::newCycleToken,"newCycleToken"); #line 799 "runtime.in" - addFunc(ve, run::gen_runtime90, primGuide(), "operator cast", formal(primCycleToken(), "tok", false, false)); + addFunc(ve, run::gen_runtime90, primGuide(), symbol::trans("operator cast"), formal(primCycleToken(), SYM(tok), false, false)); #line 806 "runtime.in" - addFunc(ve, run::gen_runtime91, primGuide(), "operator spec", formal(primPair(), "z", false, false), formal(primInt(), "p", false, false)); + addFunc(ve, run::gen_runtime91, primGuide(), symbol::trans("operator spec"), formal(primPair(), SYM(z), false, false), formal(primInt(), SYM(p), false, false)); #line 814 "runtime.in" - addFunc(ve, run::gen_runtime92, primCurlSpecifier(), "operator curl", formal(primReal(), "gamma", false, false), formal(primInt(), "p", false, false)); + addFunc(ve, run::gen_runtime92, primCurlSpecifier(), SYM_CURL, formal(primReal(), SYM(gamma), false, false), formal(primInt(), SYM(p), false, false)); #line 820 "runtime.in" REGISTER_BLTIN(run::curlSpecifierValuePart,"curlSpecifierValuePart"); #line 825 "runtime.in" REGISTER_BLTIN(run::curlSpecifierSidePart,"curlSpecifierSidePart"); #line 830 "runtime.in" - addFunc(ve, run::gen_runtime95, primGuide(), "operator cast", formal(primCurlSpecifier(), "spec", false, false)); + addFunc(ve, run::gen_runtime95, primGuide(), symbol::trans("operator cast"), formal(primCurlSpecifier(), SYM(spec), false, false)); #line 835 "runtime.in" - addFunc(ve, run::gen_runtime96, primTensionSpecifier(), "operator tension", formal(primReal(), "tout", false, false), formal(primReal(), "tin", false, false), formal(primBoolean(), "atleast", false, false)); + addFunc(ve, run::gen_runtime96, primTensionSpecifier(), SYM_TENSION, formal(primReal(), SYM(tout), false, false), formal(primReal(), SYM(tin), false, false), formal(primBoolean(), SYM(atleast), false, false)); #line 840 "runtime.in" REGISTER_BLTIN(run::tensionSpecifierOutPart,"tensionSpecifierOutPart"); #line 845 "runtime.in" @@ -2008,49 +2011,49 @@ void gen_runtime_venv(venv &ve) #line 850 "runtime.in" REGISTER_BLTIN(run::tensionSpecifierAtleastPart,"tensionSpecifierAtleastPart"); #line 855 "runtime.in" - addFunc(ve, run::gen_runtime100, primGuide(), "operator cast", formal(primTensionSpecifier(), "t", false, false)); + addFunc(ve, run::gen_runtime100, primGuide(), symbol::trans("operator cast"), formal(primTensionSpecifier(), SYM(t), false, false)); #line 860 "runtime.in" - addFunc(ve, run::gen_runtime101, primGuide(), "operator controls", formal(primPair(), "zout", false, false), formal(primPair(), "zin", false, false)); + addFunc(ve, run::gen_runtime101, primGuide(), SYM_CONTROLS, formal(primPair(), SYM(zout), false, false), formal(primPair(), SYM(zin), false, false)); #line 865 "runtime.in" - addFunc(ve, run::gen_runtime102, primInt(), "size", formal(primGuide(), "g", false, false)); + addFunc(ve, run::gen_runtime102, primInt(), SYM(size), formal(primGuide(), SYM(g), false, false)); #line 872 "runtime.in" - addFunc(ve, run::gen_runtime103, primInt(), "length", formal(primGuide(), "g", false, false)); + addFunc(ve, run::gen_runtime103, primInt(), SYM(length), formal(primGuide(), SYM(g), false, false)); #line 879 "runtime.in" - addFunc(ve, run::gen_runtime104, primBoolean(), "cyclic", formal(primGuide(), "g", false, false)); + addFunc(ve, run::gen_runtime104, primBoolean(), SYM(cyclic), formal(primGuide(), SYM(g), false, false)); #line 886 "runtime.in" - addFunc(ve, run::gen_runtime105, primPair(), "point", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runtime105, primPair(), SYM(point), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false)); #line 893 "runtime.in" - addFunc(ve, run::gen_runtime106, pairArray(), "dirSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runtime106, pairArray(), SYM(dirSpecifier), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false)); #line 905 "runtime.in" - addFunc(ve, run::gen_runtime107, pairArray(), "controlSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runtime107, pairArray(), SYM(controlSpecifier), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false)); #line 922 "runtime.in" - addFunc(ve, run::gen_runtime108, primTensionSpecifier(), "tensionSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runtime108, primTensionSpecifier(), SYM(tensionSpecifier), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false)); #line 932 "runtime.in" - addFunc(ve, run::gen_runtime109, realArray(), "curlSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); + addFunc(ve, run::gen_runtime109, realArray(), SYM(curlSpecifier), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false)); #line 946 "runtime.in" - addFunc(ve, run::gen_runtime110, primGuide(), "reverse", formal(primGuide(), "g", false, false)); + addFunc(ve, run::gen_runtime110, primGuide(), SYM(reverse), formal(primGuide(), SYM(g), false, false)); #line 1001 "runtime.in" - addFunc(ve, run::gen_runtime111, realArray(), "_cputime"); + addFunc(ve, run::gen_runtime111, realArray(), SYM(_cputime)); #line 1015 "runtime.in" - addFunc(ve, run::gen_runtime112, primBoolean(), "==", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false)); + addFunc(ve, run::gen_runtime112, primBoolean(), SYM_EQ, formal(primTransform(), SYM(a), false, false), formal(primTransform(), SYM(b), false, false)); #line 1023 "runtime.in" - addFunc(ve, run::gen_runtime113, primBoolean(), "!=", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false)); + addFunc(ve, run::gen_runtime113, primBoolean(), SYM_NEQ, formal(primTransform(), SYM(a), false, false), formal(primTransform(), SYM(b), false, false)); #line 1028 "runtime.in" - addFunc(ve, run::gen_runtime114, primTransform(), "+", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false)); + addFunc(ve, run::gen_runtime114, primTransform(), SYM_PLUS, formal(primTransform(), SYM(a), false, false), formal(primTransform(), SYM(b), false, false)); #line 1033 "runtime.in" - addFunc(ve, run::gen_runtime115, primTransform(), "*", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false)); + addFunc(ve, run::gen_runtime115, primTransform(), SYM_TIMES, formal(primTransform(), SYM(a), false, false), formal(primTransform(), SYM(b), false, false)); #line 1038 "runtime.in" - addFunc(ve, run::gen_runtime116, primPair(), "*", formal(primTransform(), "t", false, false), formal(primPair(), "z", false, false)); + addFunc(ve, run::gen_runtime116, primPair(), SYM_TIMES, formal(primTransform(), SYM(t), false, false), formal(primPair(), SYM(z), false, false)); #line 1043 "runtime.in" - addFunc(ve, run::gen_runtime117, primPath(), "*", formal(primTransform(), "t", false, false), formal(primPath(), "g", false, false)); + addFunc(ve, run::gen_runtime117, primPath(), SYM_TIMES, formal(primTransform(), SYM(t), false, false), formal(primPath(), SYM(g), false, false)); #line 1048 "runtime.in" - addFunc(ve, run::gen_runtime118, primPen(), "*", formal(primTransform(), "t", false, false), formal(primPen(), "p", false, false)); + addFunc(ve, run::gen_runtime118, primPen(), SYM_TIMES, formal(primTransform(), SYM(t), false, false), formal(primPen(), SYM(p), false, false)); #line 1053 "runtime.in" - addFunc(ve, run::gen_runtime119, primPicture(), "*", formal(primTransform(), "t", false, false), formal(primPicture(), "f", false, false)); + addFunc(ve, run::gen_runtime119, primPicture(), SYM_TIMES, formal(primTransform(), SYM(t), false, false), formal(primPicture(), SYM(f), false, false)); #line 1058 "runtime.in" - addFunc(ve, run::gen_runtime120, primPicture(), "*", formal(realArray2(), "t", false, false), formal(primPicture(), "f", false, false)); + addFunc(ve, run::gen_runtime120, primPicture(), SYM_TIMES, formal(realArray2(), SYM(t), false, false), formal(primPicture(), SYM(f), false, false)); #line 1063 "runtime.in" - addFunc(ve, run::gen_runtime121, primTransform(), "^", formal(primTransform(), "t", false, false), formal(primInt(), "n", false, false)); + addFunc(ve, run::gen_runtime121, primTransform(), SYM_CARET, formal(primTransform(), SYM(t), false, false), formal(primInt(), SYM(n), false, false)); #line 1074 "runtime.in" REGISTER_BLTIN(run::transformXPart,"transformXPart"); #line 1079 "runtime.in" @@ -2066,31 +2069,31 @@ void gen_runtime_venv(venv &ve) #line 1104 "runtime.in" REGISTER_BLTIN(run::real6ToTransform,"real6ToTransform"); #line 1110 "runtime.in" - addFunc(ve, run::gen_runtime129, primTransform(), "shift", formal(primTransform(), "t", false, false)); + addFunc(ve, run::gen_runtime129, primTransform(), SYM(shift), formal(primTransform(), SYM(t), false, false)); #line 1115 "runtime.in" - addFunc(ve, run::gen_runtime130, primTransform(), "shiftless", formal(primTransform(), "t", false, false)); + addFunc(ve, run::gen_runtime130, primTransform(), SYM(shiftless), formal(primTransform(), SYM(t), false, false)); #line 1120 "runtime.in" - addFunc(ve, run::transformIdentity, primTransform(), "identity"); + addFunc(ve, run::transformIdentity, primTransform(), SYM(identity)); #line 1125 "runtime.in" - addFunc(ve, run::gen_runtime132, primTransform(), "inverse", formal(primTransform(), "t", false, false)); + addFunc(ve, run::gen_runtime132, primTransform(), SYM(inverse), formal(primTransform(), SYM(t), false, false)); #line 1130 "runtime.in" - addFunc(ve, run::gen_runtime133, primTransform(), "shift", formal(primPair(), "z", false, false)); + addFunc(ve, run::gen_runtime133, primTransform(), SYM(shift), formal(primPair(), SYM(z), false, false)); #line 1135 "runtime.in" - addFunc(ve, run::gen_runtime134, primTransform(), "shift", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); + addFunc(ve, run::gen_runtime134, primTransform(), SYM(shift), formal(primReal(), SYM(x), false, false), formal(primReal(), SYM(y), false, false)); #line 1140 "runtime.in" - addFunc(ve, run::gen_runtime135, primTransform(), "xscale", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runtime135, primTransform(), SYM(xscale), formal(primReal(), SYM(x), false, false)); #line 1145 "runtime.in" - addFunc(ve, run::gen_runtime136, primTransform(), "yscale", formal(primReal(), "y", false, false)); + addFunc(ve, run::gen_runtime136, primTransform(), SYM(yscale), formal(primReal(), SYM(y), false, false)); #line 1150 "runtime.in" - addFunc(ve, run::gen_runtime137, primTransform(), "scale", formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runtime137, primTransform(), SYM(scale), formal(primReal(), SYM(x), false, false)); #line 1155 "runtime.in" - addFunc(ve, run::gen_runtime138, primTransform(), "scale", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); + addFunc(ve, run::gen_runtime138, primTransform(), SYM(scale), formal(primReal(), SYM(x), false, false), formal(primReal(), SYM(y), false, false)); #line 1160 "runtime.in" - addFunc(ve, run::gen_runtime139, primTransform(), "slant", formal(primReal(), "s", false, false)); + addFunc(ve, run::gen_runtime139, primTransform(), SYM(slant), formal(primReal(), SYM(s), false, false)); #line 1165 "runtime.in" - addFunc(ve, run::gen_runtime140, primTransform(), "rotate", formal(primReal(), "angle", false, false), formal(primPair(), "z", true, false)); + addFunc(ve, run::gen_runtime140, primTransform(), SYM(rotate), formal(primReal(), SYM(angle), false, false), formal(primPair(), SYM(z), true, false)); #line 1170 "runtime.in" - addFunc(ve, run::gen_runtime141, primTransform(), "reflect", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false)); + addFunc(ve, run::gen_runtime141, primTransform(), SYM(reflect), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runtime.pl b/Build/source/utils/asymptote/runtime.pl index e43813ad1c4..26330bf48f4 100755 --- a/Build/source/utils/asymptote/runtime.pl +++ b/Build/source/utils/asymptote/runtime.pl @@ -70,6 +70,31 @@ sub read_types { } } +# Scrape the symbol names of the operators from opsymbols.h. +my %opsymbols = (); +open(opsyms, "opsymbols.h") || + die("Couldn't open opsymbols.h"); +while (<opsyms>) { + if (m/^OPSYMBOL\(\"(.*)\", ([A-Za-z_]+)\);/) { + $opsymbols{ $1 } = $2; + } +} + +# Turn a name into a symbol. +sub symbolize { + my $name = shift; + if ($name =~ /^[A-Za-z0-9_]+$/) { + return "SYM($name)"; + } + if ($opsymbols{ $name }) { + return $opsymbols{ $name }; + } + if ($name =~ /operator (\w+)/ && $opsymbols{ $1 }) { + return $opsymbols{ $1 } + } + return "symbol::trans(\"" . $name . "\")" +} + sub asy_params { my $params = shift; my @params = split m/,\s*/, $params; @@ -85,7 +110,8 @@ sub asy_params { if (not $type_map{$type}) { assoc_error($filename, $line, $type); } - $_ = "formal(" . $type_map{$type} . ", \"" . lc($name) . "\"" . ", " . + $_ = "formal(" . $type_map{$type} . ", " . + symbolize(lc($name)) . ", " . ($default ? "true" : "false") . ", " . ($explicit ? "true" : "false") . ")"; } @@ -148,6 +174,7 @@ $header = <>; print $header; $source_line += ($header =~ tr/\n//);; +print "\n#include \"$prefix.symbols.h\"\n"; print "\nnamespace run {\n"; read_types($basetypes, "runtimebase.in", $basesource_type_line); @@ -196,7 +223,7 @@ while (<>) { push @builtin, "#line $source_line \"$prefix.in\"\n" . " addFunc(ve, run::" . $cname . ", " . $type_map{$type} - . ", " . '"' . $name . '"' + . ", " . symbolize($name) . ( @params ? ", " . join(", ",@asy_params) : "" ) . ");\n"; diff --git a/Build/source/utils/asymptote/runtime.symbols.h b/Build/source/utils/asymptote/runtime.symbols.h new file mode 100644 index 00000000000..a6573452e02 --- /dev/null +++ b/Build/source/utils/asymptote/runtime.symbols.h @@ -0,0 +1,116 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(_cputime); +ADDSYMBOL(_eval); +ADDSYMBOL(a); +ADDSYMBOL(abort); +ADDSYMBOL(adjust); +ADDSYMBOL(angle); +ADDSYMBOL(arclength); +ADDSYMBOL(assert); +ADDSYMBOL(asydir); +ADDSYMBOL(atleast); +ADDSYMBOL(b); +ADDSYMBOL(basealign); +ADDSYMBOL(blend); +ADDSYMBOL(byte); +ADDSYMBOL(c); +ADDSYMBOL(cd); +ADDSYMBOL(cmyk); +ADDSYMBOL(colorless); +ADDSYMBOL(colors); +ADDSYMBOL(colorspace); +ADDSYMBOL(controlSpecifier); +ADDSYMBOL(curlSpecifier); +ADDSYMBOL(cyclic); +ADDSYMBOL(defaultpen); +ADDSYMBOL(dirSpecifier); +ADDSYMBOL(embedded); +ADDSYMBOL(exit); +ADDSYMBOL(f); +ADDSYMBOL(fillrule); +ADDSYMBOL(font); +ADDSYMBOL(fontcommand); +ADDSYMBOL(fontsize); +ADDSYMBOL(g); +ADDSYMBOL(gamma); +ADDSYMBOL(gray); +ADDSYMBOL(hex); +ADDSYMBOL(identity); +ADDSYMBOL(imports); +ADDSYMBOL(interactive); +ADDSYMBOL(interactivewrite); +ADDSYMBOL(interp); +ADDSYMBOL(inverse); +ADDSYMBOL(invisible); +ADDSYMBOL(k); +ADDSYMBOL(length); +ADDSYMBOL(linecap); +ADDSYMBOL(linejoin); +ADDSYMBOL(lineskip); +ADDSYMBOL(linetype); +ADDSYMBOL(linewidth); +ADDSYMBOL(list); +ADDSYMBOL(locale); +ADDSYMBOL(location); +ADDSYMBOL(m); +ADDSYMBOL(makepen); +ADDSYMBOL(max); +ADDSYMBOL(microseconds); +ADDSYMBOL(min); +ADDSYMBOL(miterlimit); +ADDSYMBOL(n); +ADDSYMBOL(nib); +ADDSYMBOL(offset); +ADDSYMBOL(opacity); +ADDSYMBOL(overwrite); +ADDSYMBOL(p); +ADDSYMBOL(pattern); +ADDSYMBOL(point); +ADDSYMBOL(r); +ADDSYMBOL(reflect); +ADDSYMBOL(resetdefaultpen); +ADDSYMBOL(reverse); +ADDSYMBOL(rgb); +ADDSYMBOL(rotate); +ADDSYMBOL(s); +ADDSYMBOL(scale); +ADDSYMBOL(seconds); +ADDSYMBOL(shift); +ADDSYMBOL(shiftless); +ADDSYMBOL(size); +ADDSYMBOL(slant); +ADDSYMBOL(sleep); +ADDSYMBOL(spec); +ADDSYMBOL(system); +ADDSYMBOL(t); +ADDSYMBOL(tensionSpecifier); +ADDSYMBOL(tin); +ADDSYMBOL(tok); +ADDSYMBOL(tout); +ADDSYMBOL(transform); +ADDSYMBOL(uptodate); +ADDSYMBOL(usleep); +ADDSYMBOL(view); +ADDSYMBOL(x); +ADDSYMBOL(xscale); +ADDSYMBOL(y); +ADDSYMBOL(yscale); +ADDSYMBOL(z); +ADDSYMBOL(zin); +ADDSYMBOL(zout); diff --git a/Build/source/utils/asymptote/runtimebase.in b/Build/source/utils/asymptote/runtimebase.in index bce2fb0dad7..44d7dbe802b 100644 --- a/Build/source/utils/asymptote/runtimebase.in +++ b/Build/source/utils/asymptote/runtimebase.in @@ -28,6 +28,7 @@ string => primString() #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; diff --git a/Build/source/utils/asymptote/runtriple.cc b/Build/source/utils/asymptote/runtriple.cc index a240339c211..2383d6d2c7d 100644 --- a/Build/source/utils/asymptote/runtriple.cc +++ b/Build/source/utils/asymptote/runtriple.cc @@ -27,6 +27,7 @@ #include "array.h" #include "triple.h" #include "callable.h" +#include "opsymbols.h" using vm::stack; using vm::error; @@ -114,6 +115,8 @@ using namespace camp; +#include "runtriple.symbols.h" + namespace run { #line 18 "runtriple.in" void tripleZero(stack *Stack) @@ -407,55 +410,55 @@ void gen_runtriple_venv(venv &ve) #line 24 "runtriple.in" REGISTER_BLTIN(run::realRealRealToTriple,"realRealRealToTriple"); #line 29 "runtriple.in" - addFunc(ve, run::tripleXPart, primReal(), "xpart", formal(primTriple(), "v", false, false)); + addFunc(ve, run::tripleXPart, primReal(), SYM(xpart), formal(primTriple(), SYM(v), false, false)); #line 34 "runtriple.in" - addFunc(ve, run::tripleYPart, primReal(), "ypart", formal(primTriple(), "v", false, false)); + addFunc(ve, run::tripleYPart, primReal(), SYM(ypart), formal(primTriple(), SYM(v), false, false)); #line 39 "runtriple.in" - addFunc(ve, run::tripleZPart, primReal(), "zpart", formal(primTriple(), "v", false, false)); + addFunc(ve, run::tripleZPart, primReal(), SYM(zpart), formal(primTriple(), SYM(v), false, false)); #line 44 "runtriple.in" - addFunc(ve, run::gen_runtriple5, primTriple(), "*", formal(primReal(), "x", false, false), formal(primTriple(), "v", false, false)); + addFunc(ve, run::gen_runtriple5, primTriple(), SYM_TIMES, formal(primReal(), SYM(x), false, false), formal(primTriple(), SYM(v), false, false)); #line 49 "runtriple.in" - addFunc(ve, run::gen_runtriple6, primTriple(), "*", formal(primTriple(), "v", false, false), formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runtriple6, primTriple(), SYM_TIMES, formal(primTriple(), SYM(v), false, false), formal(primReal(), SYM(x), false, false)); #line 54 "runtriple.in" - addFunc(ve, run::gen_runtriple7, primTriple(), "/", formal(primTriple(), "v", false, false), formal(primReal(), "x", false, false)); + addFunc(ve, run::gen_runtriple7, primTriple(), SYM_DIVIDE, formal(primTriple(), SYM(v), false, false), formal(primReal(), SYM(x), false, false)); #line 59 "runtriple.in" - addFunc(ve, run::gen_runtriple8, primReal(), "length", formal(primTriple(), "v", false, false)); + addFunc(ve, run::gen_runtriple8, primReal(), SYM(length), formal(primTriple(), SYM(v), false, false)); #line 64 "runtriple.in" - addFunc(ve, run::gen_runtriple9, primReal(), "abs", formal(primTriple(), "v", false, false)); + addFunc(ve, run::gen_runtriple9, primReal(), SYM(abs), formal(primTriple(), SYM(v), false, false)); #line 69 "runtriple.in" - addFunc(ve, run::gen_runtriple10, primReal(), "polar", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runtriple10, primReal(), SYM(polar), formal(primTriple(), SYM(v), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 75 "runtriple.in" - addFunc(ve, run::gen_runtriple11, primReal(), "azimuth", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runtriple11, primReal(), SYM(azimuth), formal(primTriple(), SYM(v), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 81 "runtriple.in" - addFunc(ve, run::gen_runtriple12, primReal(), "colatitude", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runtriple12, primReal(), SYM(colatitude), formal(primTriple(), SYM(v), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 87 "runtriple.in" - addFunc(ve, run::gen_runtriple13, primReal(), "latitude", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runtriple13, primReal(), SYM(latitude), formal(primTriple(), SYM(v), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 93 "runtriple.in" - addFunc(ve, run::gen_runtriple14, primReal(), "longitude", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false)); + addFunc(ve, run::gen_runtriple14, primReal(), SYM(longitude), formal(primTriple(), SYM(v), false, false), formal(primBoolean(), SYM(warn), true, false)); #line 100 "runtriple.in" - addFunc(ve, run::gen_runtriple15, primTriple(), "unit", formal(primTriple(), "v", false, false)); + addFunc(ve, run::gen_runtriple15, primTriple(), SYM(unit), formal(primTriple(), SYM(v), false, false)); #line 105 "runtriple.in" - addFunc(ve, run::gen_runtriple16, primReal(), "dot", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false)); + addFunc(ve, run::gen_runtriple16, primReal(), SYM(dot), formal(primTriple(), SYM(u), false, false), formal(primTriple(), SYM(v), false, false)); #line 110 "runtriple.in" - addFunc(ve, run::gen_runtriple17, primTriple(), "cross", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false)); + addFunc(ve, run::gen_runtriple17, primTriple(), SYM(cross), formal(primTriple(), SYM(u), false, false), formal(primTriple(), SYM(v), false, false)); #line 115 "runtriple.in" - addFunc(ve, run::gen_runtriple18, primTriple(), "dir", formal(primTriple(), "z", false, true)); + addFunc(ve, run::gen_runtriple18, primTriple(), SYM(dir), formal(primTriple(), SYM(z), false, true)); #line 120 "runtriple.in" - addFunc(ve, run::gen_runtriple19, primTriple(), "expi", formal(primReal(), "polar", false, false), formal(primReal(), "azimuth", false, false)); + addFunc(ve, run::gen_runtriple19, primTriple(), SYM(expi), formal(primReal(), SYM(polar), false, false), formal(primReal(), SYM(azimuth), false, false)); #line 125 "runtriple.in" - addFunc(ve, run::gen_runtriple20, primTriple(), "dir", formal(primReal(), "colatitude", false, false), formal(primReal(), "longitude", false, false)); + addFunc(ve, run::gen_runtriple20, primTriple(), SYM(dir), formal(primReal(), SYM(colatitude), false, false), formal(primReal(), SYM(longitude), false, false)); #line 130 "runtriple.in" - addFunc(ve, run::gen_runtriple21, primTriple(), "realmult", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false)); + addFunc(ve, run::gen_runtriple21, primTriple(), SYM(realmult), formal(primTriple(), SYM(u), false, false), formal(primTriple(), SYM(v), false, false)); #line 135 "runtriple.in" - addFunc(ve, run::gen_runtriple22, primTriple(), "perp", formal(primTriple(), "v", false, false), formal(primTriple(), "u", false, false)); + addFunc(ve, run::gen_runtriple22, primTriple(), SYM(perp), formal(primTriple(), SYM(v), false, false), formal(primTriple(), SYM(u), false, false)); #line 141 "runtriple.in" - addFunc(ve, run::gen_runtriple23, primTriple(), "bezier", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runtriple23, primTriple(), SYM(bezier), formal(primTriple(), SYM(a), false, false), formal(primTriple(), SYM(b), false, false), formal(primTriple(), SYM(c), false, false), formal(primTriple(), SYM(d), false, false), formal(primReal(), SYM(t), false, false)); #line 148 "runtriple.in" - addFunc(ve, run::gen_runtriple24, primTriple(), "bezierP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runtriple24, primTriple(), SYM(bezierP), formal(primTriple(), SYM(a), false, false), formal(primTriple(), SYM(b), false, false), formal(primTriple(), SYM(c), false, false), formal(primTriple(), SYM(d), false, false), formal(primReal(), SYM(t), false, false)); #line 153 "runtriple.in" - addFunc(ve, run::gen_runtriple25, primTriple(), "bezierPP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false)); + addFunc(ve, run::gen_runtriple25, primTriple(), SYM(bezierPP), formal(primTriple(), SYM(a), false, false), formal(primTriple(), SYM(b), false, false), formal(primTriple(), SYM(c), false, false), formal(primTriple(), SYM(d), false, false), formal(primReal(), SYM(t), false, false)); #line 158 "runtriple.in" - addFunc(ve, run::gen_runtriple26, primTriple(), "bezierPPP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false)); + addFunc(ve, run::gen_runtriple26, primTriple(), SYM(bezierPPP), formal(primTriple(), SYM(a), false, false), formal(primTriple(), SYM(b), false, false), formal(primTriple(), SYM(c), false, false), formal(primTriple(), SYM(d), false, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runtriple.symbols.h b/Build/source/utils/asymptote/runtriple.symbols.h new file mode 100644 index 00000000000..476a8672943 --- /dev/null +++ b/Build/source/utils/asymptote/runtriple.symbols.h @@ -0,0 +1,48 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(a); +ADDSYMBOL(abs); +ADDSYMBOL(azimuth); +ADDSYMBOL(b); +ADDSYMBOL(bezier); +ADDSYMBOL(bezierP); +ADDSYMBOL(bezierPP); +ADDSYMBOL(bezierPPP); +ADDSYMBOL(c); +ADDSYMBOL(colatitude); +ADDSYMBOL(cross); +ADDSYMBOL(d); +ADDSYMBOL(dir); +ADDSYMBOL(dot); +ADDSYMBOL(expi); +ADDSYMBOL(latitude); +ADDSYMBOL(length); +ADDSYMBOL(longitude); +ADDSYMBOL(perp); +ADDSYMBOL(polar); +ADDSYMBOL(realmult); +ADDSYMBOL(t); +ADDSYMBOL(u); +ADDSYMBOL(unit); +ADDSYMBOL(v); +ADDSYMBOL(warn); +ADDSYMBOL(x); +ADDSYMBOL(xpart); +ADDSYMBOL(ypart); +ADDSYMBOL(z); +ADDSYMBOL(zpart); diff --git a/Build/source/utils/asymptote/symbol.cc b/Build/source/utils/asymptote/symbol.cc index 0f9a506e839..94089223417 100644 --- a/Build/source/utils/asymptote/symbol.cc +++ b/Build/source/utils/asymptote/symbol.cc @@ -22,3 +22,16 @@ symbol *symbol::ecastsym=symbol::specialTrans(string("operator ecast")); } // namespace sym +#ifdef PRESYM +/* Define all of operator symbols SYM_PLUS, etc. */ +#define OPSYMBOL(str, name) \ + sym::symbol *name = sym::symbol::opTrans(str) +#include "opsymbols.h" +#undef OPSYMBOL + +/* Define all of the symbols of the type SYM(name) in selected files. */ +#define ADDSYMBOL(name) \ + sym::symbol *PRETRANSLATED_SYMBOL_##name = sym::symbol::literalTrans(#name) +#include "allsymbols.h" +#undef ADDSYMBOL +#endif diff --git a/Build/source/utils/asymptote/symbol.h b/Build/source/utils/asymptote/symbol.h index e630c5a99b1..c4cb5a504df 100644 --- a/Build/source/utils/asymptote/symbol.h +++ b/Build/source/utils/asymptote/symbol.h @@ -57,10 +57,17 @@ public: static symbol *ecastsym; static symbol *literalTrans(string s) { +#ifdef SYMACC + symbol &slot = dict[s]; + if (slot.name.empty()) + slot=symbol(s); + return &slot; +#else if (dict.find(s) != dict.end()) return &dict[s]; else return &(dict[s]=symbol(s)); +#endif } static symbol *opTrans(string s) { diff --git a/Build/source/utils/asymptote/tests/types/resolve.asy b/Build/source/utils/asymptote/tests/types/resolve.asy index e20962bbd21..e290ad58c48 100644 --- a/Build/source/utils/asymptote/tests/types/resolve.asy +++ b/Build/source/utils/asymptote/tests/types/resolve.asy @@ -9,4 +9,53 @@ B operator cast(A) { return new B; } assert(f(new A, 3) == 1); C operator cast(A) { return new C; } assert(f(new A, 3) == 2); + +int givex(int x, int y) { return x; } +assert(givex(2002,3) == 2002); +assert(givex(2002,2002) == 2002); +assert(givex(-2005,2005) == -2005); +assert(givex(x=-77,205) == -77); +assert(givex(-77,y=205) == -77); +assert(givex(-77,x=205) == 205); +assert(givex(x=-77,y=205) == -77); +assert(givex(y=-77,x=205) == 205); + +int g(real x, real y) { return 7; } +int g(int x, real y) { return 8; } + +assert(g(4, 4) == 8); +assert(g(4, 4.4) == 8); +assert(g(4.4, 4) == 7); +assert(g(4.4, 4.4) == 7); + +assert(g(x=4, y=4) == 8); +assert(g(x=4, y=4.4) == 8); +assert(g(x=4.4, y=4) == 7); +assert(g(x=4.4, y=4.4) == 7); + +assert(g(x=4, 4) == 8); +assert(g(x=4, 4.4) == 8); +assert(g(x=4.4, 4) == 7); +assert(g(x=4.4, 4.4) == 7); + +assert(g(4, y=4) == 8); +assert(g(4, y=4.4) == 8); +assert(g(4.4, y=4) == 7); +assert(g(4.4, y=4.4) == 7); + +assert(g(y=4, x=4) == 8); +assert(g(y=4, x=4.4) == 7); +assert(g(y=4.4, x=4) == 8); +assert(g(y=4.4, x=4.4) == 7); + +assert(g(4, x=4) == 8); +assert(g(4, x=4.4) == 7); +assert(g(4.4, x=4) == 8); +assert(g(4.4, x=4.4) == 7); + +assert(g(y=4, 4) == 8); +assert(g(y=4, 4.4) == 7); +assert(g(y=4.4, 4) == 8); +assert(g(y=4.4, 4.4) == 7); + EndTest(); diff --git a/Build/source/utils/asymptote/tests/types/var.asy b/Build/source/utils/asymptote/tests/types/var.asy new file mode 100644 index 00000000000..a54500b7d00 --- /dev/null +++ b/Build/source/utils/asymptote/tests/types/var.asy @@ -0,0 +1,86 @@ +import TestLib; +StartTest("var"); +var x = 4; +assert(x + x == 8); +assert(x^2 == 16); +assert((real)x == 4.0); + +var y = x; +assert(y + y == 8); +assert(x + y == 8); +assert(y^2 == 16); +assert((real)y == 4.0); + +var z = 2 * x; +assert(z + z == 16); +assert(x + z == 12); +assert(z^2 == 64); +assert((real)z == 8.0); + +var t = sin(0); +assert(t == 0.0); +assert(2t == 0.0); + +struct A { + int x; +}; + +A a; +a.x = 3; + +var b = a; +assert(a == b); +assert(a.x == 3); + +A func(int x, int y) { return a; } + +var c = func(2,3); +assert(a == b); +assert(a.x == 3); + +int f(int x) { return x*x; } +var g = f; +assert(g == f); +for (int i = 0; i < 100; ++i) + assert(g(i) == i*i); + +/* var can be replaced with a normal type. */ +{ + typedef int var; + var x; + assert(x == 0); + + var v = 14; + assert(v == 14); +} + +{ + struct var { + int x; + } + + var n = null; + assert(n == null); + + var a; + assert(a != null); + assert(a.x == 0); + a.x = 11; + assert(a.x == 11); +} + +// Test for single evaluation of the initializer. +{ + int x = 3; + assert(x == 3); + var y = ++x; + assert(x == 4); + assert(y == 4); +} + +{ + int f = 4, f() = null; + var x = (int)f; + assert(x == 4); +} +EndTest(); diff --git a/Build/source/utils/asymptote/texfile.cc b/Build/source/utils/asymptote/texfile.cc index 15410d569cd..3f5de393c50 100644 --- a/Build/source/utils/asymptote/texfile.cc +++ b/Build/source/utils/asymptote/texfile.cc @@ -148,11 +148,16 @@ void texfile::beginlayer(const string& psname, bool postscript) *out << "{\\catcode`\"=12%" << newl << "\\includegraphics"; bool pdf=settings::pdf(texengine); + string quote; + if(stripDir(psname) != psname) + quote="\""; + if(!pdf) *out << "[bb=" << box.left << " " << box.bottom << " " << box.right << " " << box.top << "]"; - if(pdf) *out << "{\"" << stripExt(psname) << "\".pdf}%" << newl; - else *out << "{\"" << psname << "\"}%" << newl; + if(pdf) *out << "{" << quote << stripExt(psname) << quote << ".pdf}%" + << newl; + else *out << "{" << quote << psname << quote << "}%" << newl; *out << "}%" << newl; } if(!inlinetex) diff --git a/Build/source/utils/asymptote/tr.cc b/Build/source/utils/asymptote/tr.cc index d76ea846fc6..69041a5f80b 100644 --- a/Build/source/utils/asymptote/tr.cc +++ b/Build/source/utils/asymptote/tr.cc @@ -62,7 +62,6 @@ #endif #include "tr.h" - #define DEFAULT_TILE_WIDTH 256 #define DEFAULT_TILE_HEIGHT 256 #define DEFAULT_TILE_BORDER 0 @@ -290,7 +289,8 @@ void trPerspective(TRcontext *tr, GLdouble zNear, GLdouble zFar ) { GLdouble xmin, xmax, ymin, ymax; - ymax = zNear * tan(fovy * 3.14159265 / 360.0); + static const double halfradians=acos(-1.0)/360.0; + ymax = zNear * tan(fovy * halfradians); ymin = -ymax; xmin = ymin * aspect; xmax = ymax * aspect; diff --git a/Build/source/utils/asymptote/types.cc b/Build/source/utils/asymptote/types.cc index 72e72a7aac8..10b88da9c22 100644 --- a/Build/source/utils/asymptote/types.cc +++ b/Build/source/utils/asymptote/types.cc @@ -19,6 +19,9 @@ #include "access.h" #include "virtualfieldaccess.h" +// For pre-translated symbols. +#include "types.symbols.h" + namespace types { /* Base types */ @@ -62,21 +65,21 @@ void ty::print(ostream& out) const // Used for primitive virtual fields and array virtual fields. #define FIELD(Type, name, func) \ - if (sig == 0 && id == symbol::trans(name)) { \ + if (sig == 0 && id == name) { \ static trans::virtualFieldAccess a(run::func); \ static trans::varEntry v(Type(), &a, 0, position()); \ return &v; \ } #define RWFIELD(Type, name, getter, setter) \ - if (sig == 0 && id == symbol::trans(name)) { \ + if (sig == 0 && id == name) { \ static trans::virtualFieldAccess a(run::getter, run::setter); \ static trans::varEntry v(Type(), &a, 0, position()); \ return &v; \ } #define SIGFIELD(Type, name, func) \ - if (id == symbol::trans(name) && \ + if (id == name && \ equivalent(sig, Type()->getSignature())) \ { \ static trans::virtualFieldAccess a(run::func); \ @@ -84,8 +87,8 @@ void ty::print(ostream& out) const return &v; \ } -#define DSIGFIELD(name, func) \ - if (id == symbol::trans(#name) && \ +#define DSIGFIELD(name, sym, func) \ + if (id == sym && \ equivalent(sig, name##Type()->getSignature())) \ { \ static trans::virtualFieldAccess a(run::func); \ @@ -96,65 +99,66 @@ void ty::print(ostream& out) const return v; \ } -#define FILEFIELD(GetType, SetType, name) \ - FIELD(GetType,#name,name##Part); \ - SIGFIELD(SetType,#name,name##Set); +#define FILEFIELD(GetType, SetType, name, sym) \ + FIELD(GetType,sym,name##Part); \ + SIGFIELD(SetType,sym,name##Set); + ty *dimensionType() { return new function(primFile(), - formal(primInt(),"nx",true), - formal(primInt(),"ny",true), - formal(primInt(),"nz",true)); + formal(primInt(),SYM(nx),true), + formal(primInt(),SYM(ny),true), + formal(primInt(),SYM(nz),true)); } ty *modeType() { - return new function(primFile(),formal(primBoolean(),"b", true)); + return new function(primFile(),formal(primBoolean(),SYM(b), true)); } ty *readType() { - return new function(primFile(), formal(primInt(), "i")); + return new function(primFile(), formal(primInt(), SYM(i))); } trans::varEntry *primitiveTy::virtualField(symbol *id, signature *sig) { switch (kind) { case ty_pair: - FIELD(primReal,"x",pairXPart); - FIELD(primReal,"y",pairYPart); + FIELD(primReal,SYM(x),pairXPart); + FIELD(primReal,SYM(y),pairYPart); break; case ty_triple: - FIELD(primReal,"x",tripleXPart); - FIELD(primReal,"y",tripleYPart); - FIELD(primReal,"z",tripleZPart); + FIELD(primReal,SYM(x),tripleXPart); + FIELD(primReal,SYM(y),tripleYPart); + FIELD(primReal,SYM(z),tripleZPart); break; case ty_transform: - FIELD(primReal,"x",transformXPart); - FIELD(primReal,"y",transformYPart); - FIELD(primReal,"xx",transformXXPart); - FIELD(primReal,"xy",transformXYPart); - FIELD(primReal,"yx",transformYXPart); - FIELD(primReal,"yy",transformYYPart); + FIELD(primReal,SYM(x),transformXPart); + FIELD(primReal,SYM(y),transformYPart); + FIELD(primReal,SYM(xx),transformXXPart); + FIELD(primReal,SYM(xy),transformXYPart); + FIELD(primReal,SYM(yx),transformYXPart); + FIELD(primReal,SYM(yy),transformYYPart); break; case ty_tensionSpecifier: - FIELD(primReal,"out",tensionSpecifierOutPart); - FIELD(primReal,"in",tensionSpecifierInPart); - FIELD(primBoolean,"atLeast",tensionSpecifierAtleastPart); + FIELD(primReal,SYM(out),tensionSpecifierOutPart); + FIELD(primReal,SYM(in),tensionSpecifierInPart); + FIELD(primBoolean,SYM(atLeast),tensionSpecifierAtleastPart); break; case ty_curlSpecifier: - FIELD(primReal,"value",curlSpecifierValuePart); - FIELD(primInt,"side",curlSpecifierSidePart); + FIELD(primReal,SYM(value),curlSpecifierValuePart); + FIELD(primInt,SYM(side),curlSpecifierSidePart); break; case ty_file: - FIELD(primString,"name",namePart); - FIELD(primString,"mode",modePart); - FILEFIELD(IntArray,dimensionType,dimension); - FILEFIELD(primBoolean,modeType,line); - FILEFIELD(primBoolean,modeType,csv); - FILEFIELD(primBoolean,modeType,word); - FILEFIELD(primBoolean,modeType,singlereal); - FILEFIELD(primBoolean,modeType,singleint); - FILEFIELD(primBoolean,modeType,signedint); - SIGFIELD(readType,"read",readSet); + FIELD(primString,SYM(name),namePart); + FIELD(primString,SYM(mode),modePart); + FILEFIELD(IntArray,dimensionType,dimension,SYM(dimension)); + FILEFIELD(primBoolean,modeType,line,SYM(line)); + FILEFIELD(primBoolean,modeType,csv,SYM(csv)); + FILEFIELD(primBoolean,modeType,word,SYM(word)); + FILEFIELD(primBoolean,modeType,singlereal,SYM(singlereal)); + FILEFIELD(primBoolean,modeType,singleint,SYM(singleint)); + FILEFIELD(primBoolean,modeType,signedint,SYM(signedint)); + SIGFIELD(readType,SYM(read),readSet); break; default: break; @@ -185,15 +189,15 @@ ty *ty::virtualFieldGetType(symbol *id) ty *primitiveTy::virtualFieldGetType(symbol *id) { if(kind == ty_file) { - if (id == symbol::trans("dimension")) + if (id == SYM(dimension)) return overloadedDimensionType(); - if (id == symbol::trans("line") || id == symbol::trans("csv") || - id == symbol::trans("word") || id == symbol::trans("singlereal") || - id == symbol::trans("singleint") || id == symbol::trans("signedint")) + if (id == SYM(line) || id == SYM(csv) || + id == SYM(word) || id == SYM(singlereal) || + id == SYM(singleint) || id == SYM(signedint)) return overloadedModeType(); - if (id == symbol::trans("read")) + if (id == SYM(read)) return readType(); } @@ -232,7 +236,7 @@ trans::access *array::initializer() ty *array::pushType() { if (pushtype == 0) - pushtype = new function(celltype,formal(celltype,"x")); + pushtype = new function(celltype,formal(celltype,SYM(x))); return pushtype; } @@ -248,7 +252,7 @@ ty *array::popType() ty *array::appendType() { if (appendtype == 0) - appendtype = new function(primVoid(),formal(this,"a")); + appendtype = new function(primVoid(),formal(this,SYM(a))); return appendtype; } @@ -256,7 +260,7 @@ ty *array::appendType() ty *array::insertType() { if (inserttype == 0) { - function *f=new function(primVoid(),formal(primInt(),"i")); + function *f=new function(primVoid(),formal(primInt(),SYM(i))); f->addRest(this); inserttype = f; } @@ -267,28 +271,28 @@ ty *array::insertType() ty *array::deleteType() { if (deletetype == 0) - deletetype = new function(primVoid(),formal(primInt(),"i",true), - formal(primInt(),"j",true)); + deletetype = new function(primVoid(),formal(primInt(),SYM(i),true), + formal(primInt(),SYM(j),true)); return deletetype; } ty *initializedType() { - return new function(primBoolean(),formal(primInt(),"i")); + return new function(primBoolean(),formal(primInt(),SYM(i))); } #define SIGFIELDLIST \ - ASIGFIELD(initialized, arrayInitialized); \ - ASIGFIELD(push, arrayPush); \ - ASIGFIELD(pop, arrayPop); \ - ASIGFIELD(append, arrayAppend); \ - ASIGFIELD(insert, arrayInsert); \ - ASIGFIELD(delete, arrayDelete); \ + ASIGFIELD(initialized, SYM(initialized), arrayInitialized); \ + ASIGFIELD(push, SYM(push), arrayPush); \ + ASIGFIELD(pop, SYM(pop), arrayPop); \ + ASIGFIELD(append, SYM(append), arrayAppend); \ + ASIGFIELD(insert, SYM(insert), arrayInsert); \ + ASIGFIELD(delete, SYM(delete), arrayDelete); \ ty *array::virtualFieldGetType(symbol *id) { - #define ASIGFIELD(name, func) \ - if (id == symbol::trans(#name)) \ + #define ASIGFIELD(name, sym, func) \ + if (id == sym) \ return name##Type(); SIGFIELDLIST @@ -300,11 +304,11 @@ ty *array::virtualFieldGetType(symbol *id) trans::varEntry *array::virtualField(symbol *id, signature *sig) { - FIELD(primInt, "length", arrayLength); - FIELD(IntArray, "keys", arrayKeys); - RWFIELD(primBoolean, "cyclic", arrayCyclicFlag, arraySetCyclicFlag); + FIELD(primInt, SYM(length), arrayLength); + FIELD(IntArray, SYM(keys), arrayKeys); + RWFIELD(primBoolean, SYM(cyclic), arrayCyclicFlag, arraySetCyclicFlag); - #define ASIGFIELD(name, func) DSIGFIELD(name,func) + #define ASIGFIELD(name, sym, func) DSIGFIELD(name, sym, func) SIGFIELDLIST diff --git a/Build/source/utils/asymptote/types.h b/Build/source/utils/asymptote/types.h index 1cb31869c80..93cdcc5b0ba 100644 --- a/Build/source/utils/asymptote/types.h +++ b/Build/source/utils/asymptote/types.h @@ -281,12 +281,17 @@ struct formal { : t(t), name(name), defval(optional ? absyntax::Default : 0), Explicit(Explicit) {} + // string->symbol translation is costly if done too many times. This + // constructor has been disabled to make this cost more visible to the + // programmer. +#if 0 formal(ty *t, const char *name, bool optional=false, bool Explicit=false) : t(t), name(symbol::trans(name)), defval(optional ? absyntax::Default : 0), Explicit(Explicit) {} +#endif friend ostream& operator<< (ostream& out, const formal& f); }; diff --git a/Build/source/utils/asymptote/types.symbols.h b/Build/source/utils/asymptote/types.symbols.h new file mode 100644 index 00000000000..4a1ffe028d3 --- /dev/null +++ b/Build/source/utils/asymptote/types.symbols.h @@ -0,0 +1,55 @@ +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +ADDSYMBOL(a); +ADDSYMBOL(append); +ADDSYMBOL(atLeast); +ADDSYMBOL(b); +ADDSYMBOL(csv); +ADDSYMBOL(cyclic); +ADDSYMBOL(delete); +ADDSYMBOL(dimension); +ADDSYMBOL(i); +ADDSYMBOL(in); +ADDSYMBOL(initialized); +ADDSYMBOL(insert); +ADDSYMBOL(j); +ADDSYMBOL(keys); +ADDSYMBOL(length); +ADDSYMBOL(line); +ADDSYMBOL(mode); +ADDSYMBOL(name); +ADDSYMBOL(nx); +ADDSYMBOL(ny); +ADDSYMBOL(nz); +ADDSYMBOL(out); +ADDSYMBOL(pop); +ADDSYMBOL(push); +ADDSYMBOL(read); +ADDSYMBOL(side); +ADDSYMBOL(signedint); +ADDSYMBOL(singleint); +ADDSYMBOL(singlereal); +ADDSYMBOL(value); +ADDSYMBOL(word); +ADDSYMBOL(x); +ADDSYMBOL(xx); +ADDSYMBOL(xy); +ADDSYMBOL(y); +ADDSYMBOL(yx); +ADDSYMBOL(yy); +ADDSYMBOL(z); |